diff --git a/android/build.gradle b/android/build.gradle index bc157bd1..002c6222 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,4 +1,7 @@ allprojects { + tasks.withType(JavaCompile) { + options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" + } repositories { google() mavenCentral() diff --git a/lib/app_router.dart b/lib/app_router.dart index 2f1f53e4..d88156f1 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -75,43 +75,38 @@ class AppRouter { }, routes: [ GoRoute( - pageBuilder: (context, state) => NoTransitionPage(child: ProfileScreen()), path: '/my-profile-screen', name: 'myProfileScreen', redirect: (context, state) async { await context.read().runInitialization(); return null; }, + builder: (context, state) => ProfileScreen(), ), GoRoute( - pageBuilder: (context, state) => NoTransitionPage(child: FeedScreen()), path: '/feed-screen', name: 'feedScreen', + builder: (context, state) => FeedScreen(), ), GoRoute( - pageBuilder: (context, state) { - if (state.extra != null) - return NoTransitionPage(child: DiaryScreen(diaryID: state.extra as String)); - else - return NoTransitionPage(child: DiaryScreen(diaryID: '0')); - }, path: '/diary-screen', name: 'diaryScreen', + builder: (context, state) => DiaryScreen(), ), GoRoute( - pageBuilder: (context, state) => NoTransitionPage(child: ChatSelectScreen()), path: '/chat-select-screen', name: 'chatSelectScreen', + builder: (context, state) => ChatSelectScreen(), ), GoRoute( - pageBuilder: (context, state) => NoTransitionPage(child: NotificationsScreen()), path: '/notifications-screen', name: 'notificationsScreen', + builder: (context, state) => NotificationsScreen(), ), GoRoute( - pageBuilder: (context, state) => NoTransitionPage(child: MenuScreen()), path: '/menu-screen', name: 'menuScreen', + builder: (context, state) => MenuScreen(), ), ], ), diff --git a/lib/features/diary/models/diary_day_model.dart b/lib/features/diary/models/diary_day_model.dart new file mode 100644 index 00000000..773920dc --- /dev/null +++ b/lib/features/diary/models/diary_day_model.dart @@ -0,0 +1,80 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'diary_day_model.freezed.dart'; + +part 'diary_day_model.g.dart'; + +@freezed +class DiaryDayWrapperModel with _$DiaryDayWrapperModel { + const factory DiaryDayWrapperModel({ + @JsonKey(name: "diary") required DiaryDayModel diary, + }) = _DiaryDayWrapperModel; + + factory DiaryDayWrapperModel.fromJson(Map json) => _$DiaryDayWrapperModelFromJson(json); +} + +@freezed +class DiaryDayModel with _$DiaryDayModel { + const factory DiaryDayModel({ + @JsonKey(name: "id") required int id, + @JsonKey(name: "date") required String date, + @JsonKey(name: "wakeup") String? wakeup, + @JsonKey(name: "retire") String? retire, + @JsonKey(name: "closed") required int closed, + @JsonKey(name: "comment") required String comment, + @JsonKey(name: "state") required TypeOfDiaryModel typeOfDiary, + @JsonKey(name: "meals") required List meals, + }) = _DiaryDayModel; + + factory DiaryDayModel.fromJson(Map json) => _$DiaryDayModelFromJson(json); +} + +@freezed +class MealModel with _$MealModel { + const factory MealModel({ + @JsonKey(name: "id") required int id, + @JsonKey(name: "time") required String time, + @JsonKey(name: "type") required int type, + @JsonKey(name: "satiety") required int satiety, + @JsonKey(name: "mood") required int mood, + @JsonKey(name: "portions") required List portions, + @JsonKey(name: "photos") required List photos, + }) = _MealModel; + + factory MealModel.fromJson(Map json) => _$MealModelFromJson(json); +} + +@freezed +class DiaryPhotoModel with _$DiaryPhotoModel { + const factory DiaryPhotoModel({ + @JsonKey(name: "id") required String id, + @JsonKey(name: "original_name") required String originalName, + @JsonKey(name: "path") required String path, + @JsonKey(name: "size") required String size, + }) = _DiaryPhotoModel; + + factory DiaryPhotoModel.fromJson(Map json) => _$DiaryPhotoModelFromJson(json); +} + +@freezed +class Portion with _$Portion { + const factory Portion({ + @JsonKey(name: "id") required int id, + @JsonKey(name: "product_name") required String productName, + @JsonKey(name: "quantity") required int quantity, + @JsonKey(name: "portion") required String portion, + @JsonKey(name: "from_diet") required bool fromDiet, + }) = _Portion; + + factory Portion.fromJson(Map json) => _$PortionFromJson(json); +} + +@freezed +class TypeOfDiaryModel with _$TypeOfDiaryModel { + const factory TypeOfDiaryModel({ + @JsonKey(name: "has_chosen_diet") required bool hasChosenDiet, + @JsonKey(name: "has_chosen_plan") required bool hasChosenPlan, + }) = _TypeOfDiaryModel; + + factory TypeOfDiaryModel.fromJson(Map json) => _$TypeOfDiaryModelFromJson(json); +} diff --git a/lib/features/diary/models/diary_day_model.freezed.dart b/lib/features/diary/models/diary_day_model.freezed.dart new file mode 100644 index 00000000..dc780145 --- /dev/null +++ b/lib/features/diary/models/diary_day_model.freezed.dart @@ -0,0 +1,1504 @@ +// 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 'diary_day_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(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'); + +DiaryDayWrapperModel _$DiaryDayWrapperModelFromJson(Map json) { + return _DiaryDayWrapperModel.fromJson(json); +} + +/// @nodoc +mixin _$DiaryDayWrapperModel { + @JsonKey(name: "diary") + DiaryDayModel get diary => throw _privateConstructorUsedError; + + /// Serializes this DiaryDayWrapperModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of DiaryDayWrapperModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DiaryDayWrapperModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DiaryDayWrapperModelCopyWith<$Res> { + factory $DiaryDayWrapperModelCopyWith(DiaryDayWrapperModel value, + $Res Function(DiaryDayWrapperModel) then) = + _$DiaryDayWrapperModelCopyWithImpl<$Res, DiaryDayWrapperModel>; + @useResult + $Res call({@JsonKey(name: "diary") DiaryDayModel diary}); + + $DiaryDayModelCopyWith<$Res> get diary; +} + +/// @nodoc +class _$DiaryDayWrapperModelCopyWithImpl<$Res, + $Val extends DiaryDayWrapperModel> + implements $DiaryDayWrapperModelCopyWith<$Res> { + _$DiaryDayWrapperModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of DiaryDayWrapperModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? diary = null, + }) { + return _then(_value.copyWith( + diary: null == diary + ? _value.diary + : diary // ignore: cast_nullable_to_non_nullable + as DiaryDayModel, + ) as $Val); + } + + /// Create a copy of DiaryDayWrapperModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $DiaryDayModelCopyWith<$Res> get diary { + return $DiaryDayModelCopyWith<$Res>(_value.diary, (value) { + return _then(_value.copyWith(diary: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$DiaryDayWrapperModelImplCopyWith<$Res> + implements $DiaryDayWrapperModelCopyWith<$Res> { + factory _$$DiaryDayWrapperModelImplCopyWith(_$DiaryDayWrapperModelImpl value, + $Res Function(_$DiaryDayWrapperModelImpl) then) = + __$$DiaryDayWrapperModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({@JsonKey(name: "diary") DiaryDayModel diary}); + + @override + $DiaryDayModelCopyWith<$Res> get diary; +} + +/// @nodoc +class __$$DiaryDayWrapperModelImplCopyWithImpl<$Res> + extends _$DiaryDayWrapperModelCopyWithImpl<$Res, _$DiaryDayWrapperModelImpl> + implements _$$DiaryDayWrapperModelImplCopyWith<$Res> { + __$$DiaryDayWrapperModelImplCopyWithImpl(_$DiaryDayWrapperModelImpl _value, + $Res Function(_$DiaryDayWrapperModelImpl) _then) + : super(_value, _then); + + /// Create a copy of DiaryDayWrapperModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? diary = null, + }) { + return _then(_$DiaryDayWrapperModelImpl( + diary: null == diary + ? _value.diary + : diary // ignore: cast_nullable_to_non_nullable + as DiaryDayModel, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DiaryDayWrapperModelImpl implements _DiaryDayWrapperModel { + const _$DiaryDayWrapperModelImpl( + {@JsonKey(name: "diary") required this.diary}); + + factory _$DiaryDayWrapperModelImpl.fromJson(Map json) => + _$$DiaryDayWrapperModelImplFromJson(json); + + @override + @JsonKey(name: "diary") + final DiaryDayModel diary; + + @override + String toString() { + return 'DiaryDayWrapperModel(diary: $diary)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DiaryDayWrapperModelImpl && + (identical(other.diary, diary) || other.diary == diary)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, diary); + + /// Create a copy of DiaryDayWrapperModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DiaryDayWrapperModelImplCopyWith<_$DiaryDayWrapperModelImpl> + get copyWith => + __$$DiaryDayWrapperModelImplCopyWithImpl<_$DiaryDayWrapperModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$DiaryDayWrapperModelImplToJson( + this, + ); + } +} + +abstract class _DiaryDayWrapperModel implements DiaryDayWrapperModel { + const factory _DiaryDayWrapperModel( + {@JsonKey(name: "diary") required final DiaryDayModel diary}) = + _$DiaryDayWrapperModelImpl; + + factory _DiaryDayWrapperModel.fromJson(Map json) = + _$DiaryDayWrapperModelImpl.fromJson; + + @override + @JsonKey(name: "diary") + DiaryDayModel get diary; + + /// Create a copy of DiaryDayWrapperModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DiaryDayWrapperModelImplCopyWith<_$DiaryDayWrapperModelImpl> + get copyWith => throw _privateConstructorUsedError; +} + +DiaryDayModel _$DiaryDayModelFromJson(Map json) { + return _DiaryDayModel.fromJson(json); +} + +/// @nodoc +mixin _$DiaryDayModel { + @JsonKey(name: "id") + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "date") + String get date => throw _privateConstructorUsedError; + @JsonKey(name: "wakeup") + String? get wakeup => throw _privateConstructorUsedError; + @JsonKey(name: "retire") + String? get retire => throw _privateConstructorUsedError; + @JsonKey(name: "closed") + int get closed => throw _privateConstructorUsedError; + @JsonKey(name: "comment") + String get comment => throw _privateConstructorUsedError; + @JsonKey(name: "state") + TypeOfDiaryModel get typeOfDiary => throw _privateConstructorUsedError; + @JsonKey(name: "meals") + List get meals => throw _privateConstructorUsedError; + + /// Serializes this DiaryDayModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of DiaryDayModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DiaryDayModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DiaryDayModelCopyWith<$Res> { + factory $DiaryDayModelCopyWith( + DiaryDayModel value, $Res Function(DiaryDayModel) then) = + _$DiaryDayModelCopyWithImpl<$Res, DiaryDayModel>; + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "date") String date, + @JsonKey(name: "wakeup") String? wakeup, + @JsonKey(name: "retire") String? retire, + @JsonKey(name: "closed") int closed, + @JsonKey(name: "comment") String comment, + @JsonKey(name: "state") TypeOfDiaryModel typeOfDiary, + @JsonKey(name: "meals") List meals}); + + $TypeOfDiaryModelCopyWith<$Res> get typeOfDiary; +} + +/// @nodoc +class _$DiaryDayModelCopyWithImpl<$Res, $Val extends DiaryDayModel> + implements $DiaryDayModelCopyWith<$Res> { + _$DiaryDayModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of DiaryDayModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? date = null, + Object? wakeup = freezed, + Object? retire = freezed, + Object? closed = null, + Object? comment = null, + Object? typeOfDiary = null, + Object? meals = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as String, + wakeup: freezed == wakeup + ? _value.wakeup + : wakeup // ignore: cast_nullable_to_non_nullable + as String?, + retire: freezed == retire + ? _value.retire + : retire // ignore: cast_nullable_to_non_nullable + as String?, + closed: null == closed + ? _value.closed + : closed // ignore: cast_nullable_to_non_nullable + as int, + comment: null == comment + ? _value.comment + : comment // ignore: cast_nullable_to_non_nullable + as String, + typeOfDiary: null == typeOfDiary + ? _value.typeOfDiary + : typeOfDiary // ignore: cast_nullable_to_non_nullable + as TypeOfDiaryModel, + meals: null == meals + ? _value.meals + : meals // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } + + /// Create a copy of DiaryDayModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $TypeOfDiaryModelCopyWith<$Res> get typeOfDiary { + return $TypeOfDiaryModelCopyWith<$Res>(_value.typeOfDiary, (value) { + return _then(_value.copyWith(typeOfDiary: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$DiaryDayModelImplCopyWith<$Res> + implements $DiaryDayModelCopyWith<$Res> { + factory _$$DiaryDayModelImplCopyWith( + _$DiaryDayModelImpl value, $Res Function(_$DiaryDayModelImpl) then) = + __$$DiaryDayModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "date") String date, + @JsonKey(name: "wakeup") String? wakeup, + @JsonKey(name: "retire") String? retire, + @JsonKey(name: "closed") int closed, + @JsonKey(name: "comment") String comment, + @JsonKey(name: "state") TypeOfDiaryModel typeOfDiary, + @JsonKey(name: "meals") List meals}); + + @override + $TypeOfDiaryModelCopyWith<$Res> get typeOfDiary; +} + +/// @nodoc +class __$$DiaryDayModelImplCopyWithImpl<$Res> + extends _$DiaryDayModelCopyWithImpl<$Res, _$DiaryDayModelImpl> + implements _$$DiaryDayModelImplCopyWith<$Res> { + __$$DiaryDayModelImplCopyWithImpl( + _$DiaryDayModelImpl _value, $Res Function(_$DiaryDayModelImpl) _then) + : super(_value, _then); + + /// Create a copy of DiaryDayModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? date = null, + Object? wakeup = freezed, + Object? retire = freezed, + Object? closed = null, + Object? comment = null, + Object? typeOfDiary = null, + Object? meals = null, + }) { + return _then(_$DiaryDayModelImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as String, + wakeup: freezed == wakeup + ? _value.wakeup + : wakeup // ignore: cast_nullable_to_non_nullable + as String?, + retire: freezed == retire + ? _value.retire + : retire // ignore: cast_nullable_to_non_nullable + as String?, + closed: null == closed + ? _value.closed + : closed // ignore: cast_nullable_to_non_nullable + as int, + comment: null == comment + ? _value.comment + : comment // ignore: cast_nullable_to_non_nullable + as String, + typeOfDiary: null == typeOfDiary + ? _value.typeOfDiary + : typeOfDiary // ignore: cast_nullable_to_non_nullable + as TypeOfDiaryModel, + meals: null == meals + ? _value._meals + : meals // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DiaryDayModelImpl implements _DiaryDayModel { + const _$DiaryDayModelImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "date") required this.date, + @JsonKey(name: "wakeup") this.wakeup, + @JsonKey(name: "retire") this.retire, + @JsonKey(name: "closed") required this.closed, + @JsonKey(name: "comment") required this.comment, + @JsonKey(name: "state") required this.typeOfDiary, + @JsonKey(name: "meals") required final List meals}) + : _meals = meals; + + factory _$DiaryDayModelImpl.fromJson(Map json) => + _$$DiaryDayModelImplFromJson(json); + + @override + @JsonKey(name: "id") + final int id; + @override + @JsonKey(name: "date") + final String date; + @override + @JsonKey(name: "wakeup") + final String? wakeup; + @override + @JsonKey(name: "retire") + final String? retire; + @override + @JsonKey(name: "closed") + final int closed; + @override + @JsonKey(name: "comment") + final String comment; + @override + @JsonKey(name: "state") + final TypeOfDiaryModel typeOfDiary; + final List _meals; + @override + @JsonKey(name: "meals") + List get meals { + if (_meals is EqualUnmodifiableListView) return _meals; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_meals); + } + + @override + String toString() { + return 'DiaryDayModel(id: $id, date: $date, wakeup: $wakeup, retire: $retire, closed: $closed, comment: $comment, typeOfDiary: $typeOfDiary, meals: $meals)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DiaryDayModelImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.date, date) || other.date == date) && + (identical(other.wakeup, wakeup) || other.wakeup == wakeup) && + (identical(other.retire, retire) || other.retire == retire) && + (identical(other.closed, closed) || other.closed == closed) && + (identical(other.comment, comment) || other.comment == comment) && + (identical(other.typeOfDiary, typeOfDiary) || + other.typeOfDiary == typeOfDiary) && + const DeepCollectionEquality().equals(other._meals, _meals)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, id, date, wakeup, retire, closed, + comment, typeOfDiary, const DeepCollectionEquality().hash(_meals)); + + /// Create a copy of DiaryDayModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DiaryDayModelImplCopyWith<_$DiaryDayModelImpl> get copyWith => + __$$DiaryDayModelImplCopyWithImpl<_$DiaryDayModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$DiaryDayModelImplToJson( + this, + ); + } +} + +abstract class _DiaryDayModel implements DiaryDayModel { + const factory _DiaryDayModel( + {@JsonKey(name: "id") required final int id, + @JsonKey(name: "date") required final String date, + @JsonKey(name: "wakeup") final String? wakeup, + @JsonKey(name: "retire") final String? retire, + @JsonKey(name: "closed") required final int closed, + @JsonKey(name: "comment") required final String comment, + @JsonKey(name: "state") required final TypeOfDiaryModel typeOfDiary, + @JsonKey(name: "meals") required final List meals}) = + _$DiaryDayModelImpl; + + factory _DiaryDayModel.fromJson(Map json) = + _$DiaryDayModelImpl.fromJson; + + @override + @JsonKey(name: "id") + int get id; + @override + @JsonKey(name: "date") + String get date; + @override + @JsonKey(name: "wakeup") + String? get wakeup; + @override + @JsonKey(name: "retire") + String? get retire; + @override + @JsonKey(name: "closed") + int get closed; + @override + @JsonKey(name: "comment") + String get comment; + @override + @JsonKey(name: "state") + TypeOfDiaryModel get typeOfDiary; + @override + @JsonKey(name: "meals") + List get meals; + + /// Create a copy of DiaryDayModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DiaryDayModelImplCopyWith<_$DiaryDayModelImpl> get copyWith => + throw _privateConstructorUsedError; +} + +MealModel _$MealModelFromJson(Map json) { + return _MealModel.fromJson(json); +} + +/// @nodoc +mixin _$MealModel { + @JsonKey(name: "id") + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "time") + String get time => throw _privateConstructorUsedError; + @JsonKey(name: "type") + int get type => throw _privateConstructorUsedError; + @JsonKey(name: "satiety") + int get satiety => throw _privateConstructorUsedError; + @JsonKey(name: "mood") + int get mood => throw _privateConstructorUsedError; + @JsonKey(name: "portions") + List get portions => throw _privateConstructorUsedError; + @JsonKey(name: "photos") + List get photos => throw _privateConstructorUsedError; + + /// Serializes this MealModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of MealModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $MealModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MealModelCopyWith<$Res> { + factory $MealModelCopyWith(MealModel value, $Res Function(MealModel) then) = + _$MealModelCopyWithImpl<$Res, MealModel>; + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "time") String time, + @JsonKey(name: "type") int type, + @JsonKey(name: "satiety") int satiety, + @JsonKey(name: "mood") int mood, + @JsonKey(name: "portions") List portions, + @JsonKey(name: "photos") List photos}); +} + +/// @nodoc +class _$MealModelCopyWithImpl<$Res, $Val extends MealModel> + implements $MealModelCopyWith<$Res> { + _$MealModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of MealModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? time = null, + Object? type = null, + Object? satiety = null, + Object? mood = null, + Object? portions = null, + Object? photos = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as int, + satiety: null == satiety + ? _value.satiety + : satiety // ignore: cast_nullable_to_non_nullable + as int, + mood: null == mood + ? _value.mood + : mood // ignore: cast_nullable_to_non_nullable + as int, + portions: null == portions + ? _value.portions + : portions // ignore: cast_nullable_to_non_nullable + as List, + photos: null == photos + ? _value.photos + : photos // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MealModelImplCopyWith<$Res> + implements $MealModelCopyWith<$Res> { + factory _$$MealModelImplCopyWith( + _$MealModelImpl value, $Res Function(_$MealModelImpl) then) = + __$$MealModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "time") String time, + @JsonKey(name: "type") int type, + @JsonKey(name: "satiety") int satiety, + @JsonKey(name: "mood") int mood, + @JsonKey(name: "portions") List portions, + @JsonKey(name: "photos") List photos}); +} + +/// @nodoc +class __$$MealModelImplCopyWithImpl<$Res> + extends _$MealModelCopyWithImpl<$Res, _$MealModelImpl> + implements _$$MealModelImplCopyWith<$Res> { + __$$MealModelImplCopyWithImpl( + _$MealModelImpl _value, $Res Function(_$MealModelImpl) _then) + : super(_value, _then); + + /// Create a copy of MealModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? time = null, + Object? type = null, + Object? satiety = null, + Object? mood = null, + Object? portions = null, + Object? photos = null, + }) { + return _then(_$MealModelImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as int, + satiety: null == satiety + ? _value.satiety + : satiety // ignore: cast_nullable_to_non_nullable + as int, + mood: null == mood + ? _value.mood + : mood // ignore: cast_nullable_to_non_nullable + as int, + portions: null == portions + ? _value._portions + : portions // ignore: cast_nullable_to_non_nullable + as List, + photos: null == photos + ? _value._photos + : photos // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MealModelImpl implements _MealModel { + const _$MealModelImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "time") required this.time, + @JsonKey(name: "type") required this.type, + @JsonKey(name: "satiety") required this.satiety, + @JsonKey(name: "mood") required this.mood, + @JsonKey(name: "portions") required final List portions, + @JsonKey(name: "photos") required final List photos}) + : _portions = portions, + _photos = photos; + + factory _$MealModelImpl.fromJson(Map json) => + _$$MealModelImplFromJson(json); + + @override + @JsonKey(name: "id") + final int id; + @override + @JsonKey(name: "time") + final String time; + @override + @JsonKey(name: "type") + final int type; + @override + @JsonKey(name: "satiety") + final int satiety; + @override + @JsonKey(name: "mood") + final int mood; + final List _portions; + @override + @JsonKey(name: "portions") + List get portions { + if (_portions is EqualUnmodifiableListView) return _portions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_portions); + } + + final List _photos; + @override + @JsonKey(name: "photos") + List get photos { + if (_photos is EqualUnmodifiableListView) return _photos; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_photos); + } + + @override + String toString() { + return 'MealModel(id: $id, time: $time, type: $type, satiety: $satiety, mood: $mood, portions: $portions, photos: $photos)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MealModelImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.time, time) || other.time == time) && + (identical(other.type, type) || other.type == type) && + (identical(other.satiety, satiety) || other.satiety == satiety) && + (identical(other.mood, mood) || other.mood == mood) && + const DeepCollectionEquality().equals(other._portions, _portions) && + const DeepCollectionEquality().equals(other._photos, _photos)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + id, + time, + type, + satiety, + mood, + const DeepCollectionEquality().hash(_portions), + const DeepCollectionEquality().hash(_photos)); + + /// Create a copy of MealModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$MealModelImplCopyWith<_$MealModelImpl> get copyWith => + __$$MealModelImplCopyWithImpl<_$MealModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$MealModelImplToJson( + this, + ); + } +} + +abstract class _MealModel implements MealModel { + const factory _MealModel( + {@JsonKey(name: "id") required final int id, + @JsonKey(name: "time") required final String time, + @JsonKey(name: "type") required final int type, + @JsonKey(name: "satiety") required final int satiety, + @JsonKey(name: "mood") required final int mood, + @JsonKey(name: "portions") required final List portions, + @JsonKey(name: "photos") + required final List photos}) = _$MealModelImpl; + + factory _MealModel.fromJson(Map json) = + _$MealModelImpl.fromJson; + + @override + @JsonKey(name: "id") + int get id; + @override + @JsonKey(name: "time") + String get time; + @override + @JsonKey(name: "type") + int get type; + @override + @JsonKey(name: "satiety") + int get satiety; + @override + @JsonKey(name: "mood") + int get mood; + @override + @JsonKey(name: "portions") + List get portions; + @override + @JsonKey(name: "photos") + List get photos; + + /// Create a copy of MealModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$MealModelImplCopyWith<_$MealModelImpl> get copyWith => + throw _privateConstructorUsedError; +} + +DiaryPhotoModel _$DiaryPhotoModelFromJson(Map json) { + return _DiaryPhotoModel.fromJson(json); +} + +/// @nodoc +mixin _$DiaryPhotoModel { + @JsonKey(name: "id") + String get id => throw _privateConstructorUsedError; + @JsonKey(name: "original_name") + String get originalName => throw _privateConstructorUsedError; + @JsonKey(name: "path") + String get path => throw _privateConstructorUsedError; + @JsonKey(name: "size") + String get size => throw _privateConstructorUsedError; + + /// Serializes this DiaryPhotoModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of DiaryPhotoModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DiaryPhotoModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DiaryPhotoModelCopyWith<$Res> { + factory $DiaryPhotoModelCopyWith( + DiaryPhotoModel value, $Res Function(DiaryPhotoModel) then) = + _$DiaryPhotoModelCopyWithImpl<$Res, DiaryPhotoModel>; + @useResult + $Res call( + {@JsonKey(name: "id") String id, + @JsonKey(name: "original_name") String originalName, + @JsonKey(name: "path") String path, + @JsonKey(name: "size") String size}); +} + +/// @nodoc +class _$DiaryPhotoModelCopyWithImpl<$Res, $Val extends DiaryPhotoModel> + implements $DiaryPhotoModelCopyWith<$Res> { + _$DiaryPhotoModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of DiaryPhotoModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? originalName = null, + Object? path = null, + Object? size = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + originalName: null == originalName + ? _value.originalName + : originalName // ignore: cast_nullable_to_non_nullable + as String, + path: null == path + ? _value.path + : path // ignore: cast_nullable_to_non_nullable + as String, + size: null == size + ? _value.size + : size // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$DiaryPhotoModelImplCopyWith<$Res> + implements $DiaryPhotoModelCopyWith<$Res> { + factory _$$DiaryPhotoModelImplCopyWith(_$DiaryPhotoModelImpl value, + $Res Function(_$DiaryPhotoModelImpl) then) = + __$$DiaryPhotoModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") String id, + @JsonKey(name: "original_name") String originalName, + @JsonKey(name: "path") String path, + @JsonKey(name: "size") String size}); +} + +/// @nodoc +class __$$DiaryPhotoModelImplCopyWithImpl<$Res> + extends _$DiaryPhotoModelCopyWithImpl<$Res, _$DiaryPhotoModelImpl> + implements _$$DiaryPhotoModelImplCopyWith<$Res> { + __$$DiaryPhotoModelImplCopyWithImpl( + _$DiaryPhotoModelImpl _value, $Res Function(_$DiaryPhotoModelImpl) _then) + : super(_value, _then); + + /// Create a copy of DiaryPhotoModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? originalName = null, + Object? path = null, + Object? size = null, + }) { + return _then(_$DiaryPhotoModelImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + originalName: null == originalName + ? _value.originalName + : originalName // ignore: cast_nullable_to_non_nullable + as String, + path: null == path + ? _value.path + : path // ignore: cast_nullable_to_non_nullable + as String, + size: null == size + ? _value.size + : size // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DiaryPhotoModelImpl implements _DiaryPhotoModel { + const _$DiaryPhotoModelImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "original_name") required this.originalName, + @JsonKey(name: "path") required this.path, + @JsonKey(name: "size") required this.size}); + + factory _$DiaryPhotoModelImpl.fromJson(Map json) => + _$$DiaryPhotoModelImplFromJson(json); + + @override + @JsonKey(name: "id") + final String id; + @override + @JsonKey(name: "original_name") + final String originalName; + @override + @JsonKey(name: "path") + final String path; + @override + @JsonKey(name: "size") + final String size; + + @override + String toString() { + return 'DiaryPhotoModel(id: $id, originalName: $originalName, path: $path, size: $size)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DiaryPhotoModelImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.originalName, originalName) || + other.originalName == originalName) && + (identical(other.path, path) || other.path == path) && + (identical(other.size, size) || other.size == size)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, id, originalName, path, size); + + /// Create a copy of DiaryPhotoModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DiaryPhotoModelImplCopyWith<_$DiaryPhotoModelImpl> get copyWith => + __$$DiaryPhotoModelImplCopyWithImpl<_$DiaryPhotoModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$DiaryPhotoModelImplToJson( + this, + ); + } +} + +abstract class _DiaryPhotoModel implements DiaryPhotoModel { + const factory _DiaryPhotoModel( + {@JsonKey(name: "id") required final String id, + @JsonKey(name: "original_name") required final String originalName, + @JsonKey(name: "path") required final String path, + @JsonKey(name: "size") required final String size}) = + _$DiaryPhotoModelImpl; + + factory _DiaryPhotoModel.fromJson(Map json) = + _$DiaryPhotoModelImpl.fromJson; + + @override + @JsonKey(name: "id") + String get id; + @override + @JsonKey(name: "original_name") + String get originalName; + @override + @JsonKey(name: "path") + String get path; + @override + @JsonKey(name: "size") + String get size; + + /// Create a copy of DiaryPhotoModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DiaryPhotoModelImplCopyWith<_$DiaryPhotoModelImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Portion _$PortionFromJson(Map json) { + return _Portion.fromJson(json); +} + +/// @nodoc +mixin _$Portion { + @JsonKey(name: "id") + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "product_name") + String get productName => throw _privateConstructorUsedError; + @JsonKey(name: "quantity") + int get quantity => throw _privateConstructorUsedError; + @JsonKey(name: "portion") + String get portion => throw _privateConstructorUsedError; + @JsonKey(name: "from_diet") + bool get fromDiet => throw _privateConstructorUsedError; + + /// Serializes this Portion to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Portion + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PortionCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PortionCopyWith<$Res> { + factory $PortionCopyWith(Portion value, $Res Function(Portion) then) = + _$PortionCopyWithImpl<$Res, Portion>; + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "product_name") String productName, + @JsonKey(name: "quantity") int quantity, + @JsonKey(name: "portion") String portion, + @JsonKey(name: "from_diet") bool fromDiet}); +} + +/// @nodoc +class _$PortionCopyWithImpl<$Res, $Val extends Portion> + implements $PortionCopyWith<$Res> { + _$PortionCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Portion + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? productName = null, + Object? quantity = null, + Object? portion = null, + Object? fromDiet = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + productName: null == productName + ? _value.productName + : productName // ignore: cast_nullable_to_non_nullable + as String, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + portion: null == portion + ? _value.portion + : portion // ignore: cast_nullable_to_non_nullable + as String, + fromDiet: null == fromDiet + ? _value.fromDiet + : fromDiet // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$PortionImplCopyWith<$Res> implements $PortionCopyWith<$Res> { + factory _$$PortionImplCopyWith( + _$PortionImpl value, $Res Function(_$PortionImpl) then) = + __$$PortionImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "product_name") String productName, + @JsonKey(name: "quantity") int quantity, + @JsonKey(name: "portion") String portion, + @JsonKey(name: "from_diet") bool fromDiet}); +} + +/// @nodoc +class __$$PortionImplCopyWithImpl<$Res> + extends _$PortionCopyWithImpl<$Res, _$PortionImpl> + implements _$$PortionImplCopyWith<$Res> { + __$$PortionImplCopyWithImpl( + _$PortionImpl _value, $Res Function(_$PortionImpl) _then) + : super(_value, _then); + + /// Create a copy of Portion + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? productName = null, + Object? quantity = null, + Object? portion = null, + Object? fromDiet = null, + }) { + return _then(_$PortionImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + productName: null == productName + ? _value.productName + : productName // ignore: cast_nullable_to_non_nullable + as String, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + portion: null == portion + ? _value.portion + : portion // ignore: cast_nullable_to_non_nullable + as String, + fromDiet: null == fromDiet + ? _value.fromDiet + : fromDiet // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PortionImpl implements _Portion { + const _$PortionImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "product_name") required this.productName, + @JsonKey(name: "quantity") required this.quantity, + @JsonKey(name: "portion") required this.portion, + @JsonKey(name: "from_diet") required this.fromDiet}); + + factory _$PortionImpl.fromJson(Map json) => + _$$PortionImplFromJson(json); + + @override + @JsonKey(name: "id") + final int id; + @override + @JsonKey(name: "product_name") + final String productName; + @override + @JsonKey(name: "quantity") + final int quantity; + @override + @JsonKey(name: "portion") + final String portion; + @override + @JsonKey(name: "from_diet") + final bool fromDiet; + + @override + String toString() { + return 'Portion(id: $id, productName: $productName, quantity: $quantity, portion: $portion, fromDiet: $fromDiet)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PortionImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.productName, productName) || + other.productName == productName) && + (identical(other.quantity, quantity) || + other.quantity == quantity) && + (identical(other.portion, portion) || other.portion == portion) && + (identical(other.fromDiet, fromDiet) || + other.fromDiet == fromDiet)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, id, productName, quantity, portion, fromDiet); + + /// Create a copy of Portion + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PortionImplCopyWith<_$PortionImpl> get copyWith => + __$$PortionImplCopyWithImpl<_$PortionImpl>(this, _$identity); + + @override + Map toJson() { + return _$$PortionImplToJson( + this, + ); + } +} + +abstract class _Portion implements Portion { + const factory _Portion( + {@JsonKey(name: "id") required final int id, + @JsonKey(name: "product_name") required final String productName, + @JsonKey(name: "quantity") required final int quantity, + @JsonKey(name: "portion") required final String portion, + @JsonKey(name: "from_diet") required final bool fromDiet}) = + _$PortionImpl; + + factory _Portion.fromJson(Map json) = _$PortionImpl.fromJson; + + @override + @JsonKey(name: "id") + int get id; + @override + @JsonKey(name: "product_name") + String get productName; + @override + @JsonKey(name: "quantity") + int get quantity; + @override + @JsonKey(name: "portion") + String get portion; + @override + @JsonKey(name: "from_diet") + bool get fromDiet; + + /// Create a copy of Portion + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PortionImplCopyWith<_$PortionImpl> get copyWith => + throw _privateConstructorUsedError; +} + +TypeOfDiaryModel _$TypeOfDiaryModelFromJson(Map json) { + return _TypeOfDiaryModel.fromJson(json); +} + +/// @nodoc +mixin _$TypeOfDiaryModel { + @JsonKey(name: "has_chosen_diet") + bool get hasChosenDiet => throw _privateConstructorUsedError; + @JsonKey(name: "has_chosen_plan") + bool get hasChosenPlan => throw _privateConstructorUsedError; + + /// Serializes this TypeOfDiaryModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of TypeOfDiaryModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $TypeOfDiaryModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TypeOfDiaryModelCopyWith<$Res> { + factory $TypeOfDiaryModelCopyWith( + TypeOfDiaryModel value, $Res Function(TypeOfDiaryModel) then) = + _$TypeOfDiaryModelCopyWithImpl<$Res, TypeOfDiaryModel>; + @useResult + $Res call( + {@JsonKey(name: "has_chosen_diet") bool hasChosenDiet, + @JsonKey(name: "has_chosen_plan") bool hasChosenPlan}); +} + +/// @nodoc +class _$TypeOfDiaryModelCopyWithImpl<$Res, $Val extends TypeOfDiaryModel> + implements $TypeOfDiaryModelCopyWith<$Res> { + _$TypeOfDiaryModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of TypeOfDiaryModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? hasChosenDiet = null, + Object? hasChosenPlan = null, + }) { + return _then(_value.copyWith( + hasChosenDiet: null == hasChosenDiet + ? _value.hasChosenDiet + : hasChosenDiet // ignore: cast_nullable_to_non_nullable + as bool, + hasChosenPlan: null == hasChosenPlan + ? _value.hasChosenPlan + : hasChosenPlan // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$TypeOfDiaryModelImplCopyWith<$Res> + implements $TypeOfDiaryModelCopyWith<$Res> { + factory _$$TypeOfDiaryModelImplCopyWith(_$TypeOfDiaryModelImpl value, + $Res Function(_$TypeOfDiaryModelImpl) then) = + __$$TypeOfDiaryModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "has_chosen_diet") bool hasChosenDiet, + @JsonKey(name: "has_chosen_plan") bool hasChosenPlan}); +} + +/// @nodoc +class __$$TypeOfDiaryModelImplCopyWithImpl<$Res> + extends _$TypeOfDiaryModelCopyWithImpl<$Res, _$TypeOfDiaryModelImpl> + implements _$$TypeOfDiaryModelImplCopyWith<$Res> { + __$$TypeOfDiaryModelImplCopyWithImpl(_$TypeOfDiaryModelImpl _value, + $Res Function(_$TypeOfDiaryModelImpl) _then) + : super(_value, _then); + + /// Create a copy of TypeOfDiaryModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? hasChosenDiet = null, + Object? hasChosenPlan = null, + }) { + return _then(_$TypeOfDiaryModelImpl( + hasChosenDiet: null == hasChosenDiet + ? _value.hasChosenDiet + : hasChosenDiet // ignore: cast_nullable_to_non_nullable + as bool, + hasChosenPlan: null == hasChosenPlan + ? _value.hasChosenPlan + : hasChosenPlan // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$TypeOfDiaryModelImpl implements _TypeOfDiaryModel { + const _$TypeOfDiaryModelImpl( + {@JsonKey(name: "has_chosen_diet") required this.hasChosenDiet, + @JsonKey(name: "has_chosen_plan") required this.hasChosenPlan}); + + factory _$TypeOfDiaryModelImpl.fromJson(Map json) => + _$$TypeOfDiaryModelImplFromJson(json); + + @override + @JsonKey(name: "has_chosen_diet") + final bool hasChosenDiet; + @override + @JsonKey(name: "has_chosen_plan") + final bool hasChosenPlan; + + @override + String toString() { + return 'TypeOfDiaryModel(hasChosenDiet: $hasChosenDiet, hasChosenPlan: $hasChosenPlan)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$TypeOfDiaryModelImpl && + (identical(other.hasChosenDiet, hasChosenDiet) || + other.hasChosenDiet == hasChosenDiet) && + (identical(other.hasChosenPlan, hasChosenPlan) || + other.hasChosenPlan == hasChosenPlan)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, hasChosenDiet, hasChosenPlan); + + /// Create a copy of TypeOfDiaryModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$TypeOfDiaryModelImplCopyWith<_$TypeOfDiaryModelImpl> get copyWith => + __$$TypeOfDiaryModelImplCopyWithImpl<_$TypeOfDiaryModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$TypeOfDiaryModelImplToJson( + this, + ); + } +} + +abstract class _TypeOfDiaryModel implements TypeOfDiaryModel { + const factory _TypeOfDiaryModel( + {@JsonKey(name: "has_chosen_diet") required final bool hasChosenDiet, + @JsonKey(name: "has_chosen_plan") + required final bool hasChosenPlan}) = _$TypeOfDiaryModelImpl; + + factory _TypeOfDiaryModel.fromJson(Map json) = + _$TypeOfDiaryModelImpl.fromJson; + + @override + @JsonKey(name: "has_chosen_diet") + bool get hasChosenDiet; + @override + @JsonKey(name: "has_chosen_plan") + bool get hasChosenPlan; + + /// Create a copy of TypeOfDiaryModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$TypeOfDiaryModelImplCopyWith<_$TypeOfDiaryModelImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/diary/models/diary_day_model.g.dart b/lib/features/diary/models/diary_day_model.g.dart new file mode 100644 index 00000000..05d36efa --- /dev/null +++ b/lib/features/diary/models/diary_day_model.g.dart @@ -0,0 +1,122 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'diary_day_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$DiaryDayWrapperModelImpl _$$DiaryDayWrapperModelImplFromJson( + Map json) => + _$DiaryDayWrapperModelImpl( + diary: DiaryDayModel.fromJson(json['diary'] as Map), + ); + +Map _$$DiaryDayWrapperModelImplToJson( + _$DiaryDayWrapperModelImpl instance) => + { + 'diary': instance.diary, + }; + +_$DiaryDayModelImpl _$$DiaryDayModelImplFromJson(Map json) => + _$DiaryDayModelImpl( + id: (json['id'] as num).toInt(), + date: json['date'] as String, + wakeup: json['wakeup'] as String?, + retire: json['retire'] as String?, + closed: (json['closed'] as num).toInt(), + comment: json['comment'] as String, + typeOfDiary: + TypeOfDiaryModel.fromJson(json['state'] as Map), + meals: (json['meals'] as List) + .map((e) => MealModel.fromJson(e as Map)) + .toList(), + ); + +Map _$$DiaryDayModelImplToJson(_$DiaryDayModelImpl instance) => + { + 'id': instance.id, + 'date': instance.date, + 'wakeup': instance.wakeup, + 'retire': instance.retire, + 'closed': instance.closed, + 'comment': instance.comment, + 'state': instance.typeOfDiary, + 'meals': instance.meals, + }; + +_$MealModelImpl _$$MealModelImplFromJson(Map json) => + _$MealModelImpl( + id: (json['id'] as num).toInt(), + time: json['time'] as String, + type: (json['type'] as num).toInt(), + satiety: (json['satiety'] as num).toInt(), + mood: (json['mood'] as num).toInt(), + portions: (json['portions'] as List) + .map((e) => Portion.fromJson(e as Map)) + .toList(), + photos: (json['photos'] as List) + .map((e) => DiaryPhotoModel.fromJson(e as Map)) + .toList(), + ); + +Map _$$MealModelImplToJson(_$MealModelImpl instance) => + { + 'id': instance.id, + 'time': instance.time, + 'type': instance.type, + 'satiety': instance.satiety, + 'mood': instance.mood, + 'portions': instance.portions, + 'photos': instance.photos, + }; + +_$DiaryPhotoModelImpl _$$DiaryPhotoModelImplFromJson( + Map json) => + _$DiaryPhotoModelImpl( + id: json['id'] as String, + originalName: json['original_name'] as String, + path: json['path'] as String, + size: json['size'] as String, + ); + +Map _$$DiaryPhotoModelImplToJson( + _$DiaryPhotoModelImpl instance) => + { + 'id': instance.id, + 'original_name': instance.originalName, + 'path': instance.path, + 'size': instance.size, + }; + +_$PortionImpl _$$PortionImplFromJson(Map json) => + _$PortionImpl( + id: (json['id'] as num).toInt(), + productName: json['product_name'] as String, + quantity: (json['quantity'] as num).toInt(), + portion: json['portion'] as String, + fromDiet: json['from_diet'] as bool, + ); + +Map _$$PortionImplToJson(_$PortionImpl instance) => + { + 'id': instance.id, + 'product_name': instance.productName, + 'quantity': instance.quantity, + 'portion': instance.portion, + 'from_diet': instance.fromDiet, + }; + +_$TypeOfDiaryModelImpl _$$TypeOfDiaryModelImplFromJson( + Map json) => + _$TypeOfDiaryModelImpl( + hasChosenDiet: json['has_chosen_diet'] as bool, + hasChosenPlan: json['has_chosen_plan'] as bool, + ); + +Map _$$TypeOfDiaryModelImplToJson( + _$TypeOfDiaryModelImpl instance) => + { + 'has_chosen_diet': instance.hasChosenDiet, + 'has_chosen_plan': instance.hasChosenPlan, + }; diff --git a/lib/features/diary/models/diary_index_model.dart b/lib/features/diary/models/diary_index_model.dart new file mode 100644 index 00000000..6b895e96 --- /dev/null +++ b/lib/features/diary/models/diary_index_model.dart @@ -0,0 +1,14 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'diary_index_model.freezed.dart'; + +part 'diary_index_model.g.dart'; + +@freezed +class DiaryIndexModel with _$DiaryIndexModel { + const factory DiaryIndexModel({ + required int id, + }) = _DiaryIndexModel; + + factory DiaryIndexModel.fromJson(Map json) => _$DiaryIndexModelFromJson(json); +} diff --git a/lib/features/diary/models/diary_index_model.freezed.dart b/lib/features/diary/models/diary_index_model.freezed.dart new file mode 100644 index 00000000..9b78696c --- /dev/null +++ b/lib/features/diary/models/diary_index_model.freezed.dart @@ -0,0 +1,166 @@ +// 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 'diary_index_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(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'); + +DiaryIndexModel _$DiaryIndexModelFromJson(Map json) { + return _DiaryIndexModel.fromJson(json); +} + +/// @nodoc +mixin _$DiaryIndexModel { + int get id => throw _privateConstructorUsedError; + + /// Serializes this DiaryIndexModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of DiaryIndexModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DiaryIndexModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DiaryIndexModelCopyWith<$Res> { + factory $DiaryIndexModelCopyWith( + DiaryIndexModel value, $Res Function(DiaryIndexModel) then) = + _$DiaryIndexModelCopyWithImpl<$Res, DiaryIndexModel>; + @useResult + $Res call({int id}); +} + +/// @nodoc +class _$DiaryIndexModelCopyWithImpl<$Res, $Val extends DiaryIndexModel> + implements $DiaryIndexModelCopyWith<$Res> { + _$DiaryIndexModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of DiaryIndexModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$DiaryIndexModelImplCopyWith<$Res> + implements $DiaryIndexModelCopyWith<$Res> { + factory _$$DiaryIndexModelImplCopyWith(_$DiaryIndexModelImpl value, + $Res Function(_$DiaryIndexModelImpl) then) = + __$$DiaryIndexModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({int id}); +} + +/// @nodoc +class __$$DiaryIndexModelImplCopyWithImpl<$Res> + extends _$DiaryIndexModelCopyWithImpl<$Res, _$DiaryIndexModelImpl> + implements _$$DiaryIndexModelImplCopyWith<$Res> { + __$$DiaryIndexModelImplCopyWithImpl( + _$DiaryIndexModelImpl _value, $Res Function(_$DiaryIndexModelImpl) _then) + : super(_value, _then); + + /// Create a copy of DiaryIndexModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + }) { + return _then(_$DiaryIndexModelImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DiaryIndexModelImpl implements _DiaryIndexModel { + const _$DiaryIndexModelImpl({required this.id}); + + factory _$DiaryIndexModelImpl.fromJson(Map json) => + _$$DiaryIndexModelImplFromJson(json); + + @override + final int id; + + @override + String toString() { + return 'DiaryIndexModel(id: $id)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DiaryIndexModelImpl && + (identical(other.id, id) || other.id == id)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, id); + + /// Create a copy of DiaryIndexModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DiaryIndexModelImplCopyWith<_$DiaryIndexModelImpl> get copyWith => + __$$DiaryIndexModelImplCopyWithImpl<_$DiaryIndexModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$DiaryIndexModelImplToJson( + this, + ); + } +} + +abstract class _DiaryIndexModel implements DiaryIndexModel { + const factory _DiaryIndexModel({required final int id}) = + _$DiaryIndexModelImpl; + + factory _DiaryIndexModel.fromJson(Map json) = + _$DiaryIndexModelImpl.fromJson; + + @override + int get id; + + /// Create a copy of DiaryIndexModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DiaryIndexModelImplCopyWith<_$DiaryIndexModelImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/diary/models/photo.g.dart b/lib/features/diary/models/diary_index_model.g.dart similarity index 50% rename from lib/features/diary/models/photo.g.dart rename to lib/features/diary/models/diary_index_model.g.dart index cacf65ac..268132fa 100644 --- a/lib/features/diary/models/photo.g.dart +++ b/lib/features/diary/models/diary_index_model.g.dart @@ -1,20 +1,19 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'photo.dart'; +part of 'diary_index_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -_$PhotoImpl _$$PhotoImplFromJson(Map json) => _$PhotoImpl( +_$DiaryIndexModelImpl _$$DiaryIndexModelImplFromJson( + Map json) => + _$DiaryIndexModelImpl( id: (json['id'] as num).toInt(), - originalName: json['original_name'] as String, - path: json['path'] as String, ); -Map _$$PhotoImplToJson(_$PhotoImpl instance) => +Map _$$DiaryIndexModelImplToJson( + _$DiaryIndexModelImpl instance) => { 'id': instance.id, - 'original_name': instance.originalName, - 'path': instance.path, }; diff --git a/lib/features/diary/models/diary_model.dart b/lib/features/diary/models/diary_model.dart deleted file mode 100644 index 8c152997..00000000 --- a/lib/features/diary/models/diary_model.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:eatvio_app/features/diary/models/state.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -import './meal.dart'; - -part 'diary_model.freezed.dart'; - -part 'diary_model.g.dart'; - -@freezed -class DiaryModel with _$DiaryModel { - const factory DiaryModel({ - required int id, - required DateTime date, - required int closed, - required List meals, - required State state, - String? comment, - DateTime? wakeup, - DateTime? retire, - }) = _DiaryModel; - - factory DiaryModel.fromJson(Map json) => _$DiaryModelFromJson(json); -} diff --git a/lib/features/diary/models/diary_model.freezed.dart b/lib/features/diary/models/diary_model.freezed.dart deleted file mode 100644 index ceabd5db..00000000 --- a/lib/features/diary/models/diary_model.freezed.dart +++ /dev/null @@ -1,339 +0,0 @@ -// 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 'diary_model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(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'); - -DiaryModel _$DiaryModelFromJson(Map json) { - return _DiaryModel.fromJson(json); -} - -/// @nodoc -mixin _$DiaryModel { - int get id => throw _privateConstructorUsedError; - DateTime get date => throw _privateConstructorUsedError; - int get closed => throw _privateConstructorUsedError; - List get meals => throw _privateConstructorUsedError; - State get state => throw _privateConstructorUsedError; - String? get comment => throw _privateConstructorUsedError; - DateTime? get wakeup => throw _privateConstructorUsedError; - DateTime? get retire => throw _privateConstructorUsedError; - - /// Serializes this DiaryModel to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $DiaryModelCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $DiaryModelCopyWith<$Res> { - factory $DiaryModelCopyWith( - DiaryModel value, $Res Function(DiaryModel) then) = - _$DiaryModelCopyWithImpl<$Res, DiaryModel>; - @useResult - $Res call( - {int id, - DateTime date, - int closed, - List meals, - State state, - String? comment, - DateTime? wakeup, - DateTime? retire}); - - $StateCopyWith<$Res> get state; -} - -/// @nodoc -class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel> - implements $DiaryModelCopyWith<$Res> { - _$DiaryModelCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? date = null, - Object? closed = null, - Object? meals = null, - Object? state = null, - Object? comment = freezed, - Object? wakeup = freezed, - Object? retire = freezed, - }) { - return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - date: null == date - ? _value.date - : date // ignore: cast_nullable_to_non_nullable - as DateTime, - closed: null == closed - ? _value.closed - : closed // ignore: cast_nullable_to_non_nullable - as int, - meals: null == meals - ? _value.meals - : meals // ignore: cast_nullable_to_non_nullable - as List, - state: null == state - ? _value.state - : state // ignore: cast_nullable_to_non_nullable - as State, - comment: freezed == comment - ? _value.comment - : comment // ignore: cast_nullable_to_non_nullable - as String?, - wakeup: freezed == wakeup - ? _value.wakeup - : wakeup // ignore: cast_nullable_to_non_nullable - as DateTime?, - retire: freezed == retire - ? _value.retire - : retire // ignore: cast_nullable_to_non_nullable - as DateTime?, - ) as $Val); - } - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $StateCopyWith<$Res> get state { - return $StateCopyWith<$Res>(_value.state, (value) { - return _then(_value.copyWith(state: value) as $Val); - }); - } -} - -/// @nodoc -abstract class _$$DiaryModelImplCopyWith<$Res> - implements $DiaryModelCopyWith<$Res> { - factory _$$DiaryModelImplCopyWith( - _$DiaryModelImpl value, $Res Function(_$DiaryModelImpl) then) = - __$$DiaryModelImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {int id, - DateTime date, - int closed, - List meals, - State state, - String? comment, - DateTime? wakeup, - DateTime? retire}); - - @override - $StateCopyWith<$Res> get state; -} - -/// @nodoc -class __$$DiaryModelImplCopyWithImpl<$Res> - extends _$DiaryModelCopyWithImpl<$Res, _$DiaryModelImpl> - implements _$$DiaryModelImplCopyWith<$Res> { - __$$DiaryModelImplCopyWithImpl( - _$DiaryModelImpl _value, $Res Function(_$DiaryModelImpl) _then) - : super(_value, _then); - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? date = null, - Object? closed = null, - Object? meals = null, - Object? state = null, - Object? comment = freezed, - Object? wakeup = freezed, - Object? retire = freezed, - }) { - return _then(_$DiaryModelImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - date: null == date - ? _value.date - : date // ignore: cast_nullable_to_non_nullable - as DateTime, - closed: null == closed - ? _value.closed - : closed // ignore: cast_nullable_to_non_nullable - as int, - meals: null == meals - ? _value._meals - : meals // ignore: cast_nullable_to_non_nullable - as List, - state: null == state - ? _value.state - : state // ignore: cast_nullable_to_non_nullable - as State, - comment: freezed == comment - ? _value.comment - : comment // ignore: cast_nullable_to_non_nullable - as String?, - wakeup: freezed == wakeup - ? _value.wakeup - : wakeup // ignore: cast_nullable_to_non_nullable - as DateTime?, - retire: freezed == retire - ? _value.retire - : retire // ignore: cast_nullable_to_non_nullable - as DateTime?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$DiaryModelImpl implements _DiaryModel { - const _$DiaryModelImpl( - {required this.id, - required this.date, - required this.closed, - required final List meals, - required this.state, - this.comment, - this.wakeup, - this.retire}) - : _meals = meals; - - factory _$DiaryModelImpl.fromJson(Map json) => - _$$DiaryModelImplFromJson(json); - - @override - final int id; - @override - final DateTime date; - @override - final int closed; - final List _meals; - @override - List get meals { - if (_meals is EqualUnmodifiableListView) return _meals; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_meals); - } - - @override - final State state; - @override - final String? comment; - @override - final DateTime? wakeup; - @override - final DateTime? retire; - - @override - String toString() { - return 'DiaryModel(id: $id, date: $date, closed: $closed, meals: $meals, state: $state, comment: $comment, wakeup: $wakeup, retire: $retire)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$DiaryModelImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.date, date) || other.date == date) && - (identical(other.closed, closed) || other.closed == closed) && - const DeepCollectionEquality().equals(other._meals, _meals) && - (identical(other.state, state) || other.state == state) && - (identical(other.comment, comment) || other.comment == comment) && - (identical(other.wakeup, wakeup) || other.wakeup == wakeup) && - (identical(other.retire, retire) || other.retire == retire)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - id, - date, - closed, - const DeepCollectionEquality().hash(_meals), - state, - comment, - wakeup, - retire); - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$DiaryModelImplCopyWith<_$DiaryModelImpl> get copyWith => - __$$DiaryModelImplCopyWithImpl<_$DiaryModelImpl>(this, _$identity); - - @override - Map toJson() { - return _$$DiaryModelImplToJson( - this, - ); - } -} - -abstract class _DiaryModel implements DiaryModel { - const factory _DiaryModel( - {required final int id, - required final DateTime date, - required final int closed, - required final List meals, - required final State state, - final String? comment, - final DateTime? wakeup, - final DateTime? retire}) = _$DiaryModelImpl; - - factory _DiaryModel.fromJson(Map json) = - _$DiaryModelImpl.fromJson; - - @override - int get id; - @override - DateTime get date; - @override - int get closed; - @override - List get meals; - @override - State get state; - @override - String? get comment; - @override - DateTime? get wakeup; - @override - DateTime? get retire; - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$DiaryModelImplCopyWith<_$DiaryModelImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/features/diary/models/diary_model.g.dart b/lib/features/diary/models/diary_model.g.dart deleted file mode 100644 index 29f98caa..00000000 --- a/lib/features/diary/models/diary_model.g.dart +++ /dev/null @@ -1,37 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'diary_model.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$DiaryModelImpl _$$DiaryModelImplFromJson(Map json) => - _$DiaryModelImpl( - id: (json['id'] as num).toInt(), - date: DateTime.parse(json['date'] as String), - closed: (json['closed'] as num).toInt(), - meals: (json['meals'] as List) - .map((e) => Meal.fromJson(e as Map)) - .toList(), - state: State.fromJson(json['state'] as Map), - comment: json['comment'] as String?, - wakeup: json['wakeup'] == null - ? null - : DateTime.parse(json['wakeup'] as String), - retire: json['retire'] == null - ? null - : DateTime.parse(json['retire'] as String), - ); - -Map _$$DiaryModelImplToJson(_$DiaryModelImpl instance) => - { - 'id': instance.id, - 'date': instance.date.toIso8601String(), - 'closed': instance.closed, - 'meals': instance.meals, - 'state': instance.state, - 'comment': instance.comment, - 'wakeup': instance.wakeup?.toIso8601String(), - 'retire': instance.retire?.toIso8601String(), - }; diff --git a/lib/features/diary/models/meal.dart b/lib/features/diary/models/meal.dart deleted file mode 100644 index b5e12d83..00000000 --- a/lib/features/diary/models/meal.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -import './photo.dart'; -import './portion.dart'; - -part 'meal.freezed.dart'; - -part 'meal.g.dart'; - -@freezed -class Meal with _$Meal { - const factory Meal({ - required int id, - required String time, - required int type, - required int satiety, - required int mood, - required List portions, - required List photos, - }) = _Meal; - - factory Meal.fromJson(Map json) => _$MealFromJson(json); -} diff --git a/lib/features/diary/models/meal.freezed.dart b/lib/features/diary/models/meal.freezed.dart deleted file mode 100644 index 2bd6c478..00000000 --- a/lib/features/diary/models/meal.freezed.dart +++ /dev/null @@ -1,304 +0,0 @@ -// 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 'meal.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(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'); - -Meal _$MealFromJson(Map json) { - return _Meal.fromJson(json); -} - -/// @nodoc -mixin _$Meal { - int get id => throw _privateConstructorUsedError; - String get time => throw _privateConstructorUsedError; - int get type => throw _privateConstructorUsedError; - int get satiety => throw _privateConstructorUsedError; - int get mood => throw _privateConstructorUsedError; - List get portions => throw _privateConstructorUsedError; - List get photos => throw _privateConstructorUsedError; - - /// Serializes this Meal to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $MealCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $MealCopyWith<$Res> { - factory $MealCopyWith(Meal value, $Res Function(Meal) then) = - _$MealCopyWithImpl<$Res, Meal>; - @useResult - $Res call( - {int id, - String time, - int type, - int satiety, - int mood, - List portions, - List photos}); -} - -/// @nodoc -class _$MealCopyWithImpl<$Res, $Val extends Meal> - implements $MealCopyWith<$Res> { - _$MealCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? time = null, - Object? type = null, - Object? satiety = null, - Object? mood = null, - Object? portions = null, - Object? photos = null, - }) { - return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - time: null == time - ? _value.time - : time // ignore: cast_nullable_to_non_nullable - as String, - type: null == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as int, - satiety: null == satiety - ? _value.satiety - : satiety // ignore: cast_nullable_to_non_nullable - as int, - mood: null == mood - ? _value.mood - : mood // ignore: cast_nullable_to_non_nullable - as int, - portions: null == portions - ? _value.portions - : portions // ignore: cast_nullable_to_non_nullable - as List, - photos: null == photos - ? _value.photos - : photos // ignore: cast_nullable_to_non_nullable - as List, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$MealImplCopyWith<$Res> implements $MealCopyWith<$Res> { - factory _$$MealImplCopyWith( - _$MealImpl value, $Res Function(_$MealImpl) then) = - __$$MealImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {int id, - String time, - int type, - int satiety, - int mood, - List portions, - List photos}); -} - -/// @nodoc -class __$$MealImplCopyWithImpl<$Res> - extends _$MealCopyWithImpl<$Res, _$MealImpl> - implements _$$MealImplCopyWith<$Res> { - __$$MealImplCopyWithImpl(_$MealImpl _value, $Res Function(_$MealImpl) _then) - : super(_value, _then); - - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? time = null, - Object? type = null, - Object? satiety = null, - Object? mood = null, - Object? portions = null, - Object? photos = null, - }) { - return _then(_$MealImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - time: null == time - ? _value.time - : time // ignore: cast_nullable_to_non_nullable - as String, - type: null == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as int, - satiety: null == satiety - ? _value.satiety - : satiety // ignore: cast_nullable_to_non_nullable - as int, - mood: null == mood - ? _value.mood - : mood // ignore: cast_nullable_to_non_nullable - as int, - portions: null == portions - ? _value._portions - : portions // ignore: cast_nullable_to_non_nullable - as List, - photos: null == photos - ? _value._photos - : photos // ignore: cast_nullable_to_non_nullable - as List, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$MealImpl implements _Meal { - const _$MealImpl( - {required this.id, - required this.time, - required this.type, - required this.satiety, - required this.mood, - required final List portions, - required final List photos}) - : _portions = portions, - _photos = photos; - - factory _$MealImpl.fromJson(Map json) => - _$$MealImplFromJson(json); - - @override - final int id; - @override - final String time; - @override - final int type; - @override - final int satiety; - @override - final int mood; - final List _portions; - @override - List get portions { - if (_portions is EqualUnmodifiableListView) return _portions; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_portions); - } - - final List _photos; - @override - List get photos { - if (_photos is EqualUnmodifiableListView) return _photos; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_photos); - } - - @override - String toString() { - return 'Meal(id: $id, time: $time, type: $type, satiety: $satiety, mood: $mood, portions: $portions, photos: $photos)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$MealImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.time, time) || other.time == time) && - (identical(other.type, type) || other.type == type) && - (identical(other.satiety, satiety) || other.satiety == satiety) && - (identical(other.mood, mood) || other.mood == mood) && - const DeepCollectionEquality().equals(other._portions, _portions) && - const DeepCollectionEquality().equals(other._photos, _photos)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - id, - time, - type, - satiety, - mood, - const DeepCollectionEquality().hash(_portions), - const DeepCollectionEquality().hash(_photos)); - - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$MealImplCopyWith<_$MealImpl> get copyWith => - __$$MealImplCopyWithImpl<_$MealImpl>(this, _$identity); - - @override - Map toJson() { - return _$$MealImplToJson( - this, - ); - } -} - -abstract class _Meal implements Meal { - const factory _Meal( - {required final int id, - required final String time, - required final int type, - required final int satiety, - required final int mood, - required final List portions, - required final List photos}) = _$MealImpl; - - factory _Meal.fromJson(Map json) = _$MealImpl.fromJson; - - @override - int get id; - @override - String get time; - @override - int get type; - @override - int get satiety; - @override - int get mood; - @override - List get portions; - @override - List get photos; - - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$MealImplCopyWith<_$MealImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/features/diary/models/meal.g.dart b/lib/features/diary/models/meal.g.dart deleted file mode 100644 index 5536ed92..00000000 --- a/lib/features/diary/models/meal.g.dart +++ /dev/null @@ -1,32 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'meal.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$MealImpl _$$MealImplFromJson(Map json) => _$MealImpl( - id: (json['id'] as num).toInt(), - time: json['time'] as String, - type: (json['type'] as num).toInt(), - satiety: (json['satiety'] as num).toInt(), - mood: (json['mood'] as num).toInt(), - portions: (json['portions'] as List) - .map((e) => Portion.fromJson(e as Map)) - .toList(), - photos: (json['photos'] as List) - .map((e) => Photo.fromJson(e as Map)) - .toList(), - ); - -Map _$$MealImplToJson(_$MealImpl instance) => - { - 'id': instance.id, - 'time': instance.time, - 'type': instance.type, - 'satiety': instance.satiety, - 'mood': instance.mood, - 'portions': instance.portions, - 'photos': instance.photos, - }; diff --git a/lib/features/diary/models/photo.dart b/lib/features/diary/models/photo.dart deleted file mode 100644 index d3e4f695..00000000 --- a/lib/features/diary/models/photo.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'photo.freezed.dart'; - -part 'photo.g.dart'; - -@freezed -class Photo with _$Photo { - const factory Photo({ - required int id, - @JsonKey(name: 'original_name') required String originalName, - required String path, - }) = _Photo; - - factory Photo.fromJson(Map json) => _$PhotoFromJson(json); -} diff --git a/lib/features/diary/models/photo.freezed.dart b/lib/features/diary/models/photo.freezed.dart deleted file mode 100644 index 8f5e0152..00000000 --- a/lib/features/diary/models/photo.freezed.dart +++ /dev/null @@ -1,208 +0,0 @@ -// 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 'photo.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(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'); - -Photo _$PhotoFromJson(Map json) { - return _Photo.fromJson(json); -} - -/// @nodoc -mixin _$Photo { - int get id => throw _privateConstructorUsedError; - @JsonKey(name: 'original_name') - String get originalName => throw _privateConstructorUsedError; - String get path => throw _privateConstructorUsedError; - - /// Serializes this Photo to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PhotoCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $PhotoCopyWith<$Res> { - factory $PhotoCopyWith(Photo value, $Res Function(Photo) then) = - _$PhotoCopyWithImpl<$Res, Photo>; - @useResult - $Res call( - {int id, - @JsonKey(name: 'original_name') String originalName, - String path}); -} - -/// @nodoc -class _$PhotoCopyWithImpl<$Res, $Val extends Photo> - implements $PhotoCopyWith<$Res> { - _$PhotoCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? originalName = null, - Object? path = null, - }) { - return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - originalName: null == originalName - ? _value.originalName - : originalName // ignore: cast_nullable_to_non_nullable - as String, - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$PhotoImplCopyWith<$Res> implements $PhotoCopyWith<$Res> { - factory _$$PhotoImplCopyWith( - _$PhotoImpl value, $Res Function(_$PhotoImpl) then) = - __$$PhotoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {int id, - @JsonKey(name: 'original_name') String originalName, - String path}); -} - -/// @nodoc -class __$$PhotoImplCopyWithImpl<$Res> - extends _$PhotoCopyWithImpl<$Res, _$PhotoImpl> - implements _$$PhotoImplCopyWith<$Res> { - __$$PhotoImplCopyWithImpl( - _$PhotoImpl _value, $Res Function(_$PhotoImpl) _then) - : super(_value, _then); - - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? originalName = null, - Object? path = null, - }) { - return _then(_$PhotoImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - originalName: null == originalName - ? _value.originalName - : originalName // ignore: cast_nullable_to_non_nullable - as String, - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$PhotoImpl implements _Photo { - const _$PhotoImpl( - {required this.id, - @JsonKey(name: 'original_name') required this.originalName, - required this.path}); - - factory _$PhotoImpl.fromJson(Map json) => - _$$PhotoImplFromJson(json); - - @override - final int id; - @override - @JsonKey(name: 'original_name') - final String originalName; - @override - final String path; - - @override - String toString() { - return 'Photo(id: $id, originalName: $originalName, path: $path)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PhotoImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.originalName, originalName) || - other.originalName == originalName) && - (identical(other.path, path) || other.path == path)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, id, originalName, path); - - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PhotoImplCopyWith<_$PhotoImpl> get copyWith => - __$$PhotoImplCopyWithImpl<_$PhotoImpl>(this, _$identity); - - @override - Map toJson() { - return _$$PhotoImplToJson( - this, - ); - } -} - -abstract class _Photo implements Photo { - const factory _Photo( - {required final int id, - @JsonKey(name: 'original_name') required final String originalName, - required final String path}) = _$PhotoImpl; - - factory _Photo.fromJson(Map json) = _$PhotoImpl.fromJson; - - @override - int get id; - @override - @JsonKey(name: 'original_name') - String get originalName; - @override - String get path; - - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PhotoImplCopyWith<_$PhotoImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/features/diary/models/portion.dart b/lib/features/diary/models/portion.dart deleted file mode 100644 index f829dcf9..00000000 --- a/lib/features/diary/models/portion.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'portion.freezed.dart'; - -part 'portion.g.dart'; - -@freezed -class Portion with _$Portion { - const factory Portion({ - required int id, - required String product_name, - required int quantity, - required String portion, - required bool from_diet, - }) = _Portion; - - factory Portion.fromJson(Map json) => _$PortionFromJson(json); -} diff --git a/lib/features/diary/models/portion.freezed.dart b/lib/features/diary/models/portion.freezed.dart deleted file mode 100644 index 4bef02d4..00000000 --- a/lib/features/diary/models/portion.freezed.dart +++ /dev/null @@ -1,248 +0,0 @@ -// 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 'portion.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(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'); - -Portion _$PortionFromJson(Map json) { - return _Portion.fromJson(json); -} - -/// @nodoc -mixin _$Portion { - int get id => throw _privateConstructorUsedError; - String get product_name => throw _privateConstructorUsedError; - int get quantity => throw _privateConstructorUsedError; - String get portion => throw _privateConstructorUsedError; - bool get from_diet => throw _privateConstructorUsedError; - - /// Serializes this Portion to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PortionCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $PortionCopyWith<$Res> { - factory $PortionCopyWith(Portion value, $Res Function(Portion) then) = - _$PortionCopyWithImpl<$Res, Portion>; - @useResult - $Res call( - {int id, - String product_name, - int quantity, - String portion, - bool from_diet}); -} - -/// @nodoc -class _$PortionCopyWithImpl<$Res, $Val extends Portion> - implements $PortionCopyWith<$Res> { - _$PortionCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? product_name = null, - Object? quantity = null, - Object? portion = null, - Object? from_diet = null, - }) { - return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - product_name: null == product_name - ? _value.product_name - : product_name // ignore: cast_nullable_to_non_nullable - as String, - quantity: null == quantity - ? _value.quantity - : quantity // ignore: cast_nullable_to_non_nullable - as int, - portion: null == portion - ? _value.portion - : portion // ignore: cast_nullable_to_non_nullable - as String, - from_diet: null == from_diet - ? _value.from_diet - : from_diet // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$PortionImplCopyWith<$Res> implements $PortionCopyWith<$Res> { - factory _$$PortionImplCopyWith( - _$PortionImpl value, $Res Function(_$PortionImpl) then) = - __$$PortionImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {int id, - String product_name, - int quantity, - String portion, - bool from_diet}); -} - -/// @nodoc -class __$$PortionImplCopyWithImpl<$Res> - extends _$PortionCopyWithImpl<$Res, _$PortionImpl> - implements _$$PortionImplCopyWith<$Res> { - __$$PortionImplCopyWithImpl( - _$PortionImpl _value, $Res Function(_$PortionImpl) _then) - : super(_value, _then); - - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? product_name = null, - Object? quantity = null, - Object? portion = null, - Object? from_diet = null, - }) { - return _then(_$PortionImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - product_name: null == product_name - ? _value.product_name - : product_name // ignore: cast_nullable_to_non_nullable - as String, - quantity: null == quantity - ? _value.quantity - : quantity // ignore: cast_nullable_to_non_nullable - as int, - portion: null == portion - ? _value.portion - : portion // ignore: cast_nullable_to_non_nullable - as String, - from_diet: null == from_diet - ? _value.from_diet - : from_diet // ignore: cast_nullable_to_non_nullable - as bool, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$PortionImpl implements _Portion { - const _$PortionImpl( - {required this.id, - required this.product_name, - required this.quantity, - required this.portion, - required this.from_diet}); - - factory _$PortionImpl.fromJson(Map json) => - _$$PortionImplFromJson(json); - - @override - final int id; - @override - final String product_name; - @override - final int quantity; - @override - final String portion; - @override - final bool from_diet; - - @override - String toString() { - return 'Portion(id: $id, product_name: $product_name, quantity: $quantity, portion: $portion, from_diet: $from_diet)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PortionImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.product_name, product_name) || - other.product_name == product_name) && - (identical(other.quantity, quantity) || - other.quantity == quantity) && - (identical(other.portion, portion) || other.portion == portion) && - (identical(other.from_diet, from_diet) || - other.from_diet == from_diet)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => - Object.hash(runtimeType, id, product_name, quantity, portion, from_diet); - - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PortionImplCopyWith<_$PortionImpl> get copyWith => - __$$PortionImplCopyWithImpl<_$PortionImpl>(this, _$identity); - - @override - Map toJson() { - return _$$PortionImplToJson( - this, - ); - } -} - -abstract class _Portion implements Portion { - const factory _Portion( - {required final int id, - required final String product_name, - required final int quantity, - required final String portion, - required final bool from_diet}) = _$PortionImpl; - - factory _Portion.fromJson(Map json) = _$PortionImpl.fromJson; - - @override - int get id; - @override - String get product_name; - @override - int get quantity; - @override - String get portion; - @override - bool get from_diet; - - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PortionImplCopyWith<_$PortionImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/features/diary/models/portion.g.dart b/lib/features/diary/models/portion.g.dart deleted file mode 100644 index f3503e5c..00000000 --- a/lib/features/diary/models/portion.g.dart +++ /dev/null @@ -1,25 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'portion.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$PortionImpl _$$PortionImplFromJson(Map json) => - _$PortionImpl( - id: (json['id'] as num).toInt(), - product_name: json['product_name'] as String, - quantity: (json['quantity'] as num).toInt(), - portion: json['portion'] as String, - from_diet: json['from_diet'] as bool, - ); - -Map _$$PortionImplToJson(_$PortionImpl instance) => - { - 'id': instance.id, - 'product_name': instance.product_name, - 'quantity': instance.quantity, - 'portion': instance.portion, - 'from_diet': instance.from_diet, - }; diff --git a/lib/features/diary/models/state.dart b/lib/features/diary/models/state.dart deleted file mode 100644 index b1da05c4..00000000 --- a/lib/features/diary/models/state.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'state.freezed.dart'; - -part 'state.g.dart'; - -@freezed -class State with _$State { - const factory State({ - required bool has_chosen_diet, - required bool has_chosen_plan, - }) = _State; - - factory State.fromJson(Map json) => _$StateFromJson(json); -} diff --git a/lib/features/diary/models/state.freezed.dart b/lib/features/diary/models/state.freezed.dart deleted file mode 100644 index 6b9c50fb..00000000 --- a/lib/features/diary/models/state.freezed.dart +++ /dev/null @@ -1,182 +0,0 @@ -// 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 'state.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(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'); - -State _$StateFromJson(Map json) { - return _State.fromJson(json); -} - -/// @nodoc -mixin _$State { - bool get has_chosen_diet => throw _privateConstructorUsedError; - bool get has_chosen_plan => throw _privateConstructorUsedError; - - /// Serializes this State to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $StateCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $StateCopyWith<$Res> { - factory $StateCopyWith(State value, $Res Function(State) then) = - _$StateCopyWithImpl<$Res, State>; - @useResult - $Res call({bool has_chosen_diet, bool has_chosen_plan}); -} - -/// @nodoc -class _$StateCopyWithImpl<$Res, $Val extends State> - implements $StateCopyWith<$Res> { - _$StateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? has_chosen_diet = null, - Object? has_chosen_plan = null, - }) { - return _then(_value.copyWith( - has_chosen_diet: null == has_chosen_diet - ? _value.has_chosen_diet - : has_chosen_diet // ignore: cast_nullable_to_non_nullable - as bool, - has_chosen_plan: null == has_chosen_plan - ? _value.has_chosen_plan - : has_chosen_plan // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$StateImplCopyWith<$Res> implements $StateCopyWith<$Res> { - factory _$$StateImplCopyWith( - _$StateImpl value, $Res Function(_$StateImpl) then) = - __$$StateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({bool has_chosen_diet, bool has_chosen_plan}); -} - -/// @nodoc -class __$$StateImplCopyWithImpl<$Res> - extends _$StateCopyWithImpl<$Res, _$StateImpl> - implements _$$StateImplCopyWith<$Res> { - __$$StateImplCopyWithImpl( - _$StateImpl _value, $Res Function(_$StateImpl) _then) - : super(_value, _then); - - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? has_chosen_diet = null, - Object? has_chosen_plan = null, - }) { - return _then(_$StateImpl( - has_chosen_diet: null == has_chosen_diet - ? _value.has_chosen_diet - : has_chosen_diet // ignore: cast_nullable_to_non_nullable - as bool, - has_chosen_plan: null == has_chosen_plan - ? _value.has_chosen_plan - : has_chosen_plan // ignore: cast_nullable_to_non_nullable - as bool, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$StateImpl implements _State { - const _$StateImpl( - {required this.has_chosen_diet, required this.has_chosen_plan}); - - factory _$StateImpl.fromJson(Map json) => - _$$StateImplFromJson(json); - - @override - final bool has_chosen_diet; - @override - final bool has_chosen_plan; - - @override - String toString() { - return 'State(has_chosen_diet: $has_chosen_diet, has_chosen_plan: $has_chosen_plan)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$StateImpl && - (identical(other.has_chosen_diet, has_chosen_diet) || - other.has_chosen_diet == has_chosen_diet) && - (identical(other.has_chosen_plan, has_chosen_plan) || - other.has_chosen_plan == has_chosen_plan)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => - Object.hash(runtimeType, has_chosen_diet, has_chosen_plan); - - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$StateImplCopyWith<_$StateImpl> get copyWith => - __$$StateImplCopyWithImpl<_$StateImpl>(this, _$identity); - - @override - Map toJson() { - return _$$StateImplToJson( - this, - ); - } -} - -abstract class _State implements State { - const factory _State( - {required final bool has_chosen_diet, - required final bool has_chosen_plan}) = _$StateImpl; - - factory _State.fromJson(Map json) = _$StateImpl.fromJson; - - @override - bool get has_chosen_diet; - @override - bool get has_chosen_plan; - - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$StateImplCopyWith<_$StateImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/features/diary/models/state.g.dart b/lib/features/diary/models/state.g.dart deleted file mode 100644 index 1b0da8f4..00000000 --- a/lib/features/diary/models/state.g.dart +++ /dev/null @@ -1,18 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'state.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$StateImpl _$$StateImplFromJson(Map json) => _$StateImpl( - has_chosen_diet: json['has_chosen_diet'] as bool, - has_chosen_plan: json['has_chosen_plan'] as bool, - ); - -Map _$$StateImplToJson(_$StateImpl instance) => - { - 'has_chosen_diet': instance.has_chosen_diet, - 'has_chosen_plan': instance.has_chosen_plan, - }; diff --git a/lib/features/diary/presentation/bloc/diary_bloc.dart b/lib/features/diary/presentation/bloc/diary_bloc.dart deleted file mode 100644 index cee99a34..00000000 --- a/lib/features/diary/presentation/bloc/diary_bloc.dart +++ /dev/null @@ -1,517 +0,0 @@ -import 'dart:async'; - -import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; -import 'package:eatvio_app/features/diary/models/diary_model.dart'; -import 'package:eatvio_app/features/diary/models/meal.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; -import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; -import 'package:eatvio_app/features/diary/repositories/diary_repository.dart'; -import 'package:equatable/equatable.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:image_picker/image_picker.dart'; -import 'package:intl/intl.dart'; - -part 'diary_event.dart'; - -/// A bloc that manages the state of a Diary according to the event that is dispatched to it. -class DiaryBloc extends Bloc { - final DiaryRepository diaryRepository; - - DiaryBloc({required this.diaryRepository}) : super(const DiaryState.loading()) { - on(loadDiary); - on(loadDiaryById); - on(_changeSatiety); // пользователь нажимает на шкалу сытости - on(_changeMood); // пользователь нажимает на шкалу настроения - on(_changeMealTime); // пользовательяет времяа пиши - on(_changeMeal); - on(_changePortion); - on(_changeWakeup); // пользователь выбирает время пробуждения - on(_changeRetire); // пользователь выбирает время отхода ко сну - on(_toggleMood); - on(_toggleWakeup); - on(_addPortion); //пользователь нажимает "Добавить продукт" - on(_removePortion); - on( - _removeImage, - ); // пользователь нажимает на крестик около продукта - on(_uploadImages); //пользователь нажимает "Добавить фото" - on( - _inputProduct, - ); - on(_finishDay); - on(_sendModeration); - on(_clearInput); - on(_confirmPortion); - } - - loadDiary( - LoadDiary event, - Emitter emit, - ) async { - emit(const DiaryState.loading()); - try { - Map data = await diaryRepository.getDiaryID(); - - final int? diaryID = data['id']; - final DiaryModel diary = await diaryRepository.getDiary(diaryID ?? 45); - final Meal currentMeal = diary.meals[0]; - - List portionList = [SelectionPopupModel(title: "грамм", value: "gr"), SelectionPopupModel(title: "порций", value: "pcs")]; - - final Map chartData = await diaryRepository.getChartData(diaryID ?? 45); - final Map dailyNutritionIntake = chartData['dailyNutritionIntake']!; - final Map dailyNutritionRecommendations = chartData['dailyNutritionRecommendation']!; - final double ccal = dailyNutritionIntake['energy']! / dailyNutritionRecommendations['energy']! * 50; - final double proteins = dailyNutritionIntake['proteins']! / dailyNutritionRecommendations['proteins']! * 50; - final double fats = dailyNutritionIntake['fats']! / dailyNutritionRecommendations['fats']! * 50; - final double carbs = dailyNutritionIntake['carbohydrates']! / dailyNutritionRecommendations['carbohydrates']! * 50; - - Color getColor(double value) { - if (value >= 99.1) { - return Colors.red; - } else { - return Colors.blue; - } - } - - final List chartDataCounted = [ - NutritionData('Калории', ccal, getColor(ccal)), - NutritionData('Белки', proteins, getColor(proteins)), - NutritionData('Жиры', fats, getColor(fats)), - NutritionData('Углеводы', carbs, getColor(carbs)), - ]; - - List mealList = [ - SelectionPopupModel(title: "Прием пищи 1", id: 1), - SelectionPopupModel(title: "Прием пищи 2", id: 2), - SelectionPopupModel(title: "Прием пищи 3", id: 3), - SelectionPopupModel(title: "Прием пищи 4", id: 4), - SelectionPopupModel(title: "Прием пищи 5", id: 5), - SelectionPopupModel(title: "Прием пищи 6", id: 6), - ]; - - emit(DiaryState.loaded( - diary: diary, - currentMeal: currentMeal, - portions: currentMeal.portions, - portionList: portionList, - portionController: portionList[0], - mealList: mealList, - chartData: chartData, - chartDataCounted: chartDataCounted, - selectedMood: currentMeal.mood, - selectedSatiety: currentMeal.satiety, - wakeupController: TimeOfDay.now(), - retireController: TimeOfDay.now(), - commentController: TextEditingController(), - product_nameController: TextEditingController(), - productQuantityController: TextEditingController(), - caloriesController: TextEditingController(), - fatsController: TextEditingController(), - proteinsController: TextEditingController(), - carbsController: TextEditingController(), - wakeupExpanded: false, - moderationExpanded: false, - moodExpanded: false, - isLoading: false, - isAdded: false, - autocompleteList: [], - recommendedChartValues: [1, 1, 1, 1], - consumedChartValues: [1, 1, 1, 1])); - } catch (e) { - emit(DiaryState.error(errorMessage: e.toString())); - } - } - - loadDiaryById( - LoadDiaryById event, - Emitter emit, - ) async { - emit(const DiaryState.loading()); - try { - final int diaryID = int.parse(event.id ?? "0"); - final DiaryModel diary = await diaryRepository.getDiary(diaryID); - final Meal currentMeal = diary.meals[0]; - - List portionList = [SelectionPopupModel(title: "gr"), SelectionPopupModel(title: "pcs")]; - - final Map chartData = await diaryRepository.getChartData(diaryID); - final Map dailyNutritionIntake = chartData['dailyNutritionIntake']!; - final Map dailyNutritionRecommendations = chartData['dailyNutritionRecommendation']!; - final double ccal = dailyNutritionIntake['energy']! / dailyNutritionRecommendations['energy']! * 50; - final double proteins = dailyNutritionIntake['proteins']! / dailyNutritionRecommendations['proteins']! * 50; - final double fats = dailyNutritionIntake['fats']! / dailyNutritionRecommendations['fats']! * 50; - final double carbs = dailyNutritionIntake['carbohydrates']! / dailyNutritionRecommendations['carbohydrates']! * 50; - - Color getColor(double value) { - if (value >= 99.1) { - return Colors.red; - } else { - return Colors.blue; - } - } - - final List chartDataCounted = [ - NutritionData('Калории', ccal, getColor(ccal)), - NutritionData('Белки', proteins, getColor(proteins)), - NutritionData('Жиры', fats, getColor(fats)), - NutritionData('Углеводы', carbs, getColor(carbs)), - ]; - - List mealList = [ - SelectionPopupModel(title: "Прием пищи 1", id: 1), - SelectionPopupModel(title: "Прием пищи 2", id: 2), - SelectionPopupModel(title: "Прием пищи 3", id: 3), - SelectionPopupModel(title: "Прием пищи 4", id: 4), - SelectionPopupModel(title: "Прием пищи 5", id: 5), - SelectionPopupModel(title: "Прием пищи 6", id: 6), - ]; - - emit(DiaryState.loaded( - diary: diary, - currentMeal: currentMeal, - portions: currentMeal.portions, - portionList: portionList, - portionController: portionList[0], - mealList: mealList, - chartData: chartData, - chartDataCounted: chartDataCounted, - selectedMood: currentMeal.mood, - selectedSatiety: currentMeal.satiety, - wakeupController: TimeOfDay.now(), - retireController: TimeOfDay.now(), - commentController: TextEditingController(), - product_nameController: TextEditingController(), - productQuantityController: TextEditingController(), - caloriesController: TextEditingController(), - fatsController: TextEditingController(), - proteinsController: TextEditingController(), - carbsController: TextEditingController(), - wakeupExpanded: false, - moderationExpanded: false, - moodExpanded: false, - isLoading: false, - isAdded: false, - autocompleteList: [], - recommendedChartValues: [1, 1, 1, 1], - consumedChartValues: [1, 1, 1, 1])); - } catch (e) { - emit(DiaryState.error(errorMessage: e.toString())); - } - } - - Future _changeSatiety( - ChangeSatiety event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - var updatedState = currentState.copyWith( - selectedSatiety: event.selectedElement, - ); - diaryRepository.changeSatiety( - event.selectedElement, - currentState.currentMeal.id, - currentState.diary.id, - ); - emit(updatedState); - } - } - - Future _changeMood( - ChangeMood event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - var updatedState = currentState.copyWith( - selectedMood: event.selectedElement, - ); - - diaryRepository.changeMood( - event.selectedElement, - currentState.currentMeal.id, - currentState.diary.id, - ); - - emit(updatedState); // Передаем обновленное состояние в emit - } - } - - FutureOr _changeWakeup( - WakeupEvent event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - var updatedState = currentState.copyWith(wakeupController: event.selectedTime); - final DateFormat formatter = DateFormat('HH:mm'); - final String wakeupString = formatter.format(DateTime(2022, 1, 1, event.selectedTime.hour, event.selectedTime.minute)); - await diaryRepository.changeWakeup( - currentState.diary.id, - wakeupString, - ); - emit(updatedState); - } - } - - FutureOr _changeRetire( - RetireEvent event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - var updatedState = currentState.copyWith(retireController: event.selectedTime); - final DateFormat formatter = DateFormat('HH:mm'); - final String retireString = formatter.format(DateTime(2022, 1, 1, event.selectedTime.hour, event.selectedTime.minute)); - await diaryRepository.changeRetire( - currentState.diary.id, - retireString, - ); - emit(updatedState); - } - } - - FutureOr _changeMealTime( - ChangeMealTime event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - var updatedState = currentState.copyWith(mealTimeController: event.time); - emit(updatedState); - } - } - - FutureOr _changeMeal( - ChangeMeal event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - final currentState = state as DiaryStateLoaded; - final Meal meal = currentState.diary.meals.firstWhere((meal) => meal.type == event.value.id); - DiaryStateLoaded updatedState = currentState.copyWith( - currentMeal: meal, - portions: meal.portions, - mealTimeController: toTime(meal.time), - selectedMood: meal.mood, - selectedSatiety: meal.satiety, - ); - emit(updatedState); - } - } - - Future _inputProduct( - ProductInput event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - final Map> productNutritionalValues = await diaryRepository.inputProduct(event.input); - var updatedState = currentState.copyWith( - product_nameController: TextEditingController(text: event.input), - autocompleteList: productNutritionalValues['product_nutritional_value'] ?? [], - ); - if (event.input.length > 3) { - updatedState = updatedState.copyWith(moderationExpanded: true); - } else { - updatedState = updatedState.copyWith(moderationExpanded: false); - } - - emit(updatedState); - } - } - - FutureOr _addPortion( - AddPortionEvent event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - await diaryRepository.addPortion( - currentState.diary.id, - currentState.currentMeal.id, - currentState.product_nameController.text, - currentState.portionController.value, - int.parse(currentState.productQuantityController.text), - ); - add(LoadDiary()); - } - } - - Future _removePortion( - RemovePortionEvent event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - await diaryRepository.removePortion( - currentState.diary.id, - currentState.currentMeal.id, - event.portionId, - ); - } - add(LoadDiary()); - } - - Future _uploadImages( - UploadImages event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - emit(currentState.copyWith(isLoading: true)); - await diaryRepository.uploadImage( - event.image.path, - currentState.diary.id, - currentState.currentMeal.id, - ); - add(LoadDiary()); - } - } - - FutureOr _sendModeration( - SendModeration event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - await diaryRepository.sendModeration( - event.name, - event.energyOn100gr, - event.proteinsOn100gr, - event.fatsOn100gr, - event.carbohydratesOn100gr, - ); - } - } - - FutureOr _clearInput( - ClearInput event, - Emitter emit, - ) { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - DiaryStateLoaded updatedState = currentState.copyWith(); - emit(updatedState); - } - } - - FutureOr _changePortion( - ChangePortion event, - Emitter emit, - ) { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - DiaryStateLoaded updatedState = currentState.copyWith( - portionController: event.value, - ); - emit(updatedState); - } - } - - FutureOr _toggleMood( - ToggleMoodExpandedEvent event, - Emitter emit, - ) { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - emit(currentState.copyWith(moodExpanded: !currentState.moodExpanded)); - } - } - - FutureOr _toggleWakeup( - ToggleWakeupExpandedEvent event, - Emitter emit, - ) { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - emit(currentState.copyWith(wakeupExpanded: !currentState.wakeupExpanded)); - } - } - - FutureOr _removeImage( - RemoveImageEvent event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - await diaryRepository.removeImage( - currentState.diary.id, - currentState.currentMeal.id, - int.parse(event.photoID), - event.path, - ); - add(LoadDiary()); - } - } - - Future _finishDay(FinishDay event, Emitter emit) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - await diaryRepository.finishDay( - currentState.diary.id, - // currentState.wakeupController, - // currentState.retireController, - // currentState.commentController.text, - ); - add(LoadDiary()); - } - } - - TimeOfDay toTime(String timeStr) { - List timeParts = timeStr.split(":"); - int hour = int.parse(timeParts[0]); - int minute = int.parse(timeParts[1]); - - TimeOfDay timeOfDay = TimeOfDay(hour: hour, minute: minute); - return timeOfDay; - } - - int compareTypes(a, b) { - return a['type'].compareTo(b['type']); - } - - List fillPortion() { - return [ - SelectionPopupModel(id: 0, title: "порций", isSelected: true), - SelectionPopupModel(id: 1, title: "грамм"), - ]; - } - - FutureOr _confirmPortion(ConfirmPortion event, Emitter emit) { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - final updatedPortions = currentState.portions.map((portion) { - if (portion.id == event.id) { - return portion.copyWith(from_diet: !portion.from_diet); - } - if (!portion.from_diet) add(RemovePortionEvent(portion.id)); - return portion; - }).toList(); - - final updatedState = currentState.copyWith(portions: updatedPortions); - - emit(updatedState); - - add(LoadDiary()); - } - } -} - -int convertToInt(dynamic value) { - if (value is int) { - return value; - } else if (value is double) { - return value.toInt(); - } else { - throw FormatException('Unexpected value type: ${value.runtimeType}'); - } -} diff --git a/lib/features/diary/presentation/bloc/diary_cubit.dart b/lib/features/diary/presentation/bloc/diary_cubit.dart new file mode 100644 index 00000000..da058d9e --- /dev/null +++ b/lib/features/diary/presentation/bloc/diary_cubit.dart @@ -0,0 +1,22 @@ +import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; +import 'package:eatvio_app/features/diary/repositories/diary_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class DiaryCubit extends Cubit { + final DiaryRepository diaryRepository; + + DiaryCubit({ + required this.diaryRepository, + }) : super(const DiaryState.loading()); + + getDiaryDay(String date) async { + print(date); + emit(const DiaryState.loading()); + try { + emit(DiaryState.loaded(diary: await diaryRepository.getDiaryByDate(date))); + } catch (e) { + emit(DiaryState.error(errorMessage: e.toString())); + throw e; + } + } +} diff --git a/lib/features/diary/presentation/bloc/diary_event.dart b/lib/features/diary/presentation/bloc/diary_event.dart deleted file mode 100644 index 33c168d7..00000000 --- a/lib/features/diary/presentation/bloc/diary_event.dart +++ /dev/null @@ -1,209 +0,0 @@ -// ignore_for_file: must_be_immutable - -part of 'diary_bloc.dart'; - -/// Abstract class for all events that can be dispatched from the -///Diary widget. -/// -/// Events must be immutable and implement the [Equatable] interface. -@immutable -abstract class DiaryEvent extends Equatable {} - -/// Event that is dispatched when the Diary widget is first created. -class LoadDiary extends DiaryEvent { - @override - List get props => []; -} - -class LoadDiaryById extends DiaryEvent { - LoadDiaryById( - this.id, - ); - - final String? id; - - @override - List get props => []; -} - -class ChangeSatiety extends DiaryEvent { - ChangeSatiety( - this.selectedElement, - ); - - final int selectedElement; - - @override - List get props => [selectedElement]; -} - -class ChangeMood extends DiaryEvent { - ChangeMood( - this.selectedElement, - ); - - final int selectedElement; - - @override - List get props => [selectedElement]; -} - -class ChangeMealTime extends DiaryEvent { - ChangeMealTime(this.time); - - final TimeOfDay time; - - @override - List get props => [time]; -} - -class AddComment extends DiaryEvent { - AddComment(this.diaryId, this.comment); - - final String comment; - final int diaryId; - - @override - List get props => [comment, diaryId]; -} - -class WakeupEvent extends DiaryEvent { - WakeupEvent(this.selectedTime); - - final TimeOfDay selectedTime; - - @override - List get props => [selectedTime]; -} - -class RetireEvent extends DiaryEvent { - RetireEvent(this.selectedTime); - - final TimeOfDay selectedTime; - - @override - List get props => [selectedTime]; -} - -class ToggleMoodExpandedEvent extends DiaryEvent { - @override - List get props => []; -} - -class ToggleWakeupExpandedEvent extends DiaryEvent { - @override - List get props => []; -} - -class AddPortionEvent extends DiaryEvent { - AddPortionEvent(); - - @override - List get props => []; -} - -class RemovePortionEvent extends DiaryEvent { - RemovePortionEvent(this.portionId); - - final int portionId; - - @override - List get props => [portionId]; -} - -class UploadImages extends DiaryEvent { - UploadImages(this.image); - - final XFile image; - - @override - List get props => [image]; -} - -class RemoveImageEvent extends DiaryEvent { - RemoveImageEvent(this.photoID, this.path); - - final String photoID; - final String path; - - @override - List get props => [photoID, path]; -} - -class ProductInput extends DiaryEvent { - ProductInput(this.input); - - final String input; - - @override - List get props => [input]; -} - -class ChangeMeal extends DiaryEvent { - ChangeMeal({required this.value}); - - SelectionPopupModel value; - - @override - List get props => [value]; -} - -class ClearInput extends DiaryEvent { - ClearInput({required this.value}); - - TextEditingController value; - - @override - List get props => [value]; -} - -class ChangePortion extends DiaryEvent { - ChangePortion({required this.value}); - - SelectionPopupModel value; - - @override - List get props => [value]; -} - -class FinishDay extends DiaryEvent { - FinishDay(); - - @override - List get props => []; -} - -class RefreshEvent extends DiaryEvent { - RefreshEvent(); - - @override - List get props => []; -} - -class ConfirmPortion extends DiaryEvent { - ConfirmPortion(this.id); - - int id; - - @override - List get props => [id]; -} - -class SendModeration extends DiaryEvent { - SendModeration({ - required this.name, - required this.energyOn100gr, - required this.proteinsOn100gr, - required this.fatsOn100gr, - required this.carbohydratesOn100gr, - }); - - String name; - String energyOn100gr; - String proteinsOn100gr; - String fatsOn100gr; - String carbohydratesOn100gr; - - @override - List get props => [name, energyOn100gr, proteinsOn100gr, fatsOn100gr, carbohydratesOn100gr]; -} diff --git a/lib/features/diary/presentation/bloc/diary_state.dart b/lib/features/diary/presentation/bloc/diary_state.dart index b0aebfb2..c9b58a8d 100644 --- a/lib/features/diary/presentation/bloc/diary_state.dart +++ b/lib/features/diary/presentation/bloc/diary_state.dart @@ -1,63 +1,19 @@ -import 'package:eatvio_app/features/diary/models/diary_model.dart'; -import 'package:eatvio_app/features/diary/models/meal.dart'; -import 'package:eatvio_app/features/diary/models/portion.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; -import 'package:flutter/material.dart'; +import 'package:eatvio_app/features/diary/models/diary_day_model.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import '../../../../data/models/selectionPopupModel/selection_popup_model.dart'; - part 'diary_state.freezed.dart'; @freezed -abstract class DiaryState with _$DiaryState { +class DiaryState with _$DiaryState { const factory DiaryState() = _DiaryState; - const factory DiaryState.loading({ - int? id, - }) = DiaryStateLoading; - - const factory DiaryState.loaded({ - required DiaryModel diary, - String? diaryDate, - required List recommendedChartValues, - required List consumedChartValues, - required List portions, - required List mealList, - required List portionList, - required List autocompleteList, - required Map chartData, - required Meal currentMeal, - required SelectionPopupModel portionController, - required TimeOfDay wakeupController, - required TimeOfDay retireController, - TimeOfDay? mealTimeController, - required TextEditingController commentController, - required TextEditingController product_nameController, - required TextEditingController productQuantityController, - required TextEditingController caloriesController, - required TextEditingController fatsController, - required TextEditingController proteinsController, - required TextEditingController carbsController, - required int selectedMood, - required int selectedSatiety, - required bool wakeupExpanded, - required bool moderationExpanded, - required bool moodExpanded, - required bool isLoading, - required bool isAdded, - List? chartDataCounted, - }) = DiaryStateLoaded; + const factory DiaryState.loading() = DiaryStateLoading; const factory DiaryState.error({ required String errorMessage, }) = DiaryStateError; -} -class NutritionData { - NutritionData(this.category, this.nutrition, this.color); - - final String category; - final double nutrition; - final Color color; + const factory DiaryState.loaded({ + required DiaryDayModel diary, + }) = DiaryStateLoaded; } diff --git a/lib/features/diary/presentation/bloc/diary_state.freezed.dart b/lib/features/diary/presentation/bloc/diary_state.freezed.dart index 98d7019f..513d217d 100644 --- a/lib/features/diary/presentation/bloc/diary_state.freezed.dart +++ b/lib/features/diary/presentation/bloc/diary_state.freezed.dart @@ -19,115 +19,25 @@ mixin _$DiaryState { @optionalTypeArgs TResult when( TResult Function() $default, { - required TResult Function(int? id) loading, - required TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted) - loaded, + required TResult Function() loading, required TResult Function(String errorMessage) error, + required TResult Function(DiaryDayModel diary) loaded, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull( TResult? Function()? $default, { - TResult? Function(int? id)? loading, - TResult? Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult? Function()? loading, TResult? Function(String errorMessage)? error, + TResult? Function(DiaryDayModel diary)? loaded, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeWhen( TResult Function()? $default, { - TResult Function(int? id)? loading, - TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult Function()? loading, TResult Function(String errorMessage)? error, + TResult Function(DiaryDayModel diary)? loaded, required TResult orElse(), }) => throw _privateConstructorUsedError; @@ -135,24 +45,24 @@ mixin _$DiaryState { TResult map( TResult Function(_DiaryState value) $default, { required TResult Function(DiaryStateLoading value) loading, - required TResult Function(DiaryStateLoaded value) loaded, required TResult Function(DiaryStateError value) error, + required TResult Function(DiaryStateLoaded value) loaded, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? mapOrNull( TResult? Function(_DiaryState value)? $default, { TResult? Function(DiaryStateLoading value)? loading, - TResult? Function(DiaryStateLoaded value)? loaded, TResult? Function(DiaryStateError value)? error, + TResult? Function(DiaryStateLoaded value)? loaded, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeMap( TResult Function(_DiaryState value)? $default, { TResult Function(DiaryStateLoading value)? loading, - TResult Function(DiaryStateLoaded value)? loaded, TResult Function(DiaryStateError value)? error, + TResult Function(DiaryStateLoaded value)? loaded, required TResult orElse(), }) => throw _privateConstructorUsedError; @@ -221,39 +131,9 @@ class _$DiaryStateImpl implements _DiaryState { @optionalTypeArgs TResult when( TResult Function() $default, { - required TResult Function(int? id) loading, - required TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted) - loaded, + required TResult Function() loading, required TResult Function(String errorMessage) error, + required TResult Function(DiaryDayModel diary) loaded, }) { return $default(); } @@ -262,39 +142,9 @@ class _$DiaryStateImpl implements _DiaryState { @optionalTypeArgs TResult? whenOrNull( TResult? Function()? $default, { - TResult? Function(int? id)? loading, - TResult? Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult? Function()? loading, TResult? Function(String errorMessage)? error, + TResult? Function(DiaryDayModel diary)? loaded, }) { return $default?.call(); } @@ -303,39 +153,9 @@ class _$DiaryStateImpl implements _DiaryState { @optionalTypeArgs TResult maybeWhen( TResult Function()? $default, { - TResult Function(int? id)? loading, - TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult Function()? loading, TResult Function(String errorMessage)? error, + TResult Function(DiaryDayModel diary)? loaded, required TResult orElse(), }) { if ($default != null) { @@ -349,8 +169,8 @@ class _$DiaryStateImpl implements _DiaryState { TResult map( TResult Function(_DiaryState value) $default, { required TResult Function(DiaryStateLoading value) loading, - required TResult Function(DiaryStateLoaded value) loaded, required TResult Function(DiaryStateError value) error, + required TResult Function(DiaryStateLoaded value) loaded, }) { return $default(this); } @@ -360,8 +180,8 @@ class _$DiaryStateImpl implements _DiaryState { TResult? mapOrNull( TResult? Function(_DiaryState value)? $default, { TResult? Function(DiaryStateLoading value)? loading, - TResult? Function(DiaryStateLoaded value)? loaded, TResult? Function(DiaryStateError value)? error, + TResult? Function(DiaryStateLoaded value)? loaded, }) { return $default?.call(this); } @@ -371,8 +191,8 @@ class _$DiaryStateImpl implements _DiaryState { TResult maybeMap( TResult Function(_DiaryState value)? $default, { TResult Function(DiaryStateLoading value)? loading, - TResult Function(DiaryStateLoaded value)? loaded, TResult Function(DiaryStateError value)? error, + TResult Function(DiaryStateLoaded value)? loaded, required TResult orElse(), }) { if ($default != null) { @@ -391,8 +211,6 @@ abstract class _$$DiaryStateLoadingImplCopyWith<$Res> { factory _$$DiaryStateLoadingImplCopyWith(_$DiaryStateLoadingImpl value, $Res Function(_$DiaryStateLoadingImpl) then) = __$$DiaryStateLoadingImplCopyWithImpl<$Res>; - @useResult - $Res call({int? id}); } /// @nodoc @@ -405,176 +223,60 @@ class __$$DiaryStateLoadingImplCopyWithImpl<$Res> /// Create a copy of DiaryState /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - }) { - return _then(_$DiaryStateLoadingImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int?, - )); - } } /// @nodoc class _$DiaryStateLoadingImpl implements DiaryStateLoading { - const _$DiaryStateLoadingImpl({this.id}); - - @override - final int? id; + const _$DiaryStateLoadingImpl(); @override String toString() { - return 'DiaryState.loading(id: $id)'; + return 'DiaryState.loading()'; } @override bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$DiaryStateLoadingImpl && - (identical(other.id, id) || other.id == id)); + (other.runtimeType == runtimeType && other is _$DiaryStateLoadingImpl); } @override - int get hashCode => Object.hash(runtimeType, id); - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$DiaryStateLoadingImplCopyWith<_$DiaryStateLoadingImpl> get copyWith => - __$$DiaryStateLoadingImplCopyWithImpl<_$DiaryStateLoadingImpl>( - this, _$identity); + int get hashCode => runtimeType.hashCode; @override @optionalTypeArgs TResult when( TResult Function() $default, { - required TResult Function(int? id) loading, - required TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted) - loaded, + required TResult Function() loading, required TResult Function(String errorMessage) error, + required TResult Function(DiaryDayModel diary) loaded, }) { - return loading(id); + return loading(); } @override @optionalTypeArgs TResult? whenOrNull( TResult? Function()? $default, { - TResult? Function(int? id)? loading, - TResult? Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult? Function()? loading, TResult? Function(String errorMessage)? error, + TResult? Function(DiaryDayModel diary)? loaded, }) { - return loading?.call(id); + return loading?.call(); } @override @optionalTypeArgs TResult maybeWhen( TResult Function()? $default, { - TResult Function(int? id)? loading, - TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult Function()? loading, TResult Function(String errorMessage)? error, + TResult Function(DiaryDayModel diary)? loaded, required TResult orElse(), }) { if (loading != null) { - return loading(id); + return loading(); } return orElse(); } @@ -584,8 +286,8 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading { TResult map( TResult Function(_DiaryState value) $default, { required TResult Function(DiaryStateLoading value) loading, - required TResult Function(DiaryStateLoaded value) loaded, required TResult Function(DiaryStateError value) error, + required TResult Function(DiaryStateLoaded value) loaded, }) { return loading(this); } @@ -595,8 +297,8 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading { TResult? mapOrNull( TResult? Function(_DiaryState value)? $default, { TResult? Function(DiaryStateLoading value)? loading, - TResult? Function(DiaryStateLoaded value)? loaded, TResult? Function(DiaryStateError value)? error, + TResult? Function(DiaryStateLoaded value)? loaded, }) { return loading?.call(this); } @@ -606,8 +308,8 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading { TResult maybeMap( TResult Function(_DiaryState value)? $default, { TResult Function(DiaryStateLoading value)? loading, - TResult Function(DiaryStateLoaded value)? loaded, TResult Function(DiaryStateError value)? error, + TResult Function(DiaryStateLoaded value)? loaded, required TResult orElse(), }) { if (loading != null) { @@ -618,837 +320,7 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading { } abstract class DiaryStateLoading implements DiaryState { - const factory DiaryStateLoading({final int? id}) = _$DiaryStateLoadingImpl; - - int? get id; - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$DiaryStateLoadingImplCopyWith<_$DiaryStateLoadingImpl> get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class _$$DiaryStateLoadedImplCopyWith<$Res> { - factory _$$DiaryStateLoadedImplCopyWith(_$DiaryStateLoadedImpl value, - $Res Function(_$DiaryStateLoadedImpl) then) = - __$$DiaryStateLoadedImplCopyWithImpl<$Res>; - @useResult - $Res call( - {DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted}); - - $DiaryModelCopyWith<$Res> get diary; - $MealCopyWith<$Res> get currentMeal; - $SelectionPopupModelCopyWith<$Res> get portionController; -} - -/// @nodoc -class __$$DiaryStateLoadedImplCopyWithImpl<$Res> - extends _$DiaryStateCopyWithImpl<$Res, _$DiaryStateLoadedImpl> - implements _$$DiaryStateLoadedImplCopyWith<$Res> { - __$$DiaryStateLoadedImplCopyWithImpl(_$DiaryStateLoadedImpl _value, - $Res Function(_$DiaryStateLoadedImpl) _then) - : super(_value, _then); - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? diary = null, - Object? diaryDate = freezed, - Object? recommendedChartValues = null, - Object? consumedChartValues = null, - Object? portions = null, - Object? mealList = null, - Object? portionList = null, - Object? autocompleteList = null, - Object? chartData = null, - Object? currentMeal = null, - Object? portionController = null, - Object? wakeupController = null, - Object? retireController = null, - Object? mealTimeController = freezed, - Object? commentController = null, - Object? product_nameController = null, - Object? productQuantityController = null, - Object? caloriesController = null, - Object? fatsController = null, - Object? proteinsController = null, - Object? carbsController = null, - Object? selectedMood = null, - Object? selectedSatiety = null, - Object? wakeupExpanded = null, - Object? moderationExpanded = null, - Object? moodExpanded = null, - Object? isLoading = null, - Object? isAdded = null, - Object? chartDataCounted = freezed, - }) { - return _then(_$DiaryStateLoadedImpl( - diary: null == diary - ? _value.diary - : diary // ignore: cast_nullable_to_non_nullable - as DiaryModel, - diaryDate: freezed == diaryDate - ? _value.diaryDate - : diaryDate // ignore: cast_nullable_to_non_nullable - as String?, - recommendedChartValues: null == recommendedChartValues - ? _value._recommendedChartValues - : recommendedChartValues // ignore: cast_nullable_to_non_nullable - as List, - consumedChartValues: null == consumedChartValues - ? _value._consumedChartValues - : consumedChartValues // ignore: cast_nullable_to_non_nullable - as List, - portions: null == portions - ? _value._portions - : portions // ignore: cast_nullable_to_non_nullable - as List, - mealList: null == mealList - ? _value._mealList - : mealList // ignore: cast_nullable_to_non_nullable - as List, - portionList: null == portionList - ? _value._portionList - : portionList // ignore: cast_nullable_to_non_nullable - as List, - autocompleteList: null == autocompleteList - ? _value._autocompleteList - : autocompleteList // ignore: cast_nullable_to_non_nullable - as List, - chartData: null == chartData - ? _value._chartData - : chartData // ignore: cast_nullable_to_non_nullable - as Map, - currentMeal: null == currentMeal - ? _value.currentMeal - : currentMeal // ignore: cast_nullable_to_non_nullable - as Meal, - portionController: null == portionController - ? _value.portionController - : portionController // ignore: cast_nullable_to_non_nullable - as SelectionPopupModel, - wakeupController: null == wakeupController - ? _value.wakeupController - : wakeupController // ignore: cast_nullable_to_non_nullable - as TimeOfDay, - retireController: null == retireController - ? _value.retireController - : retireController // ignore: cast_nullable_to_non_nullable - as TimeOfDay, - mealTimeController: freezed == mealTimeController - ? _value.mealTimeController - : mealTimeController // ignore: cast_nullable_to_non_nullable - as TimeOfDay?, - commentController: null == commentController - ? _value.commentController - : commentController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - product_nameController: null == product_nameController - ? _value.product_nameController - : product_nameController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - productQuantityController: null == productQuantityController - ? _value.productQuantityController - : productQuantityController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - caloriesController: null == caloriesController - ? _value.caloriesController - : caloriesController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - fatsController: null == fatsController - ? _value.fatsController - : fatsController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - proteinsController: null == proteinsController - ? _value.proteinsController - : proteinsController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - carbsController: null == carbsController - ? _value.carbsController - : carbsController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - selectedMood: null == selectedMood - ? _value.selectedMood - : selectedMood // ignore: cast_nullable_to_non_nullable - as int, - selectedSatiety: null == selectedSatiety - ? _value.selectedSatiety - : selectedSatiety // ignore: cast_nullable_to_non_nullable - as int, - wakeupExpanded: null == wakeupExpanded - ? _value.wakeupExpanded - : wakeupExpanded // ignore: cast_nullable_to_non_nullable - as bool, - moderationExpanded: null == moderationExpanded - ? _value.moderationExpanded - : moderationExpanded // ignore: cast_nullable_to_non_nullable - as bool, - moodExpanded: null == moodExpanded - ? _value.moodExpanded - : moodExpanded // ignore: cast_nullable_to_non_nullable - as bool, - isLoading: null == isLoading - ? _value.isLoading - : isLoading // ignore: cast_nullable_to_non_nullable - as bool, - isAdded: null == isAdded - ? _value.isAdded - : isAdded // ignore: cast_nullable_to_non_nullable - as bool, - chartDataCounted: freezed == chartDataCounted - ? _value._chartDataCounted - : chartDataCounted // ignore: cast_nullable_to_non_nullable - as List?, - )); - } - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $DiaryModelCopyWith<$Res> get diary { - return $DiaryModelCopyWith<$Res>(_value.diary, (value) { - return _then(_value.copyWith(diary: value)); - }); - } - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $MealCopyWith<$Res> get currentMeal { - return $MealCopyWith<$Res>(_value.currentMeal, (value) { - return _then(_value.copyWith(currentMeal: value)); - }); - } - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $SelectionPopupModelCopyWith<$Res> get portionController { - return $SelectionPopupModelCopyWith<$Res>(_value.portionController, - (value) { - return _then(_value.copyWith(portionController: value)); - }); - } -} - -/// @nodoc - -class _$DiaryStateLoadedImpl implements DiaryStateLoaded { - const _$DiaryStateLoadedImpl( - {required this.diary, - this.diaryDate, - required final List recommendedChartValues, - required final List consumedChartValues, - required final List portions, - required final List mealList, - required final List portionList, - required final List autocompleteList, - required final Map chartData, - required this.currentMeal, - required this.portionController, - required this.wakeupController, - required this.retireController, - this.mealTimeController, - required this.commentController, - required this.product_nameController, - required this.productQuantityController, - required this.caloriesController, - required this.fatsController, - required this.proteinsController, - required this.carbsController, - required this.selectedMood, - required this.selectedSatiety, - required this.wakeupExpanded, - required this.moderationExpanded, - required this.moodExpanded, - required this.isLoading, - required this.isAdded, - final List? chartDataCounted}) - : _recommendedChartValues = recommendedChartValues, - _consumedChartValues = consumedChartValues, - _portions = portions, - _mealList = mealList, - _portionList = portionList, - _autocompleteList = autocompleteList, - _chartData = chartData, - _chartDataCounted = chartDataCounted; - - @override - final DiaryModel diary; - @override - final String? diaryDate; - final List _recommendedChartValues; - @override - List get recommendedChartValues { - if (_recommendedChartValues is EqualUnmodifiableListView) - return _recommendedChartValues; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_recommendedChartValues); - } - - final List _consumedChartValues; - @override - List get consumedChartValues { - if (_consumedChartValues is EqualUnmodifiableListView) - return _consumedChartValues; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_consumedChartValues); - } - - final List _portions; - @override - List get portions { - if (_portions is EqualUnmodifiableListView) return _portions; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_portions); - } - - final List _mealList; - @override - List get mealList { - if (_mealList is EqualUnmodifiableListView) return _mealList; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_mealList); - } - - final List _portionList; - @override - List get portionList { - if (_portionList is EqualUnmodifiableListView) return _portionList; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_portionList); - } - - final List _autocompleteList; - @override - List get autocompleteList { - if (_autocompleteList is EqualUnmodifiableListView) - return _autocompleteList; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_autocompleteList); - } - - final Map _chartData; - @override - Map get chartData { - if (_chartData is EqualUnmodifiableMapView) return _chartData; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_chartData); - } - - @override - final Meal currentMeal; - @override - final SelectionPopupModel portionController; - @override - final TimeOfDay wakeupController; - @override - final TimeOfDay retireController; - @override - final TimeOfDay? mealTimeController; - @override - final TextEditingController commentController; - @override - final TextEditingController product_nameController; - @override - final TextEditingController productQuantityController; - @override - final TextEditingController caloriesController; - @override - final TextEditingController fatsController; - @override - final TextEditingController proteinsController; - @override - final TextEditingController carbsController; - @override - final int selectedMood; - @override - final int selectedSatiety; - @override - final bool wakeupExpanded; - @override - final bool moderationExpanded; - @override - final bool moodExpanded; - @override - final bool isLoading; - @override - final bool isAdded; - final List? _chartDataCounted; - @override - List? get chartDataCounted { - final value = _chartDataCounted; - if (value == null) return null; - if (_chartDataCounted is EqualUnmodifiableListView) - return _chartDataCounted; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); - } - - @override - String toString() { - return 'DiaryState.loaded(diary: $diary, diaryDate: $diaryDate, recommendedChartValues: $recommendedChartValues, consumedChartValues: $consumedChartValues, portions: $portions, mealList: $mealList, portionList: $portionList, autocompleteList: $autocompleteList, chartData: $chartData, currentMeal: $currentMeal, portionController: $portionController, wakeupController: $wakeupController, retireController: $retireController, mealTimeController: $mealTimeController, commentController: $commentController, product_nameController: $product_nameController, productQuantityController: $productQuantityController, caloriesController: $caloriesController, fatsController: $fatsController, proteinsController: $proteinsController, carbsController: $carbsController, selectedMood: $selectedMood, selectedSatiety: $selectedSatiety, wakeupExpanded: $wakeupExpanded, moderationExpanded: $moderationExpanded, moodExpanded: $moodExpanded, isLoading: $isLoading, isAdded: $isAdded, chartDataCounted: $chartDataCounted)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$DiaryStateLoadedImpl && - (identical(other.diary, diary) || other.diary == diary) && - (identical(other.diaryDate, diaryDate) || - other.diaryDate == diaryDate) && - const DeepCollectionEquality().equals( - other._recommendedChartValues, _recommendedChartValues) && - const DeepCollectionEquality() - .equals(other._consumedChartValues, _consumedChartValues) && - const DeepCollectionEquality().equals(other._portions, _portions) && - const DeepCollectionEquality().equals(other._mealList, _mealList) && - const DeepCollectionEquality() - .equals(other._portionList, _portionList) && - const DeepCollectionEquality() - .equals(other._autocompleteList, _autocompleteList) && - const DeepCollectionEquality() - .equals(other._chartData, _chartData) && - (identical(other.currentMeal, currentMeal) || - other.currentMeal == currentMeal) && - (identical(other.portionController, portionController) || - other.portionController == portionController) && - (identical(other.wakeupController, wakeupController) || - other.wakeupController == wakeupController) && - (identical(other.retireController, retireController) || - other.retireController == retireController) && - (identical(other.mealTimeController, mealTimeController) || - other.mealTimeController == mealTimeController) && - (identical(other.commentController, commentController) || - other.commentController == commentController) && - (identical(other.product_nameController, product_nameController) || - other.product_nameController == product_nameController) && - (identical(other.productQuantityController, - productQuantityController) || - other.productQuantityController == productQuantityController) && - (identical(other.caloriesController, caloriesController) || - other.caloriesController == caloriesController) && - (identical(other.fatsController, fatsController) || - other.fatsController == fatsController) && - (identical(other.proteinsController, proteinsController) || - other.proteinsController == proteinsController) && - (identical(other.carbsController, carbsController) || - other.carbsController == carbsController) && - (identical(other.selectedMood, selectedMood) || - other.selectedMood == selectedMood) && - (identical(other.selectedSatiety, selectedSatiety) || - other.selectedSatiety == selectedSatiety) && - (identical(other.wakeupExpanded, wakeupExpanded) || - other.wakeupExpanded == wakeupExpanded) && - (identical(other.moderationExpanded, moderationExpanded) || - other.moderationExpanded == moderationExpanded) && - (identical(other.moodExpanded, moodExpanded) || - other.moodExpanded == moodExpanded) && - (identical(other.isLoading, isLoading) || - other.isLoading == isLoading) && - (identical(other.isAdded, isAdded) || other.isAdded == isAdded) && - const DeepCollectionEquality() - .equals(other._chartDataCounted, _chartDataCounted)); - } - - @override - int get hashCode => Object.hashAll([ - runtimeType, - diary, - diaryDate, - const DeepCollectionEquality().hash(_recommendedChartValues), - const DeepCollectionEquality().hash(_consumedChartValues), - const DeepCollectionEquality().hash(_portions), - const DeepCollectionEquality().hash(_mealList), - const DeepCollectionEquality().hash(_portionList), - const DeepCollectionEquality().hash(_autocompleteList), - const DeepCollectionEquality().hash(_chartData), - currentMeal, - portionController, - wakeupController, - retireController, - mealTimeController, - commentController, - product_nameController, - productQuantityController, - caloriesController, - fatsController, - proteinsController, - carbsController, - selectedMood, - selectedSatiety, - wakeupExpanded, - moderationExpanded, - moodExpanded, - isLoading, - isAdded, - const DeepCollectionEquality().hash(_chartDataCounted) - ]); - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$DiaryStateLoadedImplCopyWith<_$DiaryStateLoadedImpl> get copyWith => - __$$DiaryStateLoadedImplCopyWithImpl<_$DiaryStateLoadedImpl>( - this, _$identity); - - @override - @optionalTypeArgs - TResult when( - TResult Function() $default, { - required TResult Function(int? id) loading, - required TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted) - loaded, - required TResult Function(String errorMessage) error, - }) { - return loaded( - diary, - diaryDate, - recommendedChartValues, - consumedChartValues, - portions, - mealList, - portionList, - autocompleteList, - chartData, - currentMeal, - portionController, - wakeupController, - retireController, - mealTimeController, - commentController, - product_nameController, - productQuantityController, - caloriesController, - fatsController, - proteinsController, - carbsController, - selectedMood, - selectedSatiety, - wakeupExpanded, - moderationExpanded, - moodExpanded, - isLoading, - isAdded, - chartDataCounted); - } - - @override - @optionalTypeArgs - TResult? whenOrNull( - TResult? Function()? $default, { - TResult? Function(int? id)? loading, - TResult? Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, - TResult? Function(String errorMessage)? error, - }) { - return loaded?.call( - diary, - diaryDate, - recommendedChartValues, - consumedChartValues, - portions, - mealList, - portionList, - autocompleteList, - chartData, - currentMeal, - portionController, - wakeupController, - retireController, - mealTimeController, - commentController, - product_nameController, - productQuantityController, - caloriesController, - fatsController, - proteinsController, - carbsController, - selectedMood, - selectedSatiety, - wakeupExpanded, - moderationExpanded, - moodExpanded, - isLoading, - isAdded, - chartDataCounted); - } - - @override - @optionalTypeArgs - TResult maybeWhen( - TResult Function()? $default, { - TResult Function(int? id)? loading, - TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, - TResult Function(String errorMessage)? error, - required TResult orElse(), - }) { - if (loaded != null) { - return loaded( - diary, - diaryDate, - recommendedChartValues, - consumedChartValues, - portions, - mealList, - portionList, - autocompleteList, - chartData, - currentMeal, - portionController, - wakeupController, - retireController, - mealTimeController, - commentController, - product_nameController, - productQuantityController, - caloriesController, - fatsController, - proteinsController, - carbsController, - selectedMood, - selectedSatiety, - wakeupExpanded, - moderationExpanded, - moodExpanded, - isLoading, - isAdded, - chartDataCounted); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map( - TResult Function(_DiaryState value) $default, { - required TResult Function(DiaryStateLoading value) loading, - required TResult Function(DiaryStateLoaded value) loaded, - required TResult Function(DiaryStateError value) error, - }) { - return loaded(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull( - TResult? Function(_DiaryState value)? $default, { - TResult? Function(DiaryStateLoading value)? loading, - TResult? Function(DiaryStateLoaded value)? loaded, - TResult? Function(DiaryStateError value)? error, - }) { - return loaded?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap( - TResult Function(_DiaryState value)? $default, { - TResult Function(DiaryStateLoading value)? loading, - TResult Function(DiaryStateLoaded value)? loaded, - TResult Function(DiaryStateError value)? error, - required TResult orElse(), - }) { - if (loaded != null) { - return loaded(this); - } - return orElse(); - } -} - -abstract class DiaryStateLoaded implements DiaryState { - const factory DiaryStateLoaded( - {required final DiaryModel diary, - final String? diaryDate, - required final List recommendedChartValues, - required final List consumedChartValues, - required final List portions, - required final List mealList, - required final List portionList, - required final List autocompleteList, - required final Map chartData, - required final Meal currentMeal, - required final SelectionPopupModel portionController, - required final TimeOfDay wakeupController, - required final TimeOfDay retireController, - final TimeOfDay? mealTimeController, - required final TextEditingController commentController, - required final TextEditingController product_nameController, - required final TextEditingController productQuantityController, - required final TextEditingController caloriesController, - required final TextEditingController fatsController, - required final TextEditingController proteinsController, - required final TextEditingController carbsController, - required final int selectedMood, - required final int selectedSatiety, - required final bool wakeupExpanded, - required final bool moderationExpanded, - required final bool moodExpanded, - required final bool isLoading, - required final bool isAdded, - final List? chartDataCounted}) = _$DiaryStateLoadedImpl; - - DiaryModel get diary; - String? get diaryDate; - List get recommendedChartValues; - List get consumedChartValues; - List get portions; - List get mealList; - List get portionList; - List get autocompleteList; - Map get chartData; - Meal get currentMeal; - SelectionPopupModel get portionController; - TimeOfDay get wakeupController; - TimeOfDay get retireController; - TimeOfDay? get mealTimeController; - TextEditingController get commentController; - TextEditingController get product_nameController; - TextEditingController get productQuantityController; - TextEditingController get caloriesController; - TextEditingController get fatsController; - TextEditingController get proteinsController; - TextEditingController get carbsController; - int get selectedMood; - int get selectedSatiety; - bool get wakeupExpanded; - bool get moderationExpanded; - bool get moodExpanded; - bool get isLoading; - bool get isAdded; - List? get chartDataCounted; - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$DiaryStateLoadedImplCopyWith<_$DiaryStateLoadedImpl> get copyWith => - throw _privateConstructorUsedError; + const factory DiaryStateLoading() = _$DiaryStateLoadingImpl; } /// @nodoc @@ -1522,39 +394,9 @@ class _$DiaryStateErrorImpl implements DiaryStateError { @optionalTypeArgs TResult when( TResult Function() $default, { - required TResult Function(int? id) loading, - required TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted) - loaded, + required TResult Function() loading, required TResult Function(String errorMessage) error, + required TResult Function(DiaryDayModel diary) loaded, }) { return error(errorMessage); } @@ -1563,39 +405,9 @@ class _$DiaryStateErrorImpl implements DiaryStateError { @optionalTypeArgs TResult? whenOrNull( TResult? Function()? $default, { - TResult? Function(int? id)? loading, - TResult? Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult? Function()? loading, TResult? Function(String errorMessage)? error, + TResult? Function(DiaryDayModel diary)? loaded, }) { return error?.call(errorMessage); } @@ -1604,39 +416,9 @@ class _$DiaryStateErrorImpl implements DiaryStateError { @optionalTypeArgs TResult maybeWhen( TResult Function()? $default, { - TResult Function(int? id)? loading, - TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult Function()? loading, TResult Function(String errorMessage)? error, + TResult Function(DiaryDayModel diary)? loaded, required TResult orElse(), }) { if (error != null) { @@ -1650,8 +432,8 @@ class _$DiaryStateErrorImpl implements DiaryStateError { TResult map( TResult Function(_DiaryState value) $default, { required TResult Function(DiaryStateLoading value) loading, - required TResult Function(DiaryStateLoaded value) loaded, required TResult Function(DiaryStateError value) error, + required TResult Function(DiaryStateLoaded value) loaded, }) { return error(this); } @@ -1661,8 +443,8 @@ class _$DiaryStateErrorImpl implements DiaryStateError { TResult? mapOrNull( TResult? Function(_DiaryState value)? $default, { TResult? Function(DiaryStateLoading value)? loading, - TResult? Function(DiaryStateLoaded value)? loaded, TResult? Function(DiaryStateError value)? error, + TResult? Function(DiaryStateLoaded value)? loaded, }) { return error?.call(this); } @@ -1672,8 +454,8 @@ class _$DiaryStateErrorImpl implements DiaryStateError { TResult maybeMap( TResult Function(_DiaryState value)? $default, { TResult Function(DiaryStateLoading value)? loading, - TResult Function(DiaryStateLoaded value)? loaded, TResult Function(DiaryStateError value)? error, + TResult Function(DiaryStateLoaded value)? loaded, required TResult orElse(), }) { if (error != null) { @@ -1695,3 +477,169 @@ abstract class DiaryStateError implements DiaryState { _$$DiaryStateErrorImplCopyWith<_$DiaryStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } + +/// @nodoc +abstract class _$$DiaryStateLoadedImplCopyWith<$Res> { + factory _$$DiaryStateLoadedImplCopyWith(_$DiaryStateLoadedImpl value, + $Res Function(_$DiaryStateLoadedImpl) then) = + __$$DiaryStateLoadedImplCopyWithImpl<$Res>; + @useResult + $Res call({DiaryDayModel diary}); + + $DiaryDayModelCopyWith<$Res> get diary; +} + +/// @nodoc +class __$$DiaryStateLoadedImplCopyWithImpl<$Res> + extends _$DiaryStateCopyWithImpl<$Res, _$DiaryStateLoadedImpl> + implements _$$DiaryStateLoadedImplCopyWith<$Res> { + __$$DiaryStateLoadedImplCopyWithImpl(_$DiaryStateLoadedImpl _value, + $Res Function(_$DiaryStateLoadedImpl) _then) + : super(_value, _then); + + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? diary = null, + }) { + return _then(_$DiaryStateLoadedImpl( + diary: null == diary + ? _value.diary + : diary // ignore: cast_nullable_to_non_nullable + as DiaryDayModel, + )); + } + + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $DiaryDayModelCopyWith<$Res> get diary { + return $DiaryDayModelCopyWith<$Res>(_value.diary, (value) { + return _then(_value.copyWith(diary: value)); + }); + } +} + +/// @nodoc + +class _$DiaryStateLoadedImpl implements DiaryStateLoaded { + const _$DiaryStateLoadedImpl({required this.diary}); + + @override + final DiaryDayModel diary; + + @override + String toString() { + return 'DiaryState.loaded(diary: $diary)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DiaryStateLoadedImpl && + (identical(other.diary, diary) || other.diary == diary)); + } + + @override + int get hashCode => Object.hash(runtimeType, diary); + + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DiaryStateLoadedImplCopyWith<_$DiaryStateLoadedImpl> get copyWith => + __$$DiaryStateLoadedImplCopyWithImpl<_$DiaryStateLoadedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(String errorMessage) error, + required TResult Function(DiaryDayModel diary) loaded, + }) { + return loaded(diary); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(String errorMessage)? error, + TResult? Function(DiaryDayModel diary)? loaded, + }) { + return loaded?.call(diary); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(String errorMessage)? error, + TResult Function(DiaryDayModel diary)? loaded, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(diary); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_DiaryState value) $default, { + required TResult Function(DiaryStateLoading value) loading, + required TResult Function(DiaryStateError value) error, + required TResult Function(DiaryStateLoaded value) loaded, + }) { + return loaded(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_DiaryState value)? $default, { + TResult? Function(DiaryStateLoading value)? loading, + TResult? Function(DiaryStateError value)? error, + TResult? Function(DiaryStateLoaded value)? loaded, + }) { + return loaded?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_DiaryState value)? $default, { + TResult Function(DiaryStateLoading value)? loading, + TResult Function(DiaryStateError value)? error, + TResult Function(DiaryStateLoaded value)? loaded, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(this); + } + return orElse(); + } +} + +abstract class DiaryStateLoaded implements DiaryState { + const factory DiaryStateLoaded({required final DiaryDayModel diary}) = + _$DiaryStateLoadedImpl; + + DiaryDayModel get diary; + + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DiaryStateLoadedImplCopyWith<_$DiaryStateLoadedImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/diary/presentation/pages/diary_recommendations_scree.dart b/lib/features/diary/presentation/pages/diary_recommendations_scree.dart deleted file mode 100644 index 53b20dee..00000000 --- a/lib/features/diary/presentation/pages/diary_recommendations_scree.dart +++ /dev/null @@ -1,115 +0,0 @@ -// ignore_for_file: unused_local_variable - -import 'package:eatvio_app/features/diary/models/portion.dart'; -import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart'; -import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_form_builder/flutter_form_builder.dart'; -import 'package:rive/rive.dart'; - -// ignore: must_be_immutable -class DiaryRecommendationsScreen extends StatelessWidget { - final String? diary_recommendationsID; - - const DiaryRecommendationsScreen({ - this.diary_recommendationsID, - super.key, - }); - - Widget build(BuildContext context) { - if (diary_recommendationsID != "0") { - context.read().add(LoadDiaryById(diary_recommendationsID)); - } - return BlocBuilder( - builder: (context, state) { - if (state is DiaryStateLoaded) { - return _buildDiaryRecommendations(context, state); - } else if (state is DiaryStateLoading) { - return Scaffold( - body: Center( - child: SizedBox( - height: 32, - width: 32, - child: RiveAnimation.asset( - 'assets/rive_animations/loading.riv', - ), - ), - ), - ); - } else if (state is DiaryStateError) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text(state.errorMessage), - ), - ), - ); - } else - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text("Неопределенная ошибка"), - ), - ), - ); - }, - ); - } - - Widget _buildDiaryRecommendations(BuildContext context, DiaryStateLoaded state) { - final Portion product = new Portion(id: 1, product_name: "", quantity: 1, portion: "", from_diet: true); - return Stack( - alignment: Alignment.bottomCenter, - children: [ - FormBuilder( - child: Scaffold( - appBar: AppBar( - toolbarHeight: 0, - automaticallyImplyLeading: false, - ), - backgroundColor: Color.fromARGB(255, 240, 242, 245), - resizeToAvoidBottomInset: true, - body: SizedBox( - width: double.maxFinite, - child: Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: EdgeInsets.only(bottom: 9), - child: Column( - children: [ - Scaffold( - appBar: AppBar( - title: Text(product.product_name), - ), - body: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('Название продукта: ${product.product_name}', style: TextStyle(fontSize: 24)), - SizedBox(height: 16), - Text('Количество: ${product.quantity} ${product.portion}', style: TextStyle(fontSize: 18)), - // Добавьте другие детали о продукте по необходимости - ], - ), - ), - ) - ], - ), - ), - ), - ), - ], - ), - ), - ), - ), - ], - ); - } -} diff --git a/lib/features/diary/presentation/pages/diary_screen.dart b/lib/features/diary/presentation/pages/diary_screen.dart index aaa06ad8..9a6dbf4e 100644 --- a/lib/features/diary/presentation/pages/diary_screen.dart +++ b/lib/features/diary/presentation/pages/diary_screen.dart @@ -1,1193 +1,306 @@ -import 'package:carousel_slider_plus/carousel_slider_plus.dart'; -import 'package:eatvio_app/core/const.dart'; -import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; -import 'package:eatvio_app/features/diary/models/diary_model.dart'; -import 'package:eatvio_app/features/diary/models/meal.dart'; -import 'package:eatvio_app/features/diary/models/photo.dart'; -import 'package:eatvio_app/features/diary/models/portion.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; -import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart'; +import 'package:eatvio_app/features/diary/models/diary_day_model.dart'; +import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart'; import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; import 'package:eatvio_app/locator_service.dart'; -import 'package:eatvio_app/theme/app_decoration.dart'; -import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; -import 'package:eatvio_app/widgets/custom_drop_down.dart'; -import 'package:eatvio_app/widgets/custom_scale_element.dart'; -import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_form_builder/flutter_form_builder.dart'; -import 'package:image_picker/image_picker.dart'; -import 'package:rive/rive.dart' as rive; -import 'package:syncfusion_flutter_charts/charts.dart'; +import 'package:rive/rive.dart'; +import 'package:table_calendar/table_calendar.dart'; -class DiaryScreen extends StatelessWidget { - final String? diaryID; +class DiaryScreen extends StatefulWidget { + const DiaryScreen({super.key}); - const DiaryScreen({ - this.diaryID, - super.key, - }); + @override + State createState() => _DiaryScreenState(); +} +class _DiaryScreenState extends State { + final DiaryCubit diaryCubit = sl(); + CalendarFormat _calendarFormat = CalendarFormat.month; + DateTime _focusedDay = DateTime.now(); + DateTime? _selectedDay = DateTime.now(); + int currentSelectedMealNumber = 1; + + @override Widget build(BuildContext context) { - if (diaryID != "0") { - context.read().add(LoadDiaryById(diaryID)); - } - return BlocProvider( - create: (context) => sl()..add(LoadDiary()), - child: BlocBuilder( - builder: (context, state) { + return BlocProvider( + create: (BuildContext context) => diaryCubit..getDiaryDay(_selectedDay!.toString()), + child: BlocConsumer( + listener: (BuildContext context, DiaryState state) { if (state is DiaryStateLoaded) { - return _buildDiary(context, state); - } else if (state is DiaryStateLoading) { - return Scaffold( - body: Center( - child: SizedBox( - height: 32, - width: 32, - child: rive.RiveAnimation.asset( - 'assets/rive_animations/loading.riv', - ), - ), + setState(() { + _calendarFormat = CalendarFormat.week; + }); + } + }, + builder: (BuildContext context, DiaryState state) { + return Scaffold( + backgroundColor: Colors.grey.shade200, + appBar: AppBar( + toolbarHeight: 0, + ), + body: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + child: Column( + children: [ + _calendar(state), + if (state is DiaryStateLoading) _loader(), + if (state is DiaryStateLoaded) _meals(state.diary), + ], ), - ); - } else if (state is DiaryStateError) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text(state.errorMessage), - ), - ), - ); - } else - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text("Неопределенная ошибка"), - ), - ), - ); + ), + ); }, ), ); } - Widget _buildDiary(BuildContext context, DiaryStateLoaded state) { - return RefreshIndicator( - onRefresh: refreshPage(context), - child: Stack( - alignment: Alignment.bottomCenter, - children: [ - FormBuilder( - child: Scaffold( - appBar: AppBar( - toolbarHeight: 0, - automaticallyImplyLeading: false, - ), - backgroundColor: Color.fromARGB(255, 240, 242, 245), - resizeToAvoidBottomInset: true, - body: SizedBox( - width: double.maxFinite, - child: Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: EdgeInsets.only(bottom: 8), - child: Column( - children: [ - _buildHeaderRow(context, state), - SizedBox(height: 8), - _buildWakupRetire(context, state), - SizedBox(height: 8), - _buildMeal(context, state), - SizedBox(height: 8), - _buildMood(context, state), - SizedBox(height: 8), - _buildNutritionChart(context, state), - SizedBox(height: 8), - // _buildComment(context, state), - // SizedBox(height: 8.v), - _buildEndDay(context), - ], - ), - ), - ), - ), - ], - ), - ), - ), - ), - ], - ), - ); - } - - _buildNutritionChart(BuildContext context, DiaryStateLoaded state) { - return Container( - padding: EdgeInsets.symmetric( - horizontal: 24, - vertical: 12, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(8)), - ), - child: Column( - children: [ - Text( - "Ваш КБЖУ", - style: theme.textTheme.titleMedium, - textAlign: TextAlign.center, - ), - Text( - "от дневной суточной нормы", - ), - Transform.rotate( - angle: -1.5708, - child: ClipRect( - child: Align( - alignment: Alignment.centerRight, - widthFactor: 0.5, - child: SfCircularChart( - series: [ - RadialBarSeries( - dataSource: state.chartDataCounted, - xValueMapper: (NutritionData data, _) => data.category, - yValueMapper: (NutritionData data, _) => data.nutrition, - pointColorMapper: (NutritionData data, _) => data.color, - trackColor: Color.fromRGBO(59, 130, 246, 1), - trackOpacity: 0.1, - gap: "8%", - radius: "110%", - innerRadius: '20%', // Измените значение по вашему усмотрению - ) - ], - ), - ), - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(style: theme.textTheme.titleMedium, 'Углеводы'), - Text(style: theme.textTheme.titleMedium, 'Жиры'), - Text(style: theme.textTheme.titleMedium, 'Белки'), - Text(style: theme.textTheme.titleMedium, 'Калории'), - ], - ), - Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - '${state.chartData['dailyNutritionIntake']['carbohydrates'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['carbohydrates'].toStringAsFixed(1)} грамм'), - SizedBox(height: 8), - Text( - '${state.chartData['dailyNutritionIntake']['fats'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['fats'].toStringAsFixed(1)} грамм'), - SizedBox(height: 8), - Text( - '${state.chartData['dailyNutritionIntake']['proteins'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['proteins'].toStringAsFixed(1)} грамм'), - SizedBox(height: 8), - Text( - '${state.chartData['dailyNutritionIntake']['energy'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['energy'].toStringAsFixed(1)} Ккал'), - ], - ), - ], - ), - ], - ), - ); - } - - _buildEndDay(BuildContext context) { - return Container( - height: 48, - width: MediaQuery.of(context).size.width, - padding: EdgeInsets.only(left: 4, right: 4), - child: FloatingActionButton.extended( - heroTag: 'endDayButton', - highlightElevation: 0, - elevation: 0, - focusElevation: 0, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), - ), - backgroundColor: appTheme.blueA400, - onPressed: () => onFinishDayPressed, - label: Text( - 'Закончить день', - style: theme.textTheme.titleSmall, - ), - ), - ); - } - - refreshPage(BuildContext context) { - return () async { - context.read().add(RefreshEvent()); - }; - } - - /// Section Widget - _buildHeaderRow(BuildContext context, DiaryStateLoaded state) { - final day = state.diary.id; - return Container( - padding: EdgeInsets.symmetric( - horizontal: 24, - vertical: 12, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(8)), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: EdgeInsets.only(top: 4), - child: Column( - children: [ - Align( - alignment: Alignment.centerRight, - child: Text( - "$day день", - style: CustomTextStyles.titleMediumBlack, - ), - ), - ], - ), - ), - ], - ), - ); - } - - /// Section Widget - _buildAddProduct(BuildContext context, DiaryState state) { - return Container( - height: 48, - width: MediaQuery.of(context).size.width, - padding: EdgeInsets.only(left: 4, right: 4), - child: FloatingActionButton.extended( - heroTag: 'addProduct', - highlightElevation: 0, - elevation: 0, - focusElevation: 0, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), - ), - backgroundColor: appTheme.blueA400, - onPressed: () => addProduct(context), - label: Text( - 'Добавить продукт', - style: theme.textTheme.titleSmall, - ), - ), - ); - } - - addProduct(BuildContext context) { - context.read().add(AddPortionEvent()); - } - - /// Section Widget - _buildAddPhoto(BuildContext context, DiaryStateLoaded state) { - bool isLoading = state.isLoading; - if (state.currentMeal.photos.isEmpty) - return GestureDetector( - onTap: addImage(context, isLoading), - child: Stack( - children: [ - if (!isLoading) - Container( - margin: EdgeInsets.symmetric(horizontal: 12), - padding: EdgeInsets.symmetric( - horizontal: 32, - vertical: 64, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: EdgeInsets.only( - left: 8, - top: 8, - ), - child: Text( - "Добавить фото", - selectionColor: appTheme.blueA400, - ), - ), - Spacer(), - Icon( - Icons.photo_library, - color: appTheme.blueGray300, - ), - ], - ), - ), - if (isLoading) - Container( - margin: EdgeInsets.symmetric(horizontal: 12), - padding: EdgeInsets.symmetric( - horizontal: 32, - vertical: 64, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Center( - child: SizedBox( - height: 32, - width: 32, - child: rive.RiveAnimation.asset( - 'assets/rive_animations/loading.riv', - ), - ), - ), - ), - ], - ), - ); - else - return Container(); - } - - addImage(BuildContext context, bool isLoading) { - if (!isLoading) { - return () async { - final picker = ImagePicker(); - List? images = await picker.pickMultiImage(); - if (images.isNotEmpty) { - for (var image in images) { - context.read().add(UploadImages(image)); + _arrowDown() { + return GestureDetector( + onTapDown: (_) { + setState(() { + if (_calendarFormat == CalendarFormat.week) { + _calendarFormat = CalendarFormat.month; + } else { + _calendarFormat = CalendarFormat.week; } - } - }; - } - } - - _buildMeal(BuildContext context, DiaryStateLoaded state) { - final digitsOnly = FilteringTextInputFormatter.digitsOnly; - List _options = state.autocompleteList.map((Product item) => item.name).toList(); - return Container( - padding: EdgeInsets.symmetric( - horizontal: 24, - vertical: 12, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(8)), - ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Время приема пищи", - style: CustomTextStyles.bodyMediumBlack900, - ), - Expanded( - // Adding Expanded widget - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: ConstrainedBox( - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width - 260, - ), - child: GestureDetector( - onTap: () => _selectMealTime(context, state), - child: AbsorbPointer( - child: CustomTextFormField( - hintText: state.mealTimeController?.format(context).toString(), - autofocus: false, - ), - ), - ), - ), - ), - ), - ], - ), - ), - SizedBox(height: 24), - Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: BlocSelector( - selector: (state) { - if (state is DiaryStateLoaded) - return state.diary; - else - return null; - }, - builder: (context, diary) { - return CustomDropDown( - items: state.mealList, - contentPadding: EdgeInsets.symmetric( - horizontal: 12, - vertical: 12, - ), - // defaultValue: state.mealList[0], - onChanged: changeMeal(context, state), - ); - }, - ), - ), - SizedBox(height: 24), - Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: RawAutocomplete( - optionsBuilder: buildOptions(_options), - fieldViewBuilder: ( - BuildContext context, - TextEditingController productEditingController, - FocusNode focusNodeName, - VoidCallback onFieldSubmitted, - ) { - if (state.isAdded) { - print("Clear"); - } - return CustomTextFormField( - hintText: "Введите название продукта", - controller: productEditingController, - focusNode: focusNodeName, - onChanged: getAutocomplete(context, focusNodeName), - ); - }, - optionsViewBuilder: ( - BuildContext context, - AutocompleteOnSelected onSelected, - Iterable options, - ) { - return Align( - alignment: Alignment.topLeft, - child: Material( - elevation: 4.0, - child: SizedBox( - height: 200.0, - child: ListView.builder( - padding: const EdgeInsets.all(8.0), - itemCount: options.length, - itemBuilder: (BuildContext context, int index) { - final String option = options.elementAt(index); - return GestureDetector( - onTap: selectProduct(onSelected, option, state), - child: ListTile( - title: Text(option), - ), - ); - }, - ), - ), - ), - ); - }, - ), - ), - SizedBox(height: 24), - if (state.moderationExpanded) - Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: GestureDetector( - onTap: () => openCaloriesDialog(context, state), - child: Text("Отправить на модерацию"), - ), - ), - SizedBox(height: 24), - Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - CustomTextFormField( - width: 128, - hintText: "Кол-во", - textInputAction: TextInputAction.done, - // focusNode: focusNodeQuantity, - controller: state.productQuantityController, - keyboardType: TextInputType.number, - inputFormatters: [digitsOnly], - ), - Padding( - padding: EdgeInsets.only(left: 32), - child: BlocSelector( - selector: (state) { - if (state is DiaryStateLoaded) { - return state.diary; - } else - return null; - }, - builder: (context, diary) { - return CustomDropDown( - items: state.portionList, - // defaultValue: state.portionController, - onChanged: changePortion(context, state), - ); - }, - ), - ), - ], - ), - ), - ), - SizedBox(height: 24), - _buildAddProduct(context, state), - SizedBox(height: 24), - if (!state.diary.state.has_chosen_diet) ...state.portions.map((portion) => _buildProduct(context, portion)).toList(), - if (state.diary.state.has_chosen_diet) ...state.portions.map((portion) => _buildProductDiet(context, portion)).toList(), - SizedBox(height: 24), - _buildCarousel(context, state), - SizedBox(height: 24), - _buildAddPhoto(context, state), - SizedBox(height: 24), - Text( - "Ваша сытость после приёма пищи", - style: CustomTextStyles.bodyMediumBlack900, - ), - SizedBox(height: 16), - BlocBuilder( - builder: (context, state) { - if (state is DiaryStateLoaded) { - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text("😭"), - ScaleElement( - color: Colors.red, - isSelected: state.selectedSatiety == 0, - onTap: changeSatiety(context, 0), - ), - ScaleElement( - color: Colors.orange, - isSelected: state.selectedSatiety == 1, - onTap: changeSatiety(context, 1), - ), - ScaleElement( - color: Colors.yellow, - isSelected: state.selectedSatiety == 2, - onTap: changeSatiety(context, 2), - ), - ScaleElement( - color: Colors.lime, - isSelected: state.selectedSatiety == 3, - onTap: changeSatiety(context, 3), - ), - ScaleElement( - color: Colors.lightGreen, - isSelected: state.selectedSatiety == 4, - onTap: changeSatiety(context, 4), - ), - ScaleElement( - color: Colors.green, - isSelected: state.selectedSatiety == 5, - onTap: changeSatiety(context, 5), - ), - Text("😊"), - // Остальные элементы шкалы - ], - ); - } else { - return Container(); // Возвращаем пустой контейнер, если состояние не является DiaryState - } - }, - ), - ], - ), - ); - } - - openCaloriesDialog(BuildContext context, DiaryStateLoaded state) { - showDialog( - context: context, - builder: (BuildContext dialogContext) { - return AlertDialog( - title: Text('Введите информацию о продукте'), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - CustomTextFormField( - hintText: "Название", - controller: state.product_nameController, - ), - SizedBox(height: 12), - CustomTextFormField( - hintText: "Энергетическая ценность на 100", - keyboardType: TextInputType.number, - controller: state.caloriesController, - ), - SizedBox(height: 12), - CustomTextFormField( - hintText: "Белки на 100г", - keyboardType: TextInputType.number, - controller: state.proteinsController, - ), - SizedBox(height: 12), - CustomTextFormField( - hintText: "Жиры на 100г", - keyboardType: TextInputType.number, - controller: state.fatsController, - ), - SizedBox(height: 12), - CustomTextFormField( - hintText: "Углеводы на 100г", - keyboardType: TextInputType.number, - controller: state.carbsController, - ), - ], - ), - actions: [ - TextButton( - onPressed: popDialog(context), - child: Text('Отмена'), - ), - TextButton( - onPressed: triggerModeration( - context, - state.product_nameController.text, - state.caloriesController.text, - state.proteinsController.text, - state.fatsController.text, - state.carbsController.text, - dialogContext, - ), - child: Text('Отправить'), - ), - ], - ); + }); }, + child: Container( + padding: const EdgeInsets.only(top: 8, bottom: 16), + width: double.infinity, + child: Icon( + _calendarFormat == CalendarFormat.month ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded, + color: Colors.grey.shade600, + ), + ), ); } - triggerModeration( - BuildContext context, - String name, - String energyOn100gr, - String proteinsOn100gr, - String fatsOn100gr, - String carbohydratesOn100gr, - BuildContext dialogContext, - ) { - return () { - context.read().add( - SendModeration( - name: name, - energyOn100gr: energyOn100gr, - proteinsOn100gr: proteinsOn100gr, - fatsOn100gr: fatsOn100gr, - carbohydratesOn100gr: carbohydratesOn100gr, - ), - ); - Navigator.of(dialogContext).pop(); - }; - } - - popDialog(BuildContext dialogContext) { - return () { - Navigator.of(dialogContext).pop(); // Dismiss the dialog on Cancel button press - }; - } - - changeSatiety(BuildContext context, int satiety) { - return () { - context.read().add(ChangeSatiety(satiety)); - }; - } - - selectProduct(AutocompleteOnSelected onSelected, String option, DiaryStateLoaded state) { - state.product_nameController.text = option; - return () { - onSelected(option); - }; - } - - getAutocomplete(BuildContext context, FocusNode focusNode) { - return (value) { - if (value.length > 2) { - context.read().add(ProductInput(value)); - } - }; - } - - buildOptions(List _options) { - return (TextEditingValue textEditingValue) { - return _options.where((String option) { - return true; - }); - }; - } - - changeMeal(BuildContext context, DiaryStateLoaded state) { - return (value) { - context.read().add(ChangeMeal(value: value)); - }; - } - - changePortion(BuildContext context, DiaryStateLoaded state) { - return (value) { - context.read().add(ChangePortion(value: value)); - }; - } - - _buildCarousel(BuildContext context, DiaryStateLoaded state) { - if (state.currentMeal.photos.isEmpty) { - return Text("Фото нет"); - } else { - return CarouselSlider( - options: CarouselOptions(height: 200.0), - items: state.currentMeal.photos.map((photo) { - return _buildPhoto(context, photo, state); - }).toList(), - ); - } - } - - _buildProduct(BuildContext context, Portion portion) { + _divider(BuildContext context) { return Container( - margin: EdgeInsets.symmetric(horizontal: 12), - padding: EdgeInsets.symmetric( - horizontal: 8, - vertical: 8, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: EdgeInsets.only( - left: 8, - top: 8, - ), - child: Text( - portion.product_name.length > 8 ? portion.product_name.substring(0, 8) : portion.product_name, - style: CustomTextStyles.titleMedium16, - ), - ), - Padding( - padding: EdgeInsets.only( - left: 24, - top: 4, - bottom: 4, - ), - child: Text( - portion.quantity.toString() + ' ' + portion.portion.toString(), - ), - ), - Spacer(), - GestureDetector( - onTap: () => removePortion(context, portion), - child: Padding( - padding: const EdgeInsets.only(right: 10), - child: Icon( - Icons.close, - color: appTheme.blueGray300, - ), - ), - ), - ], + height: 0.4, + width: MediaQuery.of(context).size.width - 32, + decoration: BoxDecoration( + color: Colors.black26, + borderRadius: BorderRadius.circular(16), ), ); } - _buildProductDiet(BuildContext context, Portion portion) { - return Container( - margin: EdgeInsets.symmetric( - horizontal: 12, - vertical: 4, - ), - padding: EdgeInsets.symmetric( - horizontal: 8, - vertical: 8, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - Checkbox( - value: !portion.from_diet, - onChanged: (bool? value) => context.read().add(ConfirmPortion(portion.id)), - ), - Padding( - padding: EdgeInsets.only( - left: 8, - top: 8, - ), - child: Text( - portion.product_name.length > 18 ? portion.product_name.substring(0, 18) : portion.product_name, - style: CustomTextStyles.titleMedium16, - ), - ), - Spacer(), - Padding( - padding: EdgeInsets.only( - left: 24, - top: 4, - bottom: 4, - ), - child: Text( - portion.quantity.toString() + ' ' + portion.portion.toString(), - ), - ), - ], - ), - ); - } - - _buildPhoto(BuildContext context, Photo photo, DiaryStateLoaded state) { - return Stack( + _products(List portions) { + return Column( + mainAxisSize: MainAxisSize.min, children: [ - Container( - margin: EdgeInsets.symmetric(horizontal: 12, vertical: 12), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, + for (int i = 0; i < portions.length; i++) ...[ + _product( + portions[i].productName, + portions[i].quantity, ), - child: Image.network( - baseUrl + '/storage/' + photo.path, - fit: BoxFit.cover, // Чтобы изображение занимало весь контейнер - ), - ), - Positioned( - bottom: 0, - left: 0, - right: 0, - child: Container( - height: 64, // Высота затемненной области - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - Colors.black.withOpacity(0.7), // Цвет затемнения - Colors.transparent, - ], - begin: Alignment.bottomCenter, - end: Alignment.topCenter, - ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - IconButton( - icon: Icon(Icons.photo_outlined), - color: Colors.white, - onPressed: addImage(context, state.isLoading), - ), - IconButton( - icon: Icon(Icons.delete_outlined), - color: Colors.white, - onPressed: removePhoto(context, photo), - ), - ], - ), - ), - ), + i < portions.length - 1 ? const SizedBox(height: 8) : const SizedBox.shrink(), + ], ], ); } - removePortion(BuildContext context, Portion portion) { - return () { - context.read().add(RemovePortionEvent(portion.id)); - }; - } - - removePhoto(BuildContext context, Photo photo) { - return () { - context.read().add(RemoveImageEvent(photo.id.toString(), photo.path)); - }; - } - - /* _buildComment(BuildContext context, DiaryStateLoaded state) { - return Container( - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(8)), - ), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Дополнительная информация для консультанта", - style: theme.textTheme.titleMedium, - textAlign: TextAlign.center, - ), - SizedBox(height: 20.v), - Container( - width: 320.h, - child: CustomTextFormField( - autofocus: false, - hintText: "Введите информацию для консультанта", - maxLines: 7, - borderDecoration: InputBorder.none, - controller: state.commentController, - ), - ), - ], - ), - ); - } */ - - _buildWakupRetire(BuildContext context, DiaryStateLoaded state) { - return Container( - padding: EdgeInsets.symmetric( - horizontal: 24, - vertical: 12, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(8)), - ), - child: Column( - children: [ - GestureDetector( - onTap: toggleWakeup(context), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - r"Подъем \ отход ко сну", - style: CustomTextStyles.bodyMediumBlack900, - ), - Icon(state.wakeupExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), - ], - ), - ), - if (state.wakeupExpanded) - Padding( - padding: const EdgeInsets.only(left: 16.0), - child: Column( - children: [ - SizedBox(height: 24), - GestureDetector( - onTap: () => _selectWakeupTime(context, state), - child: AbsorbPointer( - child: CustomTextFormField( - hintText: state.wakeupController.format(context).toString(), - prefix: Icon(Icons.sunny), - autofocus: false, - ), - ), - ), - SizedBox(height: 24), - GestureDetector( - onTap: () => _selectRetireTime(context, state), - child: AbsorbPointer( - child: CustomTextFormField( - hintText: state.retireController.format(context).toString(), - prefix: Icon(Icons.bed), - autofocus: false, - ), - ), - ), - SizedBox(height: 24), - ], - ), - ), - ], + _product(String product, int portion) { + return ListTile( + onTap: () {}, + trailing: Icon(Icons.more_vert_rounded), + title: Text(product), + subtitle: Text('$portion г'), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), ), + tileColor: Color(0xFFF6FAFF), ); } - toggleWakeup(BuildContext context) { - return () { - BlocProvider.of(context).add(ToggleWakeupExpandedEvent()); - }; - } - - /// Section Widget - - Function() onFinishDayPressed(BuildContext context) { - return () { - showDialog( - context: context, - builder: (BuildContext dialogContext) { - return AlertDialog( - title: Text("Подтвердите действие"), - content: Text("Вы уверены, что хотите завершить день?"), - actions: [ - TextButton( - child: Text("Отмена"), - onPressed: closeDialog(dialogContext), + _meals(DiaryDayModel diaryDay) { + return Material( + borderRadius: BorderRadius.circular(20), + color: Colors.white, + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Прием пищи', + style: TextStyle( + color: Color(0xFF323F4B), + fontSize: 18, + fontWeight: FontWeight.w500, ), - TextButton( - child: Text("Подтвердить"), - onPressed: sendFinishDayData(dialogContext, context), - ), - ], - ); - }, - ); - }; - } - - Function() sendFinishDayData(BuildContext dialogContext, BuildContext context) { - return () { - closeDialog(dialogContext); - context.read().add(FinishDay()); - }; - } - - Function() closeDialog(BuildContext dialogContext) { - return () { - Navigator.of(dialogContext).pop(); - }; - } - - _buildMood(BuildContext context, DiaryStateLoaded state) { - return Container( - padding: EdgeInsets.symmetric( - horizontal: 24, - vertical: 12, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(8)), - ), - child: Column( - children: [ - GestureDetector( - onTap: toggleMood(context), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Ваше настроение после приема пищи", - style: CustomTextStyles.bodyMediumBlack900, - ), - Icon(state.moodExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), - ], ), - ), - if (state.moodExpanded) + const SizedBox(height: 16), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text("😭"), - ScaleElement( - color: Colors.red, - isSelected: state.selectedMood == 0, - onTap: changeMood(context, 0), - ), - ScaleElement( - color: Colors.orange, - isSelected: state.selectedMood == 1, - onTap: changeMood(context, 1), - ), - ScaleElement( - color: Colors.yellow, - isSelected: state.selectedMood == 2, - onTap: changeMood(context, 2), - ), - ScaleElement( - color: Colors.lime, - isSelected: state.selectedMood == 3, - onTap: changeMood(context, 3), - ), - ScaleElement( - color: Colors.lightGreen, - isSelected: state.selectedMood == 4, - onTap: changeMood(context, 4), - ), - ScaleElement( - color: Colors.green, - isSelected: state.selectedMood == 5, - onTap: changeMood(context, 5), - ), - Text("😊"), - // Остальные элементы шкалы + _mealButton(1), + _mealButton(2), + _mealButton(3), + _mealButton(4), + _mealButton(5), ], ), - ], + const SizedBox(height: 12), + _divider(context), + const SizedBox(height: 12), + Text( + 'Время приема пищи', + style: TextStyle( + color: Color(0xFF323F4B), + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 12), + _divider(context), + const SizedBox(height: 12), + _products(diaryDay.meals[currentSelectedMealNumber - 1].portions), + const SizedBox(height: 16), + _addProductButton(), + ], + ), ), ); } - changeMood(BuildContext context, int satiety) { - return () { - context.read().add(ChangeMood(satiety)); - }; - } + _mealButton(int mealNumber) { + bool isActive = currentSelectedMealNumber == mealNumber; - toggleMood(BuildContext context) { - return () { - BlocProvider.of(context).add(ToggleMoodExpandedEvent()); - }; - } - - Future _selectWakeupTime(BuildContext context, DiaryStateLoaded state) async { - final TimeOfDay? pickedTime = await showTimePicker( - context: context, - initialTime: state.wakeupController, + return InkWell( + onTap: () { + setState(() { + if (currentSelectedMealNumber == mealNumber) return; + currentSelectedMealNumber = mealNumber; + }); + }, + borderRadius: BorderRadius.circular(100), + child: Ink( + width: MediaQuery.of(context).size.width / 5 - (96 / 5), + height: 32, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(100), + color: isActive ? appTheme.blueA400 : Color(0xFFF1F2F6), + ), + child: Center( + child: Text( + '$mealNumber', + style: TextStyle( + color: isActive ? Colors.white : Colors.black, + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + ), + ), ); - if (pickedTime != null && pickedTime != state.wakeupController) { - context.read().add(WakeupEvent(pickedTime)); - } } - Future _selectRetireTime(BuildContext context, DiaryStateLoaded state) async { - final TimeOfDay? pickedTime = await showTimePicker( - context: context, - initialTime: state.retireController, + _loader() { + return Center( + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ); - if (pickedTime != null && pickedTime != state.retireController) { - context.read().add(RetireEvent(pickedTime)); - } } - Future _selectMealTime(BuildContext context, DiaryStateLoaded state) async { - final TimeOfDay? pickedTime = await showTimePicker( - context: context, - initialTime: state.mealTimeController ?? TimeOfDay.now(), + _calendar(DiaryState state) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: const EdgeInsets.only(top: 16), + child: TableCalendar( + firstDay: DateTime.utc(2010, 10, 16), + lastDay: DateTime.utc(2030, 3, 14), + locale: 'ru_RU', + startingDayOfWeek: StartingDayOfWeek.monday, + focusedDay: _focusedDay, + calendarFormat: _calendarFormat, + headerStyle: HeaderStyle( + titleCentered: true, + formatButtonVisible: false, + leftChevronVisible: false, + rightChevronVisible: false, + ), + selectedDayPredicate: (day) { + return isSameDay(_selectedDay, day); + }, + onDaySelected: (selectedDay, focusedDay) { + if (state is! DiaryStateLoaded) return; + if (!isSameDay(_selectedDay, selectedDay)) { + setState(() { + _selectedDay = selectedDay; + _focusedDay = focusedDay; + }); + diaryCubit.getDiaryDay(_selectedDay!.toString()); + } + }, + onFormatChanged: (format) { + if (_calendarFormat != format) { + setState(() { + _calendarFormat = format; + }); + } + }, + onPageChanged: (focusedDay) { + _focusedDay = focusedDay; + }, + calendarStyle: CalendarStyle( + selectedDecoration: BoxDecoration( + color: appTheme.blueA400, + shape: BoxShape.circle, + ), + todayTextStyle: TextStyle( + color: Colors.black, + ), + todayDecoration: BoxDecoration( + border: Border.all( + color: appTheme.blueA400, + width: 2, + ), + shape: BoxShape.circle, + ), + ), + ), + ), + _arrowDown(), + ], + ); + } + + _addProductButton() { + return InkWell( + onTap: () {}, + borderRadius: BorderRadius.circular(20), + child: Ink( + padding: EdgeInsets.symmetric(horizontal: 16), + width: MediaQuery.of(context).size.width - 32, + decoration: BoxDecoration( + color: appTheme.blueA400, + borderRadius: BorderRadius.circular(20), + ), + child: Container( + padding: EdgeInsets.all(16), + alignment: Alignment.center, + child: Text( + 'Добавить', + style: TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.w600, + ), + ), + ), + ), ); - if (pickedTime != null && pickedTime != state.mealTimeController) { - context.read().add(ChangeMealTime(pickedTime)); - } } } - -bool checkConsumedValues(List recommendedValues, List consumedValues) { - for (int i = 0; i < recommendedValues.length; i++) { - if (consumedValues[i] > recommendedValues[i]) { - // Если хотя бы одно потребленное значение превышает рекомендованное - return true; // Возвращаем false - } - } - // Если ни одно потребленное значение не превышает рекомендованное с соответствующим индексом - return false; // Возвращаем true -} - -List mealsToDropdown(List? meals) { - return meals! - .map((meal) => SelectionPopupModel( - id: meal.id, - title: "Прием пищи ${meal.type}", - isSelected: false, - )) - .toList(); -} diff --git a/lib/features/diary/repositories/diary_repository.dart b/lib/features/diary/repositories/diary_repository.dart index 04a8cad0..c11d5c0f 100644 --- a/lib/features/diary/repositories/diary_repository.dart +++ b/lib/features/diary/repositories/diary_repository.dart @@ -1,200 +1,21 @@ -import 'dart:io'; - -import 'package:eatvio_app/features/diary/models/diary_model.dart'; -import 'package:eatvio_app/features/diary/models/portion.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/diary/models/diary_day_model.dart'; import 'package:eatvio_app/features/diary/services/diary_service.dart'; class DiaryRepository { final DiaryService diaryService; - DiaryRepository({required this.diaryService}); + DiaryRepository({ + required this.diaryService, + }); - Future> getDiaryID() async { - try { - return await diaryService.getDiaryID(); - } catch (e) { - rethrow; - } + Future getDiaryByDate(String date) async { + print(await _getDiaryIndexByDate(date)); + return (await diaryService.getDiaryDay( + index: await _getDiaryIndexByDate(date), + )).diary; } - Future getDiary(int diaryID) async { - try { - return (await diaryService.getDiary(diaryID))['diary']!; - } catch (e) { - rethrow; - } - } - - Future> getChartData(int diaryID) async { - try { - return (await diaryService.getChart(diaryID)); - } catch (e) { - rethrow; - } - } - - Future>> inputProduct(String name) async { - try { - return await diaryService.getInputProduct(name); - } catch (e) { - rethrow; - } - } - - Future changeSatiety(int satiety, int mealID, int diaryID) async { - try { - await diaryService.sendSatietyData( - diaryID, - mealID, - satiety, - ); - } catch (e) { - rethrow; - } - } - - Future changeMood(int mood, int mealID, int diaryID) async { - try { - await diaryService.sendMoodData( - diaryID, - mealID, - mood, - ); - } catch (e) { - rethrow; - } - } - - Future changeWakeup( - int diaryID, - String wakeup, - ) async { - try { - await diaryService.sendWakeupData( - diaryID, - wakeup, - ); - } catch (e) { - rethrow; - } - } - - Future changeRetire( - int diaryID, - String retire, - ) async { - try { - await diaryService.sendWakeupData( - diaryID, - retire, - ); - } catch (e) { - rethrow; - } - } - - Future> addPortion( - int diaryID, - int mealID, - String name, - String product, - int quantity, - ) async { - try { - return await diaryService.sendPortionData( - diaryID, - mealID, - name, - product, - quantity, - ); - } catch (e) { - rethrow; - } - } - - Future> sendModeration( - String name, - String energy_on_100gr, - String proteins_on_100gr, - String fats_on_100gr, - String carbohydrates_on_100gr, - ) async { - try { - return await diaryService.sendModerationData( - name, - double.parse(energy_on_100gr + ".0"), - double.parse(proteins_on_100gr + ".0"), - double.parse(fats_on_100gr + ".0"), - double.parse(carbohydrates_on_100gr + ".0"), - ); - } catch (e) { - rethrow; - } - } - - Future removePortion( - int diaryID, - int mealID, - int portionID, - ) async { - try { - await diaryService.sendRemovePortionData( - diaryID, - mealID, - portionID, - ); - } catch (e) { - rethrow; - } - } - - Future uploadImage( - String path, - int diaryID, - int mealID, - ) async { - try { - File file = File(path); - await diaryService.uploadImage( - diaryID, - mealID, - file, - ); - } catch (e) { - rethrow; - } - } - - Future removeImage( - int diaryID, - int mealID, - int photoID, - String path, - ) async { - try { - await diaryService.sendRemovePhotoData( - diaryID, - mealID, - path, - photoID, - ); - } catch (e) { - rethrow; - } - } - - Future finishDay( - int diaryID, - ) async { - try { - /*final formatter = DateFormat('HH:mm'); - final wakeupString = formatter.format(DateTime(2022, 1, 1, wakeup.hour, wakeup.minute)); - final retireString = formatter.format(DateTime(2022, 1, 1, retire.hour, retire.minute));*/ - await diaryService.sendFinishDay(diaryID); - } catch (e) { - rethrow; - } + Future _getDiaryIndexByDate(String date) async { + return (await diaryService.getDiaryIndexByDate(date: date)).id; } } diff --git a/lib/features/diary/services/diary_service.dart b/lib/features/diary/services/diary_service.dart index d7fa9a0c..5f5cd8c8 100644 --- a/lib/features/diary/services/diary_service.dart +++ b/lib/features/diary/services/diary_service.dart @@ -1,9 +1,6 @@ -import 'dart:io'; - import 'package:dio/dio.dart'; -import 'package:eatvio_app/features/diary/models/diary_model.dart'; -import 'package:eatvio_app/features/diary/models/portion.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/diary/models/diary_day_model.dart'; +import 'package:eatvio_app/features/diary/models/diary_index_model.dart'; import 'package:retrofit/retrofit.dart'; part 'diary_service.g.dart'; @@ -12,89 +9,13 @@ part 'diary_service.g.dart'; abstract class DiaryService { factory DiaryService(Dio dio, {String baseUrl}) = _DiaryService; - @GET('/api/diary/index') - Future> getDiaryID(); + @GET('/api/diary/index/{date}') + Future getDiaryIndexByDate({ + @Path('date') required String date, // yyyy-mm-dd + }); - @GET('/api/diary/{id}/show/') - Future> getDiary(@Path() int id); - - @GET('/api/diary/{id}/dailyNutritionData/') - Future getChart(@Path() int id); - - @GET('/api/diary/product_nutritional_values/filter') - Future>> getInputProduct(@Query('name') String name); - - @POST('/api/diary/{diary_id}/meal/{meal_id}/satiety/fill') - Future> sendSatietyData( - @Path() int diary_id, - @Path() int meal_id, - @Query('satiety') int satiety, - ); - - @POST('/api/diary/{diary_id}/meal/{meal_id}/mood/fill') - Future> sendMoodData( - @Path() int diary_id, - @Path() int meal_id, - @Query('mood') int mood, - ); - - @POST('/api/diary/{diary_id}/wakeup/fill') - Future sendWakeupData( - @Path() int diary_id, - @Query('wakeup') String wakeup, - ); - - @POST('/api/diary/{diary_id}/retire/fill') - Future sendRetireData( - @Path() int diary_id, - @Query('retire') String retire, - ); - - @POST('/api/diary/{diary_id}/meal/{meal_id}/portions/create') - Future> sendPortionData( - @Path() int diary_id, - @Path() int meal_id, - @Query('product_name') String product_name, - @Query('portion') String portion, - @Query('quantity') int quantity, - ); - - @POST('/api/diary/{diary_id}/meal/{meal_id}/photo/upload') - Future uploadImage( - @Path() int diary_id, - @Path() int meal_id, - @Part() File photo, - ); - - @POST('/api/diary/product_nutritional_values/sendToModeration') - Future> sendModerationData( - @Query('name') String product_name, - @Query('energy_on_100gr') double energy_on_100gr, - @Query('proteins_on_100gr') double proteins_on_100gr, - @Query('fats_on_100gr') double fats_on_100gr, - @Query('carbohydrates_on_100gr') double carbohydrates_on_100gr, - ); - - @POST('/api/diary/{diary_id}/finishDay') - Future sendFinishDay( - @Path() int diary_id, - //@Query('wakeUp') String wakeup, - //@Query('retire') String retire, - //@Query('comment') String comment, - ); - - @DELETE('/api/diary/{diary_id}/meal/{meal_id}/portions/{portion_id}/delete') - Future sendRemovePortionData( - @Path() int diary_id, - @Path() int meal_id, - @Path() int portion_id, - ); - - @DELETE('/api/diary/{diary_id}/meal/{meal_id}/photo/delete') - Future sendRemovePhotoData( - @Path() int diary_id, - @Path() int meal_id, - @Query('path') String path, - @Query('id') int photo_id, - ); + @GET('/api/diary/{diary_id}/show') + Future getDiaryDay({ + @Path('diary_id') required int index, + }); } diff --git a/lib/features/diary/services/diary_service.g.dart b/lib/features/diary/services/diary_service.g.dart index 8c1039c0..ee5f5e0b 100644 --- a/lib/features/diary/services/diary_service.g.dart +++ b/lib/features/diary/services/diary_service.g.dart @@ -22,19 +22,19 @@ class _DiaryService implements DiaryService { final ParseErrorLogger? errorLogger; @override - Future> getDiaryID() async { + Future getDiaryIndexByDate({required String date}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) .compose( _dio.options, - '/api/diary/index', + '/api/diary/index/${date}', queryParameters: queryParameters, data: _data, ) @@ -44,9 +44,9 @@ class _DiaryService implements DiaryService { baseUrl, ))); final _result = await _dio.fetch>(_options); - late Map _value; + late DiaryIndexModel _value; try { - _value = _result.data!.cast(); + _value = DiaryIndexModel.fromJson(_result.data!); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; @@ -55,19 +55,19 @@ class _DiaryService implements DiaryService { } @override - Future> getDiary(int id) async { + Future getDiaryDay({required int index}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) .compose( _dio.options, - '/api/diary/${id}/show/', + '/api/diary/${index}/show', queryParameters: queryParameters, data: _data, ) @@ -77,10 +77,9 @@ class _DiaryService implements DiaryService { baseUrl, ))); final _result = await _dio.fetch>(_options); - late Map _value; + late DiaryDayWrapperModel _value; try { - _value = _result.data!.map((k, dynamic v) => - MapEntry(k, DiaryModel.fromJson(v as Map))); + _value = DiaryDayWrapperModel.fromJson(_result.data!); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; @@ -88,428 +87,6 @@ class _DiaryService implements DiaryService { return _value; } - @override - Future getChart(int id) async { - final _extra = {}; - final queryParameters = {}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${id}/dailyNutritionData/', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch(_options); - final _value = _result.data; - return _value; - } - - @override - Future>> getInputProduct(String name) async { - final _extra = {}; - final queryParameters = {r'name': name}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType>>(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/product_nutritional_values/filter', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map> _value; - try { - _value = _result.data!.map((k, dynamic v) => MapEntry( - k, - (v as List) - .map((i) => Product.fromJson(i as Map)) - .toList())); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future> sendSatietyData( - int diary_id, - int meal_id, - int satiety, - ) async { - final _extra = {}; - final queryParameters = {r'satiety': satiety}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/satiety/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.cast(); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future> sendMoodData( - int diary_id, - int meal_id, - int mood, - ) async { - final _extra = {}; - final queryParameters = {r'mood': mood}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/mood/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.cast(); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future sendWakeupData( - int diary_id, - String wakeup, - ) async { - final _extra = {}; - final queryParameters = {r'wakeup': wakeup}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/wakeup/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late DiaryModel _value; - try { - _value = DiaryModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future sendRetireData( - int diary_id, - String retire, - ) async { - final _extra = {}; - final queryParameters = {r'retire': retire}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/retire/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late DiaryModel _value; - try { - _value = DiaryModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future> sendPortionData( - int diary_id, - int meal_id, - String product_name, - String portion, - int quantity, - ) async { - final _extra = {}; - final queryParameters = { - r'product_name': product_name, - r'portion': portion, - r'quantity': quantity, - }; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/portions/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.map((k, dynamic v) => - MapEntry(k, Portion.fromJson(v as Map))); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future uploadImage( - int diary_id, - int meal_id, - File photo, - ) async { - final _extra = {}; - final queryParameters = {}; - final _headers = {}; - final _data = FormData(); - _data.files.add(MapEntry( - 'photo', - MultipartFile.fromFileSync( - photo.path, - filename: photo.path.split(Platform.pathSeparator).last, - ), - )); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/photo/upload', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - await _dio.fetch(_options); - } - - @override - Future> sendModerationData( - String product_name, - double energy_on_100gr, - double proteins_on_100gr, - double fats_on_100gr, - double carbohydrates_on_100gr, - ) async { - final _extra = {}; - final queryParameters = { - r'name': product_name, - r'energy_on_100gr': energy_on_100gr, - r'proteins_on_100gr': proteins_on_100gr, - r'fats_on_100gr': fats_on_100gr, - r'carbohydrates_on_100gr': carbohydrates_on_100gr, - }; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/product_nutritional_values/sendToModeration', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.cast(); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future sendFinishDay(int diary_id) async { - final _extra = {}; - final queryParameters = {}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/finishDay', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - await _dio.fetch(_options); - } - - @override - Future sendRemovePortionData( - int diary_id, - int meal_id, - int portion_id, - ) async { - final _extra = {}; - final queryParameters = {}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType(Options( - method: 'DELETE', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/portions/${portion_id}/delete', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - await _dio.fetch(_options); - } - - @override - Future sendRemovePhotoData( - int diary_id, - int meal_id, - String path, - int photo_id, - ) async { - final _extra = {}; - final queryParameters = { - r'path': path, - r'id': photo_id, - }; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType(Options( - method: 'DELETE', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/photo/delete', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - await _dio.fetch(_options); - } - RequestOptions _setStreamType(RequestOptions requestOptions) { if (T != dynamic && !(requestOptions.responseType == ResponseType.bytes || diff --git a/lib/features/profile/models/badge_model.dart b/lib/features/profile/models/badge_model.dart index fc9f1f2a..7ede65cc 100644 --- a/lib/features/profile/models/badge_model.dart +++ b/lib/features/profile/models/badge_model.dart @@ -12,7 +12,6 @@ class BadgeModel with _$BadgeModel { required String description, required String image, required String type, - required List parameters, }) = _BadgeModel; factory BadgeModel.fromJson(Map json) => _$BadgeModelFromJson(json); diff --git a/lib/features/profile/models/badge_model.freezed.dart b/lib/features/profile/models/badge_model.freezed.dart index ef3d1d1a..e71a7072 100644 --- a/lib/features/profile/models/badge_model.freezed.dart +++ b/lib/features/profile/models/badge_model.freezed.dart @@ -25,7 +25,6 @@ mixin _$BadgeModel { String get description => throw _privateConstructorUsedError; String get image => throw _privateConstructorUsedError; String get type => throw _privateConstructorUsedError; - List get parameters => throw _privateConstructorUsedError; /// Serializes this BadgeModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; @@ -44,12 +43,7 @@ abstract class $BadgeModelCopyWith<$Res> { _$BadgeModelCopyWithImpl<$Res, BadgeModel>; @useResult $Res call( - {int id, - String title, - String description, - String image, - String type, - List parameters}); + {int id, String title, String description, String image, String type}); } /// @nodoc @@ -72,7 +66,6 @@ class _$BadgeModelCopyWithImpl<$Res, $Val extends BadgeModel> Object? description = null, Object? image = null, Object? type = null, - Object? parameters = null, }) { return _then(_value.copyWith( id: null == id @@ -95,10 +88,6 @@ class _$BadgeModelCopyWithImpl<$Res, $Val extends BadgeModel> ? _value.type : type // ignore: cast_nullable_to_non_nullable as String, - parameters: null == parameters - ? _value.parameters - : parameters // ignore: cast_nullable_to_non_nullable - as List, ) as $Val); } } @@ -112,12 +101,7 @@ abstract class _$$BadgeModelImplCopyWith<$Res> @override @useResult $Res call( - {int id, - String title, - String description, - String image, - String type, - List parameters}); + {int id, String title, String description, String image, String type}); } /// @nodoc @@ -138,7 +122,6 @@ class __$$BadgeModelImplCopyWithImpl<$Res> Object? description = null, Object? image = null, Object? type = null, - Object? parameters = null, }) { return _then(_$BadgeModelImpl( id: null == id @@ -161,10 +144,6 @@ class __$$BadgeModelImplCopyWithImpl<$Res> ? _value.type : type // ignore: cast_nullable_to_non_nullable as String, - parameters: null == parameters - ? _value._parameters - : parameters // ignore: cast_nullable_to_non_nullable - as List, )); } } @@ -177,9 +156,7 @@ class _$BadgeModelImpl implements _BadgeModel { required this.title, required this.description, required this.image, - required this.type, - required final List parameters}) - : _parameters = parameters; + required this.type}); factory _$BadgeModelImpl.fromJson(Map json) => _$$BadgeModelImplFromJson(json); @@ -194,17 +171,10 @@ class _$BadgeModelImpl implements _BadgeModel { final String image; @override final String type; - final List _parameters; - @override - List get parameters { - if (_parameters is EqualUnmodifiableListView) return _parameters; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_parameters); - } @override String toString() { - return 'BadgeModel(id: $id, title: $title, description: $description, image: $image, type: $type, parameters: $parameters)'; + return 'BadgeModel(id: $id, title: $title, description: $description, image: $image, type: $type)'; } @override @@ -217,15 +187,13 @@ class _$BadgeModelImpl implements _BadgeModel { (identical(other.description, description) || other.description == description) && (identical(other.image, image) || other.image == image) && - (identical(other.type, type) || other.type == type) && - const DeepCollectionEquality() - .equals(other._parameters, _parameters)); + (identical(other.type, type) || other.type == type)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, id, title, description, image, - type, const DeepCollectionEquality().hash(_parameters)); + int get hashCode => + Object.hash(runtimeType, id, title, description, image, type); /// Create a copy of BadgeModel /// with the given fields replaced by the non-null parameter values. @@ -249,8 +217,7 @@ abstract class _BadgeModel implements BadgeModel { required final String title, required final String description, required final String image, - required final String type, - required final List parameters}) = _$BadgeModelImpl; + required final String type}) = _$BadgeModelImpl; factory _BadgeModel.fromJson(Map json) = _$BadgeModelImpl.fromJson; @@ -265,8 +232,6 @@ abstract class _BadgeModel implements BadgeModel { String get image; @override String get type; - @override - List get parameters; /// Create a copy of BadgeModel /// with the given fields replaced by the non-null parameter values. diff --git a/lib/features/profile/models/badge_model.g.dart b/lib/features/profile/models/badge_model.g.dart index f2cf5531..364faea5 100644 --- a/lib/features/profile/models/badge_model.g.dart +++ b/lib/features/profile/models/badge_model.g.dart @@ -13,9 +13,6 @@ _$BadgeModelImpl _$$BadgeModelImplFromJson(Map json) => description: json['description'] as String, image: json['image'] as String, type: json['type'] as String, - parameters: (json['parameters'] as List) - .map((e) => e as String) - .toList(), ); Map _$$BadgeModelImplToJson(_$BadgeModelImpl instance) => @@ -25,5 +22,4 @@ Map _$$BadgeModelImplToJson(_$BadgeModelImpl instance) => 'description': instance.description, 'image': instance.image, 'type': instance.type, - 'parameters': instance.parameters, }; diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index a9122aab..35101143 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -483,11 +483,15 @@ class _ProfileScreenState extends State { child: Row( children: [ for (int i = 0; i < state.profile.badges.length; i++) ...[ - SvgPicture.network( - baseUrl + '/storage/' + state.profile.badges[i].image, - width: 40, - height: 40, - ), + state.profile.badges[i].image.contains('svg') + ? SvgPicture.network( + baseUrl + '/storage/' + state.profile.badges[i].image, + width: 40, + height: 40, + ) + : CachedNetworkImage( + imageUrl: baseUrl + '/storage/' + state.profile.badges[i].image, + ), i < state.profile.badges.length - 1 ? const SizedBox(width: 8) : const SizedBox.shrink(), ], ], @@ -634,11 +638,15 @@ class _ProfileScreenState extends State { } _additionalInfo(ProfileStateLoaded state) { + String text = state.profileDetails.additionalInfo; + if (state.profileDetails.additionalInfo.length > 250) { + text = state.profileDetails.additionalInfo.substring(0, 250); + } return Container( alignment: Alignment.centerLeft, padding: const EdgeInsets.all(16), child: Text( - state.profileDetails.additionalInfo, + text, style: TextStyle( color: Colors.black.withOpacity(0.4), height: 1, diff --git a/lib/features/profile/repositories/profile_repository.dart b/lib/features/profile/repositories/profile_repository.dart index 2e927ca0..58b31442 100644 --- a/lib/features/profile/repositories/profile_repository.dart +++ b/lib/features/profile/repositories/profile_repository.dart @@ -65,8 +65,7 @@ class ProfileRepository { try { return (await profileService.getBlogPostByAuthorSlug( slug: slug, - )) - .feedBlogPostList; + )); } catch (e) { rethrow; } diff --git a/lib/features/profile/services/profile_service.dart b/lib/features/profile/services/profile_service.dart index f5490213..f092cc4f 100644 --- a/lib/features/profile/services/profile_service.dart +++ b/lib/features/profile/services/profile_service.dart @@ -1,10 +1,9 @@ import 'package:dio/dio.dart'; -import 'package:eatvio_app/features/feed/models/feed_blog_post_settings_model.dart'; +import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart'; import 'package:eatvio_app/features/profile/models/circumference_model.dart'; import 'package:eatvio_app/features/profile/models/profile_model.dart'; import 'package:eatvio_app/features/profile/models/weight_model.dart'; import 'package:retrofit/retrofit.dart'; - part 'profile_service.g.dart'; @RestApi() @@ -35,7 +34,7 @@ abstract class ProfileService { }); @GET('/api/blogPosts/search_by_author/{slug}') - Future getBlogPostByAuthorSlug({ + Future> getBlogPostByAuthorSlug({ @Path() required String slug, }); diff --git a/lib/features/profile/services/profile_service.g.dart b/lib/features/profile/services/profile_service.g.dart index 36b64eb3..aff8547f 100644 --- a/lib/features/profile/services/profile_service.g.dart +++ b/lib/features/profile/services/profile_service.g.dart @@ -191,13 +191,13 @@ class _ProfileService implements ProfileService { } @override - Future getBlogPostByAuthorSlug( + Future> getBlogPostByAuthorSlug( {required String slug}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _options = _setStreamType>(Options( method: 'GET', headers: _headers, extra: _extra, @@ -213,10 +213,13 @@ class _ProfileService implements ProfileService { _dio.options.baseUrl, baseUrl, ))); - final _result = await _dio.fetch>(_options); - late FeedBlogPostSettingsModel _value; + final _result = await _dio.fetch>(_options); + late List _value; try { - _value = FeedBlogPostSettingsModel.fromJson(_result.data!); + _value = _result.data! + .map((dynamic i) => + FeedBlogPostModel.fromJson(i as Map)) + .toList(); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; diff --git a/lib/features/diary/models/product.dart b/lib/features/recipes/models/product.dart similarity index 100% rename from lib/features/diary/models/product.dart rename to lib/features/recipes/models/product.dart diff --git a/lib/features/diary/models/product.freezed.dart b/lib/features/recipes/models/product.freezed.dart similarity index 100% rename from lib/features/diary/models/product.freezed.dart rename to lib/features/recipes/models/product.freezed.dart diff --git a/lib/features/diary/models/product.g.dart b/lib/features/recipes/models/product.g.dart similarity index 100% rename from lib/features/diary/models/product.g.dart rename to lib/features/recipes/models/product.g.dart diff --git a/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart b/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart index 727317bc..f666121c 100644 --- a/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart +++ b/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart @@ -3,7 +3,7 @@ import 'package:eatvio_app/features/recipes/models/ingredient.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_state.dart'; import 'package:eatvio_app/features/recipes/reporitories/recipe_repository.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/recipes/models/product.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:image_picker/image_picker.dart'; diff --git a/lib/features/recipes/presentation/bloc/recipe_create_state.dart b/lib/features/recipes/presentation/bloc/recipe_create_state.dart index 8bb6051a..76f9aba0 100644 --- a/lib/features/recipes/presentation/bloc/recipe_create_state.dart +++ b/lib/features/recipes/presentation/bloc/recipe_create_state.dart @@ -1,6 +1,6 @@ import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/ingredient.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/recipes/models/product.dart'; import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:image_picker/image_picker.dart'; diff --git a/lib/features/recipes/presentation/pages/recipe_create_screen.dart b/lib/features/recipes/presentation/pages/recipe_create_screen.dart index eb1339b4..f5a1cd10 100644 --- a/lib/features/recipes/presentation/pages/recipe_create_screen.dart +++ b/lib/features/recipes/presentation/pages/recipe_create_screen.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'dart:io'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/recipes/models/product.dart'; import 'package:eatvio_app/features/recipes/models/ingredient.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/step.dart' as step; diff --git a/lib/features/recipes/presentation/pages/recipe_edit_screen.dart b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart index dc435059..51fcd982 100644 --- a/lib/features/recipes/presentation/pages/recipe_edit_screen.dart +++ b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart @@ -1,5 +1,5 @@ import 'package:eatvio_app/core/const.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/recipes/models/product.dart'; import 'package:eatvio_app/features/recipes/models/ingredient.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/step.dart' as step; diff --git a/lib/features/recipes/reporitories/recipe_repository.dart b/lib/features/recipes/reporitories/recipe_repository.dart index cf9a355e..e07f5dc5 100644 --- a/lib/features/recipes/reporitories/recipe_repository.dart +++ b/lib/features/recipes/reporitories/recipe_repository.dart @@ -4,7 +4,7 @@ import 'dart:io'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/recipe_tag_model.dart'; import 'package:eatvio_app/features/recipes/services/recipe_service.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/recipes/models/product.dart'; class RecipeRepository { final RecipeService recipeService; diff --git a/lib/features/recipes/services/recipe_service.dart b/lib/features/recipes/services/recipe_service.dart index f0a5e200..54703dc5 100644 --- a/lib/features/recipes/services/recipe_service.dart +++ b/lib/features/recipes/services/recipe_service.dart @@ -5,7 +5,7 @@ import 'package:dio/dio.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/recipe_tag_model.dart'; import 'package:retrofit/retrofit.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/recipes/models/product.dart'; part 'recipe_service.g.dart'; diff --git a/lib/features/registration/presentation/pages/additional_information_screen.dart b/lib/features/registration/presentation/pages/additional_information_screen.dart index 01ce3ffa..c3d70fc4 100644 --- a/lib/features/registration/presentation/pages/additional_information_screen.dart +++ b/lib/features/registration/presentation/pages/additional_information_screen.dart @@ -2,6 +2,7 @@ import 'package:eatvio_app/features/registration/models/user_registration_model. import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class AdditionalInformationScreen extends StatefulWidget { @@ -43,6 +44,9 @@ class _AdditionalInformationScreenState extends State { SizedBox(height: 4), CustomTextFormField( controller: additionalInfoController, + inputFormatters: [ + new LengthLimitingTextInputFormatter(250), + ], hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни", maxLines: 8, onChanged: (newValue) {}, diff --git a/lib/locator_service.dart b/lib/locator_service.dart index 078ea81c..a1cecd73 100644 --- a/lib/locator_service.dart +++ b/lib/locator_service.dart @@ -14,7 +14,7 @@ import 'package:eatvio_app/features/chat/services/chat_service.dart'; import 'package:eatvio_app/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart'; import 'package:eatvio_app/features/consultant/become_consultant/repositories/consultant_repository.dart'; import 'package:eatvio_app/features/consultant/become_consultant/services/consultant_service.dart'; -import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart'; +import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart'; import 'package:eatvio_app/features/diary/repositories/diary_repository.dart'; import 'package:eatvio_app/features/diary/services/diary_service.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart'; @@ -53,7 +53,6 @@ Future init() async { sl.registerFactory(() => ChatRoomCubit(chatRepository: sl(), initializationCubit: sl())); sl.registerFactory(() => FeedCubit(feedRepository: sl())); sl.registerFactory(() => RecipesCubit(feedRepository: sl(), recipeRepository: sl())); - sl.registerFactory(() => DiaryBloc(diaryRepository: sl())); sl.registerFactory(() => CalendarCubit(calendarRepository: sl())); sl.registerFactory(() => ProfileCubit(profileRepository: sl(), chatRepository: sl())); sl.registerFactory(() => ProfileAvatarCubit(profileRepository: sl())); @@ -64,30 +63,31 @@ Future init() async { sl.registerFactory(() => PlansCubit(plansRepository: sl())); sl.registerFactory(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl())); sl.registerFactory(() => RegisterConsultantCubit(consultantRepository: sl())); + sl.registerFactory(() => DiaryCubit(diaryRepository: sl())); // Repository sl.registerLazySingleton(() => ChatRepository(chatService: sl())); sl.registerLazySingleton(() => FeedRepository(feedService: sl())); sl.registerLazySingleton(() => RegistrationRepository(registrationService: sl())); - sl.registerLazySingleton(() => DiaryRepository(diaryService: sl())); sl.registerLazySingleton(() => CalendarRepository(calendarService: sl())); sl.registerLazySingleton(() => ProfileRepository(profileService: sl())); sl.registerLazySingleton(() => RecipeRepository(recipeService: sl())); sl.registerLazySingleton(() => PlansRepository(plansService: sl())); sl.registerLazySingleton(() => SettingsRepository(settingsService: sl())); sl.registerLazySingleton(() => ConsultantRepository(consultantService: sl())); + sl.registerLazySingleton(() => DiaryRepository(diaryService: sl())); // Services sl.registerLazySingleton(() => ChatService(sl())); sl.registerLazySingleton(() => FeedService(sl())); sl.registerLazySingleton(() => RegistrationService(sl())); - sl.registerLazySingleton(() => DiaryService(sl())); sl.registerLazySingleton(() => CalendarService(sl())); sl.registerLazySingleton(() => ProfileService(sl())); sl.registerLazySingleton(() => RecipeService(sl())); sl.registerLazySingleton(() => PlansService(sl())); sl.registerLazySingleton(() => SettingsService(sl())); sl.registerLazySingleton(() => ConsultantService(sl())); + sl.registerLazySingleton(() => DiaryService(sl())); // External sl.registerLazySingleton( diff --git a/pubspec.yaml b/pubspec.yaml index 9383ed5a..b589dd00 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,31 +23,31 @@ dependencies: validators: ^3.0.0 path_provider: ^2.1.4 carousel_slider_plus: ^7.0.1 - flutter_form_builder: ^9.4.1 + flutter_form_builder: ^9.5.0 image_picker: ^1.1.2 flutter_typeahead: ^5.2.0 - go_router: ^14.2.9 + go_router: ^14.3.0 keyboard_dismisser: ^3.0.0 retrofit: ^4.4.1 - get_it: ^8.0.0 + get_it: ^8.0.1 dio: ^5.7.0 dart_pusher_channels: ^1.2.3 photo_view: ^0.15.0 dismissible_page: ^1.0.2 - url_launcher: ^6.3.0 + url_launcher: ^6.3.1 easy_debounce: ^2.0.3 badges: ^3.1.2 google_fonts: ^6.2.1 - location: ^6.0.2 - syncfusion_flutter_charts: ^27.1.51 + location: ^7.0.1 + syncfusion_flutter_charts: ^27.1.55 table_calendar: ^3.1.2 flutter_keyboard_visibility: ^6.0.0 - share_plus: ^10.0.2 + share_plus: ^10.1.0 flutter_html: ^3.0.0-beta.2 - file_picker: ^8.1.2 + file_picker: ^8.1.3 audioplayers: ^6.1.0 intl: ^0.19.0 - rive: ^0.13.14 + rive: ^0.13.15 mask_text_input_formatter: ^2.9.0 lottie: ^3.1.3 @@ -55,7 +55,7 @@ dev_dependencies: build_runner: ^2.4.13 freezed: ^2.5.7 json_serializable: ^6.8.0 - retrofit_generator: ^9.1.2 + retrofit_generator: ^9.1.3 flutter_test: sdk: flutter