forked from eatvio/eatvio_app
feat(diary): consultant comments
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
import 'dart:developer';
|
||||
import 'package:eatvio_app/features/diary/models/consultant_comment_model.dart';
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/consultant_comments_cubit/consultant_comments_state.dart';
|
||||
import 'package:eatvio_app/features/diary/repositories/diary_repository.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class ConsultantCommentsCubit extends Cubit<ConsultantCommentsState> {
|
||||
final DiaryRepository diaryRepository;
|
||||
ConsultantCommentsCubit({required this.diaryRepository})
|
||||
: super(
|
||||
ConsultantCommentsState(
|
||||
commentsModel: ConsultantCommentModel(
|
||||
comment: '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
void setComment(String comment) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
commentsModel: state.commentsModel.copyWith(comment: comment),
|
||||
dayCommentNeedsToBeFilled: comment.length < 3,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void setMealComment({required int mealNumber, required String comment}) {
|
||||
if (comment.isEmpty) {
|
||||
final mealsComments = Map<String, MealCommentModel>.from(state.commentsModel.mealsComments);
|
||||
mealsComments.remove(mealNumber.toString());
|
||||
emit(state.copyWith.commentsModel(mealsComments: mealsComments));
|
||||
return;
|
||||
}
|
||||
final mealsComments = Map<String, MealCommentModel>.from(state.commentsModel.mealsComments);
|
||||
mealsComments[mealNumber.toString()] = MealCommentModel(comment: comment, typeNumber: mealNumber);
|
||||
emit(state.copyWith.commentsModel(mealsComments: mealsComments));
|
||||
}
|
||||
|
||||
void addPortionComment(PortionCommentModel portionComment) {
|
||||
final portions = [...state.commentsModel.portions];
|
||||
portions.add(portionComment);
|
||||
emit(state.copyWith.commentsModel(portions: portions));
|
||||
}
|
||||
|
||||
void updatePortionComment(PortionCommentModel portionCommentModel) {
|
||||
if (portionCommentModel.comment.isEmpty) {
|
||||
final portions = [...state.commentsModel.portions];
|
||||
final updatedPortions = portions.where((portion) => portion.id != portionCommentModel.id).toList();
|
||||
emit(state.copyWith.commentsModel(portions: updatedPortions));
|
||||
return;
|
||||
}
|
||||
final portions = [...state.commentsModel.portions];
|
||||
final updatedPortions = portions.map((portion) {
|
||||
if (portion.id == portionCommentModel.id) {
|
||||
return portionCommentModel;
|
||||
}
|
||||
return portion;
|
||||
}).toList();
|
||||
|
||||
emit(state.copyWith.commentsModel(portions: updatedPortions));
|
||||
}
|
||||
|
||||
Future<void> submitComments(int diaryId) async {
|
||||
try {
|
||||
if (state.commentsModel.comment == null || state.commentsModel.comment!.isEmpty || state.commentsModel.comment!.length < 3) {
|
||||
emit(state.copyWith(dayCommentNeedsToBeFilled: true));
|
||||
return;
|
||||
}
|
||||
if (state.commentsModel.mealsComments.values.any((element) => element.comment.length < 3)) {
|
||||
return;
|
||||
}
|
||||
if (state.commentsModel.portions.any((element) => element.comment.length < 3)) {
|
||||
return;
|
||||
}
|
||||
await diaryRepository.commentUserDay(diaryId: diaryId, commentModel: state.commentsModel);
|
||||
} catch (e, st) {
|
||||
log(e.toString(), stackTrace: st);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
import 'package:eatvio_app/features/diary/models/consultant_comment_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'consultant_comments_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class ConsultantCommentsState with _$ConsultantCommentsState {
|
||||
|
||||
factory ConsultantCommentsState({
|
||||
required ConsultantCommentModel commentsModel,
|
||||
@Default(false) bool dayCommentNeedsToBeFilled
|
||||
}) = _ConsultantCommentsState;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'consultant_comments_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ConsultantCommentsState {
|
||||
ConsultantCommentModel get commentsModel =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get dayCommentNeedsToBeFilled => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ConsultantCommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$ConsultantCommentsStateCopyWith<ConsultantCommentsState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ConsultantCommentsStateCopyWith<$Res> {
|
||||
factory $ConsultantCommentsStateCopyWith(ConsultantCommentsState value,
|
||||
$Res Function(ConsultantCommentsState) then) =
|
||||
_$ConsultantCommentsStateCopyWithImpl<$Res, ConsultantCommentsState>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{ConsultantCommentModel commentsModel, bool dayCommentNeedsToBeFilled});
|
||||
|
||||
$ConsultantCommentModelCopyWith<$Res> get commentsModel;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ConsultantCommentsStateCopyWithImpl<$Res,
|
||||
$Val extends ConsultantCommentsState>
|
||||
implements $ConsultantCommentsStateCopyWith<$Res> {
|
||||
_$ConsultantCommentsStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ConsultantCommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? commentsModel = null,
|
||||
Object? dayCommentNeedsToBeFilled = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
commentsModel: null == commentsModel
|
||||
? _value.commentsModel
|
||||
: commentsModel // ignore: cast_nullable_to_non_nullable
|
||||
as ConsultantCommentModel,
|
||||
dayCommentNeedsToBeFilled: null == dayCommentNeedsToBeFilled
|
||||
? _value.dayCommentNeedsToBeFilled
|
||||
: dayCommentNeedsToBeFilled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
/// Create a copy of ConsultantCommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ConsultantCommentModelCopyWith<$Res> get commentsModel {
|
||||
return $ConsultantCommentModelCopyWith<$Res>(_value.commentsModel, (value) {
|
||||
return _then(_value.copyWith(commentsModel: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ConsultantCommentsStateImplCopyWith<$Res>
|
||||
implements $ConsultantCommentsStateCopyWith<$Res> {
|
||||
factory _$$ConsultantCommentsStateImplCopyWith(
|
||||
_$ConsultantCommentsStateImpl value,
|
||||
$Res Function(_$ConsultantCommentsStateImpl) then) =
|
||||
__$$ConsultantCommentsStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{ConsultantCommentModel commentsModel, bool dayCommentNeedsToBeFilled});
|
||||
|
||||
@override
|
||||
$ConsultantCommentModelCopyWith<$Res> get commentsModel;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ConsultantCommentsStateImplCopyWithImpl<$Res>
|
||||
extends _$ConsultantCommentsStateCopyWithImpl<$Res,
|
||||
_$ConsultantCommentsStateImpl>
|
||||
implements _$$ConsultantCommentsStateImplCopyWith<$Res> {
|
||||
__$$ConsultantCommentsStateImplCopyWithImpl(
|
||||
_$ConsultantCommentsStateImpl _value,
|
||||
$Res Function(_$ConsultantCommentsStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of ConsultantCommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? commentsModel = null,
|
||||
Object? dayCommentNeedsToBeFilled = null,
|
||||
}) {
|
||||
return _then(_$ConsultantCommentsStateImpl(
|
||||
commentsModel: null == commentsModel
|
||||
? _value.commentsModel
|
||||
: commentsModel // ignore: cast_nullable_to_non_nullable
|
||||
as ConsultantCommentModel,
|
||||
dayCommentNeedsToBeFilled: null == dayCommentNeedsToBeFilled
|
||||
? _value.dayCommentNeedsToBeFilled
|
||||
: dayCommentNeedsToBeFilled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ConsultantCommentsStateImpl implements _ConsultantCommentsState {
|
||||
_$ConsultantCommentsStateImpl(
|
||||
{required this.commentsModel, this.dayCommentNeedsToBeFilled = false});
|
||||
|
||||
@override
|
||||
final ConsultantCommentModel commentsModel;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool dayCommentNeedsToBeFilled;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ConsultantCommentsState(commentsModel: $commentsModel, dayCommentNeedsToBeFilled: $dayCommentNeedsToBeFilled)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ConsultantCommentsStateImpl &&
|
||||
(identical(other.commentsModel, commentsModel) ||
|
||||
other.commentsModel == commentsModel) &&
|
||||
(identical(other.dayCommentNeedsToBeFilled,
|
||||
dayCommentNeedsToBeFilled) ||
|
||||
other.dayCommentNeedsToBeFilled == dayCommentNeedsToBeFilled));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, commentsModel, dayCommentNeedsToBeFilled);
|
||||
|
||||
/// Create a copy of ConsultantCommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ConsultantCommentsStateImplCopyWith<_$ConsultantCommentsStateImpl>
|
||||
get copyWith => __$$ConsultantCommentsStateImplCopyWithImpl<
|
||||
_$ConsultantCommentsStateImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _ConsultantCommentsState implements ConsultantCommentsState {
|
||||
factory _ConsultantCommentsState(
|
||||
{required final ConsultantCommentModel commentsModel,
|
||||
final bool dayCommentNeedsToBeFilled}) = _$ConsultantCommentsStateImpl;
|
||||
|
||||
@override
|
||||
ConsultantCommentModel get commentsModel;
|
||||
@override
|
||||
bool get dayCommentNeedsToBeFilled;
|
||||
|
||||
/// Create a copy of ConsultantCommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ConsultantCommentsStateImplCopyWith<_$ConsultantCommentsStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -2,6 +2,9 @@ import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:eatvio_app/core/image_compressing/image_compress_utility.dart';
|
||||
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
||||
import 'package:eatvio_app/features/diary/models/consultant_review_model.dart';
|
||||
import 'package:eatvio_app/features/diary/models/diary_day_model.dart';
|
||||
import 'package:eatvio_app/features/diary/models/nutrition_model.dart';
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
||||
@@ -16,12 +19,17 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
late int selectedMeal;
|
||||
final DiaryRepository diaryRepository;
|
||||
final GlossaryRepository glossaryRepository;
|
||||
|
||||
int? diaryId;
|
||||
DiaryCubit({required this.diaryRepository, required this.glossaryRepository}) : super(const DiaryState.loading()) {
|
||||
today = DateTime.now();
|
||||
selectedDay = today;
|
||||
diaryRepository.forceFetchStream.listen((_) {
|
||||
fetchDiary(true, diaryId);
|
||||
});
|
||||
}
|
||||
|
||||
String comment = '';
|
||||
|
||||
setSelectedDay(DateTime day) async {
|
||||
selectedDay = day;
|
||||
await fetchDiary(true);
|
||||
@@ -32,21 +40,41 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
emit((state as DiaryStateLoaded).copyWith(selectedMeal: selectedMeal));
|
||||
}
|
||||
|
||||
fetchDiary([bool needLoading = false]) async {
|
||||
fetchDiary([bool needLoading = false, int? diaryId]) async {
|
||||
this.diaryId ??= diaryId;
|
||||
if (needLoading) {
|
||||
emit(const DiaryState.loading());
|
||||
selectedMeal = 1;
|
||||
}
|
||||
try {
|
||||
final diaryDay = await diaryRepository.getDiaryByDate('$selectedDay');
|
||||
|
||||
final DiaryDayModel diaryDay;
|
||||
if (diaryId != null) {
|
||||
diaryDay = await diaryRepository.getDiaryDay(diaryId);
|
||||
} else {
|
||||
final stringDate = selectedDay.toUtc().format('yyyy-MM-dd');
|
||||
diaryDay = await diaryRepository.getDiaryByDate(stringDate);
|
||||
}
|
||||
ConsultantReviewModel? consultantReview;
|
||||
if (diaryDay.chosenPlanId != null) {
|
||||
consultantReview = await diaryRepository.getDiaryComments(planId: diaryDay.chosenPlanId!, diaryId: diaryDay.id);
|
||||
}
|
||||
final nutrition = await getNutrition(diaryDay.id);
|
||||
|
||||
final isDiaryFinished = diaryDay.typeOfDiary.diaryState == DiaryStateEnum.finished || diaryDay.typeOfDiary.diaryState == DiaryStateEnum.lastDayFinished;
|
||||
|
||||
final isDiaryCommented = diaryDay.typeOfDiary.diaryState == DiaryStateEnum.commented ||
|
||||
diaryDay.typeOfDiary.diaryState == DiaryStateEnum.lastDayCommented ||
|
||||
diaryDay.typeOfDiary.diaryState == DiaryStateEnum.reviewedByUser;
|
||||
emit(
|
||||
DiaryState.loaded(
|
||||
diary: diaryDay,
|
||||
nutrition: nutrition,
|
||||
selectedDay: selectedDay,
|
||||
selectedMeal: selectedMeal,
|
||||
isConsultantView: this.diaryId != null,
|
||||
consultantReview: consultantReview,
|
||||
isDiaryFinished: isDiaryFinished,
|
||||
isDiaryCommented: isDiaryCommented,
|
||||
),
|
||||
);
|
||||
} catch (e, st) {
|
||||
@@ -55,7 +83,11 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
}
|
||||
}
|
||||
|
||||
finishDiaryDay({required int diaryId, required String wakeUp, required String retire, String? comment}) async {
|
||||
finishDiaryDay({
|
||||
required int diaryId,
|
||||
required String wakeUp,
|
||||
required String retire,
|
||||
}) async {
|
||||
await diaryRepository.finishDiaryDay(diaryId: diaryId, wakeUp: wakeUp, retire: retire, comment: comment);
|
||||
await fetchDiary();
|
||||
}
|
||||
@@ -192,6 +224,6 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
}
|
||||
|
||||
fillComment(String comment) {
|
||||
emit((state as DiaryStateLoaded).copyWith(diary: (state as DiaryStateLoaded).diary.copyWith(comment: comment)));
|
||||
this.comment = comment;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:eatvio_app/features/diary/models/consultant_review_model.dart';
|
||||
import 'package:eatvio_app/features/diary/models/diary_day_model.dart';
|
||||
import 'package:eatvio_app/features/diary/models/nutrition_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
@@ -19,6 +20,9 @@ class DiaryState with _$DiaryState {
|
||||
required NutritionDataModel nutrition,
|
||||
required DateTime selectedDay,
|
||||
required int selectedMeal,
|
||||
|
||||
@Default(false) bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
@Default(false) bool isDiaryFinished,
|
||||
@Default(false) bool isDiaryCommented,
|
||||
}) = DiaryStateLoaded;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,15 @@ mixin _$DiaryState {
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String errorMessage) error,
|
||||
required TResult Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)
|
||||
required TResult Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)
|
||||
loaded,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@@ -31,8 +38,15 @@ mixin _$DiaryState {
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
TResult? Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)?
|
||||
TResult? Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)?
|
||||
loaded,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@@ -41,8 +55,15 @@ mixin _$DiaryState {
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(String errorMessage)? error,
|
||||
TResult Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)?
|
||||
TResult Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)?
|
||||
loaded,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
@@ -139,8 +160,15 @@ class _$DiaryStateImpl implements _DiaryState {
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String errorMessage) error,
|
||||
required TResult Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)
|
||||
required TResult Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)
|
||||
loaded,
|
||||
}) {
|
||||
return $default();
|
||||
@@ -152,8 +180,15 @@ class _$DiaryStateImpl implements _DiaryState {
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
TResult? Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)?
|
||||
TResult? Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)?
|
||||
loaded,
|
||||
}) {
|
||||
return $default?.call();
|
||||
@@ -165,8 +200,15 @@ class _$DiaryStateImpl implements _DiaryState {
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(String errorMessage)? error,
|
||||
TResult Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)?
|
||||
TResult Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)?
|
||||
loaded,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
@@ -262,8 +304,15 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String errorMessage) error,
|
||||
required TResult Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)
|
||||
required TResult Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)
|
||||
loaded,
|
||||
}) {
|
||||
return loading();
|
||||
@@ -275,8 +324,15 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
TResult? Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)?
|
||||
TResult? Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)?
|
||||
loaded,
|
||||
}) {
|
||||
return loading?.call();
|
||||
@@ -288,8 +344,15 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(String errorMessage)? error,
|
||||
TResult Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)?
|
||||
TResult Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)?
|
||||
loaded,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
@@ -414,8 +477,15 @@ class _$DiaryStateErrorImpl implements DiaryStateError {
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String errorMessage) error,
|
||||
required TResult Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)
|
||||
required TResult Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)
|
||||
loaded,
|
||||
}) {
|
||||
return error(errorMessage);
|
||||
@@ -427,8 +497,15 @@ class _$DiaryStateErrorImpl implements DiaryStateError {
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
TResult? Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)?
|
||||
TResult? Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)?
|
||||
loaded,
|
||||
}) {
|
||||
return error?.call(errorMessage);
|
||||
@@ -440,8 +517,15 @@ class _$DiaryStateErrorImpl implements DiaryStateError {
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(String errorMessage)? error,
|
||||
TResult Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)?
|
||||
TResult Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)?
|
||||
loaded,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
@@ -512,10 +596,15 @@ abstract class _$$DiaryStateLoadedImplCopyWith<$Res> {
|
||||
{DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal});
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented});
|
||||
|
||||
$DiaryDayModelCopyWith<$Res> get diary;
|
||||
$NutritionDataModelCopyWith<$Res> get nutrition;
|
||||
$ConsultantReviewModelCopyWith<$Res>? get consultantReview;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -535,6 +624,10 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res>
|
||||
Object? nutrition = null,
|
||||
Object? selectedDay = null,
|
||||
Object? selectedMeal = null,
|
||||
Object? isConsultantView = null,
|
||||
Object? consultantReview = freezed,
|
||||
Object? isDiaryFinished = null,
|
||||
Object? isDiaryCommented = null,
|
||||
}) {
|
||||
return _then(_$DiaryStateLoadedImpl(
|
||||
diary: null == diary
|
||||
@@ -553,6 +646,22 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res>
|
||||
? _value.selectedMeal
|
||||
: selectedMeal // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
isConsultantView: null == isConsultantView
|
||||
? _value.isConsultantView
|
||||
: isConsultantView // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
consultantReview: freezed == consultantReview
|
||||
? _value.consultantReview
|
||||
: consultantReview // ignore: cast_nullable_to_non_nullable
|
||||
as ConsultantReviewModel?,
|
||||
isDiaryFinished: null == isDiaryFinished
|
||||
? _value.isDiaryFinished
|
||||
: isDiaryFinished // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
isDiaryCommented: null == isDiaryCommented
|
||||
? _value.isDiaryCommented
|
||||
: isDiaryCommented // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -575,6 +684,21 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res>
|
||||
return _then(_value.copyWith(nutrition: value));
|
||||
});
|
||||
}
|
||||
|
||||
/// Create a copy of DiaryState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ConsultantReviewModelCopyWith<$Res>? get consultantReview {
|
||||
if (_value.consultantReview == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $ConsultantReviewModelCopyWith<$Res>(_value.consultantReview!,
|
||||
(value) {
|
||||
return _then(_value.copyWith(consultantReview: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -584,7 +708,11 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
{required this.diary,
|
||||
required this.nutrition,
|
||||
required this.selectedDay,
|
||||
required this.selectedMeal});
|
||||
required this.selectedMeal,
|
||||
this.isConsultantView = false,
|
||||
this.consultantReview,
|
||||
this.isDiaryFinished = false,
|
||||
this.isDiaryCommented = false});
|
||||
|
||||
@override
|
||||
final DiaryDayModel diary;
|
||||
@@ -594,10 +722,21 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
final DateTime selectedDay;
|
||||
@override
|
||||
final int selectedMeal;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isConsultantView;
|
||||
@override
|
||||
final ConsultantReviewModel? consultantReview;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isDiaryFinished;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isDiaryCommented;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DiaryState.loaded(diary: $diary, nutrition: $nutrition, selectedDay: $selectedDay, selectedMeal: $selectedMeal)';
|
||||
return 'DiaryState.loaded(diary: $diary, nutrition: $nutrition, selectedDay: $selectedDay, selectedMeal: $selectedMeal, isConsultantView: $isConsultantView, consultantReview: $consultantReview, isDiaryFinished: $isDiaryFinished, isDiaryCommented: $isDiaryCommented)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -611,12 +750,28 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
(identical(other.selectedDay, selectedDay) ||
|
||||
other.selectedDay == selectedDay) &&
|
||||
(identical(other.selectedMeal, selectedMeal) ||
|
||||
other.selectedMeal == selectedMeal));
|
||||
other.selectedMeal == selectedMeal) &&
|
||||
(identical(other.isConsultantView, isConsultantView) ||
|
||||
other.isConsultantView == isConsultantView) &&
|
||||
(identical(other.consultantReview, consultantReview) ||
|
||||
other.consultantReview == consultantReview) &&
|
||||
(identical(other.isDiaryFinished, isDiaryFinished) ||
|
||||
other.isDiaryFinished == isDiaryFinished) &&
|
||||
(identical(other.isDiaryCommented, isDiaryCommented) ||
|
||||
other.isDiaryCommented == isDiaryCommented));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, diary, nutrition, selectedDay, selectedMeal);
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
diary,
|
||||
nutrition,
|
||||
selectedDay,
|
||||
selectedMeal,
|
||||
isConsultantView,
|
||||
consultantReview,
|
||||
isDiaryFinished,
|
||||
isDiaryCommented);
|
||||
|
||||
/// Create a copy of DiaryState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -633,11 +788,19 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String errorMessage) error,
|
||||
required TResult Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)
|
||||
required TResult Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)
|
||||
loaded,
|
||||
}) {
|
||||
return loaded(diary, nutrition, selectedDay, selectedMeal);
|
||||
return loaded(diary, nutrition, selectedDay, selectedMeal, isConsultantView,
|
||||
consultantReview, isDiaryFinished, isDiaryCommented);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -646,11 +809,19 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
TResult? Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)?
|
||||
TResult? Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)?
|
||||
loaded,
|
||||
}) {
|
||||
return loaded?.call(diary, nutrition, selectedDay, selectedMeal);
|
||||
return loaded?.call(diary, nutrition, selectedDay, selectedMeal,
|
||||
isConsultantView, consultantReview, isDiaryFinished, isDiaryCommented);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -659,13 +830,28 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(String errorMessage)? error,
|
||||
TResult Function(DiaryDayModel diary, NutritionDataModel nutrition,
|
||||
DateTime selectedDay, int selectedMeal)?
|
||||
TResult Function(
|
||||
DiaryDayModel diary,
|
||||
NutritionDataModel nutrition,
|
||||
DateTime selectedDay,
|
||||
int selectedMeal,
|
||||
bool isConsultantView,
|
||||
ConsultantReviewModel? consultantReview,
|
||||
bool isDiaryFinished,
|
||||
bool isDiaryCommented)?
|
||||
loaded,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(diary, nutrition, selectedDay, selectedMeal);
|
||||
return loaded(
|
||||
diary,
|
||||
nutrition,
|
||||
selectedDay,
|
||||
selectedMeal,
|
||||
isConsultantView,
|
||||
consultantReview,
|
||||
isDiaryFinished,
|
||||
isDiaryCommented);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
@@ -713,12 +899,20 @@ abstract class DiaryStateLoaded implements DiaryState {
|
||||
{required final DiaryDayModel diary,
|
||||
required final NutritionDataModel nutrition,
|
||||
required final DateTime selectedDay,
|
||||
required final int selectedMeal}) = _$DiaryStateLoadedImpl;
|
||||
required final int selectedMeal,
|
||||
final bool isConsultantView,
|
||||
final ConsultantReviewModel? consultantReview,
|
||||
final bool isDiaryFinished,
|
||||
final bool isDiaryCommented}) = _$DiaryStateLoadedImpl;
|
||||
|
||||
DiaryDayModel get diary;
|
||||
NutritionDataModel get nutrition;
|
||||
DateTime get selectedDay;
|
||||
int get selectedMeal;
|
||||
bool get isConsultantView;
|
||||
ConsultantReviewModel? get consultantReview;
|
||||
bool get isDiaryFinished;
|
||||
bool get isDiaryCommented;
|
||||
|
||||
/// Create a copy of DiaryState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
|
||||
Reference in New Issue
Block a user