diff --git a/lib/features/diary/models/diary_model.dart b/lib/features/diary/models/diary_model.dart index 9beb22d7..d9abc3a9 100644 --- a/lib/features/diary/models/diary_model.dart +++ b/lib/features/diary/models/diary_model.dart @@ -1,3 +1,4 @@ +import 'package:eatvio_app/features/diary/models/state.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import './meal.dart'; @@ -12,6 +13,7 @@ class DiaryModel with _$DiaryModel { required DateTime date, required int closed, required List meals, + required State state, String? comment, DateTime? wakeup, DateTime? retire, diff --git a/lib/features/diary/models/diary_model.freezed.dart b/lib/features/diary/models/diary_model.freezed.dart index 3fe59e15..a02a4621 100644 --- a/lib/features/diary/models/diary_model.freezed.dart +++ b/lib/features/diary/models/diary_model.freezed.dart @@ -24,6 +24,7 @@ mixin _$DiaryModel { 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; @@ -45,9 +46,12 @@ abstract class $DiaryModelCopyWith<$Res> { DateTime date, int closed, List meals, + State state, String? comment, DateTime? wakeup, DateTime? retire}); + + $StateCopyWith<$Res> get state; } /// @nodoc @@ -67,6 +71,7 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel> Object? date = null, Object? closed = null, Object? meals = null, + Object? state = null, Object? comment = freezed, Object? wakeup = freezed, Object? retire = freezed, @@ -88,6 +93,10 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel> ? _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 @@ -102,6 +111,14 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel> as DateTime?, ) as $Val); } + + @override + @pragma('vm:prefer-inline') + $StateCopyWith<$Res> get state { + return $StateCopyWith<$Res>(_value.state, (value) { + return _then(_value.copyWith(state: value) as $Val); + }); + } } /// @nodoc @@ -117,9 +134,13 @@ abstract class _$$DiaryModelImplCopyWith<$Res> DateTime date, int closed, List meals, + State state, String? comment, DateTime? wakeup, DateTime? retire}); + + @override + $StateCopyWith<$Res> get state; } /// @nodoc @@ -137,6 +158,7 @@ class __$$DiaryModelImplCopyWithImpl<$Res> Object? date = null, Object? closed = null, Object? meals = null, + Object? state = null, Object? comment = freezed, Object? wakeup = freezed, Object? retire = freezed, @@ -158,6 +180,10 @@ class __$$DiaryModelImplCopyWithImpl<$Res> ? _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 @@ -182,6 +208,7 @@ class _$DiaryModelImpl implements _DiaryModel { required this.date, required this.closed, required final List meals, + required this.state, this.comment, this.wakeup, this.retire}) @@ -204,6 +231,8 @@ class _$DiaryModelImpl implements _DiaryModel { return EqualUnmodifiableListView(_meals); } + @override + final State state; @override final String? comment; @override @@ -213,7 +242,7 @@ class _$DiaryModelImpl implements _DiaryModel { @override String toString() { - return 'DiaryModel(id: $id, date: $date, closed: $closed, meals: $meals, comment: $comment, wakeup: $wakeup, retire: $retire)'; + return 'DiaryModel(id: $id, date: $date, closed: $closed, meals: $meals, state: $state, comment: $comment, wakeup: $wakeup, retire: $retire)'; } @override @@ -225,6 +254,7 @@ class _$DiaryModelImpl implements _DiaryModel { (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)); @@ -232,8 +262,16 @@ class _$DiaryModelImpl implements _DiaryModel { @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, id, date, closed, - const DeepCollectionEquality().hash(_meals), comment, wakeup, retire); + int get hashCode => Object.hash( + runtimeType, + id, + date, + closed, + const DeepCollectionEquality().hash(_meals), + state, + comment, + wakeup, + retire); @JsonKey(ignore: true) @override @@ -255,6 +293,7 @@ abstract class _DiaryModel implements DiaryModel { 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; @@ -271,6 +310,8 @@ abstract class _DiaryModel implements DiaryModel { @override List get meals; @override + State get state; + @override String? get comment; @override DateTime? get wakeup; diff --git a/lib/features/diary/models/diary_model.g.dart b/lib/features/diary/models/diary_model.g.dart index 1a13c7d5..29f98caa 100644 --- a/lib/features/diary/models/diary_model.g.dart +++ b/lib/features/diary/models/diary_model.g.dart @@ -14,6 +14,7 @@ _$DiaryModelImpl _$$DiaryModelImplFromJson(Map json) => 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 @@ -29,6 +30,7 @@ Map _$$DiaryModelImplToJson(_$DiaryModelImpl instance) => '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/portion.dart b/lib/features/diary/models/portion.dart index 54a46dd6..f544c431 100644 --- a/lib/features/diary/models/portion.dart +++ b/lib/features/diary/models/portion.dart @@ -1,3 +1,4 @@ +import 'package:eatvio_app/features/diary/models/state.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'portion.freezed.dart'; @@ -10,6 +11,7 @@ class Portion with _$Portion { 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 index a7a35a29..77627c29 100644 --- a/lib/features/diary/models/portion.freezed.dart +++ b/lib/features/diary/models/portion.freezed.dart @@ -24,6 +24,7 @@ mixin _$Portion { String get product_name => throw _privateConstructorUsedError; int get quantity => throw _privateConstructorUsedError; String get portion => throw _privateConstructorUsedError; + bool get from_diet => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -35,7 +36,12 @@ 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}); + $Res call( + {int id, + String product_name, + int quantity, + String portion, + bool from_diet}); } /// @nodoc @@ -55,6 +61,7 @@ class _$PortionCopyWithImpl<$Res, $Val extends Portion> Object? product_name = null, Object? quantity = null, Object? portion = null, + Object? from_diet = null, }) { return _then(_value.copyWith( id: null == id @@ -73,6 +80,10 @@ class _$PortionCopyWithImpl<$Res, $Val extends 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); } } @@ -84,7 +95,12 @@ abstract class _$$PortionImplCopyWith<$Res> implements $PortionCopyWith<$Res> { __$$PortionImplCopyWithImpl<$Res>; @override @useResult - $Res call({int id, String product_name, int quantity, String portion}); + $Res call( + {int id, + String product_name, + int quantity, + String portion, + bool from_diet}); } /// @nodoc @@ -102,6 +118,7 @@ class __$$PortionImplCopyWithImpl<$Res> Object? product_name = null, Object? quantity = null, Object? portion = null, + Object? from_diet = null, }) { return _then(_$PortionImpl( id: null == id @@ -120,6 +137,10 @@ class __$$PortionImplCopyWithImpl<$Res> ? _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, )); } } @@ -131,7 +152,8 @@ class _$PortionImpl implements _Portion { {required this.id, required this.product_name, required this.quantity, - required this.portion}); + required this.portion, + required this.from_diet}); factory _$PortionImpl.fromJson(Map json) => _$$PortionImplFromJson(json); @@ -144,10 +166,12 @@ class _$PortionImpl implements _Portion { 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)'; + return 'Portion(id: $id, product_name: $product_name, quantity: $quantity, portion: $portion, from_diet: $from_diet)'; } @override @@ -160,13 +184,15 @@ class _$PortionImpl implements _Portion { other.product_name == product_name) && (identical(other.quantity, quantity) || other.quantity == quantity) && - (identical(other.portion, portion) || other.portion == portion)); + (identical(other.portion, portion) || other.portion == portion) && + (identical(other.from_diet, from_diet) || + other.from_diet == from_diet)); } @JsonKey(ignore: true) @override int get hashCode => - Object.hash(runtimeType, id, product_name, quantity, portion); + Object.hash(runtimeType, id, product_name, quantity, portion, from_diet); @JsonKey(ignore: true) @override @@ -187,7 +213,8 @@ abstract class _Portion implements Portion { {required final int id, required final String product_name, required final int quantity, - required final String portion}) = _$PortionImpl; + required final String portion, + required final bool from_diet}) = _$PortionImpl; factory _Portion.fromJson(Map json) = _$PortionImpl.fromJson; @@ -200,6 +227,8 @@ abstract class _Portion implements Portion { @override String get portion; @override + bool get from_diet; + @override @JsonKey(ignore: true) _$$PortionImplCopyWith<_$PortionImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/features/diary/models/portion.g.dart b/lib/features/diary/models/portion.g.dart index c8bd109f..f3503e5c 100644 --- a/lib/features/diary/models/portion.g.dart +++ b/lib/features/diary/models/portion.g.dart @@ -12,6 +12,7 @@ _$PortionImpl _$$PortionImplFromJson(Map json) => 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) => @@ -20,4 +21,5 @@ Map _$$PortionImplToJson(_$PortionImpl instance) => '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 new file mode 100644 index 00000000..874592ed --- /dev/null +++ b/lib/features/diary/models/state.dart @@ -0,0 +1,14 @@ +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 new file mode 100644 index 00000000..599ec29f --- /dev/null +++ b/lib/features/diary/models/state.freezed.dart @@ -0,0 +1,169 @@ +// 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; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $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; + + @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); + + @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(ignore: true) + @override + int get hashCode => + Object.hash(runtimeType, has_chosen_diet, has_chosen_plan); + + @JsonKey(ignore: true) + @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; + @override + @JsonKey(ignore: true) + _$$StateImplCopyWith<_$StateImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/diary/models/state.g.dart b/lib/features/diary/models/state.g.dart new file mode 100644 index 00000000..1b0da8f4 --- /dev/null +++ b/lib/features/diary/models/state.g.dart @@ -0,0 +1,18 @@ +// 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/pages/diary_recommendations_scree.dart b/lib/features/diary/presentation/pages/diary_recommendations_scree.dart index b2dcfca3..6c9f3a12 100644 --- a/lib/features/diary/presentation/pages/diary_recommendations_scree.dart +++ b/lib/features/diary/presentation/pages/diary_recommendations_scree.dart @@ -54,10 +54,8 @@ class DiaryRecommendationsScreen extends StatelessWidget { ); } - Widget _buildDiaryRecommendations( - BuildContext context, DiaryStateLoaded state) { - final Portion product = - new Portion(id: 1, product_name: "", quantity: 1, portion: ""); + 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: [ @@ -88,13 +86,9 @@ class DiaryRecommendationsScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - 'Название продукта: ${product.product_name}', - style: TextStyle(fontSize: 24)), + Text('Название продукта: ${product.product_name}', style: TextStyle(fontSize: 24)), SizedBox(height: 16), - Text( - 'Количество: ${product.quantity} ${product.portion}', - style: TextStyle(fontSize: 18)), + 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 74a00edc..5970ed2a 100644 --- a/lib/features/diary/presentation/pages/diary_screen.dart +++ b/lib/features/diary/presentation/pages/diary_screen.dart @@ -154,8 +154,7 @@ class DiaryScreen extends StatelessWidget { trackOpacity: 0.1, gap: "8%", radius: "110%", - innerRadius: - '20%', // Измените значение по вашему усмотрению + innerRadius: '20%', // Измените значение по вашему усмотрению ) ], ), @@ -338,9 +337,7 @@ class DiaryScreen extends StatelessWidget { borderRadius: BorderRadiusStyle.roundedBorder5, ), child: Center( - child: CircularProgressIndicator( - color: appTheme - .blueGray300), // Замените на свой прелоадер при необходимости + child: CircularProgressIndicator(color: appTheme.blueGray300), // Замените на свой прелоадер при необходимости ), ), ], @@ -366,8 +363,7 @@ class DiaryScreen extends StatelessWidget { _buildMeal(BuildContext context, DiaryStateLoaded state) { final digitsOnly = FilteringTextInputFormatter.digitsOnly; - List _options = - state.autocompleteList.map((Product item) => item.name).toList(); + List _options = state.autocompleteList.map((Product item) => item.name).toList(); FocusNode focusNodeName = FocusNode(); return Container( padding: EdgeInsets.symmetric( @@ -402,9 +398,7 @@ class DiaryScreen extends StatelessWidget { onTap: () => _selectMealTime(context, state), child: AbsorbPointer( child: CustomTextFormField( - hintText: state.mealTimeController - ?.format(context) - .toString(), + hintText: state.mealTimeController?.format(context).toString(), autofocus: false, ), ), @@ -540,9 +534,8 @@ class DiaryScreen extends StatelessWidget { SizedBox(height: 24.v), _buildAddProduct(context, state), SizedBox(height: 24.v), - ...state.portions - .map((portion) => _buildProduct(context, portion)) - .toList(), + 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.v), _buildCarousel(context, state), SizedBox(height: 24.v), @@ -691,8 +684,7 @@ class DiaryScreen extends StatelessWidget { popDialog(BuildContext dialogContext) { return () { - Navigator.of(dialogContext) - .pop(); // Dismiss the dialog on Cancel button press + Navigator.of(dialogContext).pop(); // Dismiss the dialog on Cancel button press }; } @@ -702,8 +694,7 @@ class DiaryScreen extends StatelessWidget { }; } - selectProduct(AutocompleteOnSelected onSelected, String option, - DiaryStateLoaded state) { + selectProduct(AutocompleteOnSelected onSelected, String option, DiaryStateLoaded state) { state.product_nameController.text = option; return () { onSelected(option); @@ -771,9 +762,7 @@ class DiaryScreen extends StatelessWidget { top: 5.v, ), child: Text( - portion.product_name.length > 8 - ? portion.product_name.substring(0, 8) - : portion.product_name, + portion.product_name.length > 8 ? portion.product_name.substring(0, 8) : portion.product_name, style: CustomTextStyles.titleMedium16, ), ), @@ -803,6 +792,63 @@ class DiaryScreen extends StatelessWidget { ); } + _buildProductDiet(BuildContext context, Portion portion) { + return Container( + margin: EdgeInsets.symmetric( + horizontal: 10.h, + vertical: 4.h, + ), + padding: EdgeInsets.symmetric( + horizontal: 8.h, + vertical: 6.v, + ), + decoration: AppDecoration.fillGray.copyWith( + borderRadius: BorderRadiusStyle.roundedBorder5, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + Checkbox( + value: !portion.from_diet, + onChanged: (bool? value) {}, + ), + Padding( + padding: EdgeInsets.only( + left: 7.h, + top: 5.v, + ), + child: Text( + portion.product_name.length > 8 ? portion.product_name.substring(0, 8) : portion.product_name, + style: CustomTextStyles.titleMedium16, + ), + ), + Padding( + padding: EdgeInsets.only( + left: 20.h, + top: 3.v, + bottom: 3.v, + ), + child: Text( + portion.quantity.toString() + ' ' + portion.portion.toString().tr, + ), + ), + Spacer(), + GestureDetector( + onTap: () => removePortion(context, portion), // Обернуть в лямбду + child: Padding( + padding: const EdgeInsets.only(right: 10), + child: Icon( + Icons.close, + color: appTheme.blueGray300, + ), + ), + ), + ], + ), + ); + } + _buildPhoto(BuildContext context, Photo photo, DiaryStateLoaded state) { return Stack( children: [ @@ -861,9 +907,7 @@ class DiaryScreen extends StatelessWidget { removePhoto(BuildContext context, Photo photo) { return () { - context - .read() - .add(RemoveImageEvent(photo.id.toString(), photo.path)); + context.read().add(RemoveImageEvent(photo.id.toString(), photo.path)); }; } @@ -923,9 +967,7 @@ class DiaryScreen extends StatelessWidget { r"Подъем \ отход ко сну", style: CustomTextStyles.bodyMediumBlack900, ), - Icon(state.wakeupExpanded - ? Icons.arrow_drop_up - : Icons.arrow_drop_down), + Icon(state.wakeupExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), ], ), ), @@ -939,8 +981,7 @@ class DiaryScreen extends StatelessWidget { onTap: () => _selectWakeupTime(context, state), child: AbsorbPointer( child: CustomTextFormField( - hintText: - state.wakeupController.format(context).toString(), + hintText: state.wakeupController.format(context).toString(), prefix: Icon(Icons.sunny), autofocus: false, ), @@ -951,8 +992,7 @@ class DiaryScreen extends StatelessWidget { onTap: () => _selectRetireTime(context, state), child: AbsorbPointer( child: CustomTextFormField( - hintText: - state.retireController.format(context).toString(), + hintText: state.retireController.format(context).toString(), prefix: Icon(Icons.bed), autofocus: false, ), @@ -999,8 +1039,7 @@ class DiaryScreen extends StatelessWidget { }; } - Function() sendFinishDayData( - BuildContext dialogContext, BuildContext context) { + Function() sendFinishDayData(BuildContext dialogContext, BuildContext context) { return () { closeDialog(dialogContext); context.read().add(FinishDay()); @@ -1034,9 +1073,7 @@ class DiaryScreen extends StatelessWidget { "Ваше настроение после приема пищи", style: CustomTextStyles.bodyMediumBlack900, ), - Icon(state.moodExpanded - ? Icons.arrow_drop_up - : Icons.arrow_drop_down), + Icon(state.moodExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), ], ), ), @@ -1096,8 +1133,7 @@ class DiaryScreen extends StatelessWidget { }; } - Future _selectWakeupTime( - BuildContext context, DiaryStateLoaded state) async { + Future _selectWakeupTime(BuildContext context, DiaryStateLoaded state) async { final TimeOfDay? pickedTime = await showTimePicker( context: context, initialTime: state.wakeupController, @@ -1107,8 +1143,7 @@ class DiaryScreen extends StatelessWidget { } } - Future _selectRetireTime( - BuildContext context, DiaryStateLoaded state) async { + Future _selectRetireTime(BuildContext context, DiaryStateLoaded state) async { final TimeOfDay? pickedTime = await showTimePicker( context: context, initialTime: state.retireController, @@ -1118,8 +1153,7 @@ class DiaryScreen extends StatelessWidget { } } - Future _selectMealTime( - BuildContext context, DiaryStateLoaded state) async { + Future _selectMealTime(BuildContext context, DiaryStateLoaded state) async { final TimeOfDay? pickedTime = await showTimePicker( context: context, initialTime: state.mealTimeController ?? TimeOfDay.now(), @@ -1130,8 +1164,7 @@ class DiaryScreen extends StatelessWidget { } } -bool checkConsumedValues( - List recommendedValues, List consumedValues) { +bool checkConsumedValues(List recommendedValues, List consumedValues) { for (int i = 0; i < recommendedValues.length; i++) { if (consumedValues[i] > recommendedValues[i]) { // Если хотя бы одно потребленное значение превышает рекомендованное