forked from eatvio/eatvio_app
refactor(diary): Fix
This commit is contained in:
@@ -10,7 +10,7 @@ class DiaryModel with _$DiaryModel {
|
||||
required int id,
|
||||
required DateTime date,
|
||||
required int closed,
|
||||
required List<Meal>? meals,
|
||||
required List<Meal> meals,
|
||||
String? comment,
|
||||
DateTime? wakeup,
|
||||
DateTime? retire,
|
||||
|
||||
@@ -23,7 +23,7 @@ mixin _$DiaryModel {
|
||||
int get id => throw _privateConstructorUsedError;
|
||||
DateTime get date => throw _privateConstructorUsedError;
|
||||
int get closed => throw _privateConstructorUsedError;
|
||||
List<Meal>? get meals => throw _privateConstructorUsedError;
|
||||
List<Meal> get meals => throw _privateConstructorUsedError;
|
||||
String? get comment => throw _privateConstructorUsedError;
|
||||
DateTime? get wakeup => throw _privateConstructorUsedError;
|
||||
DateTime? get retire => throw _privateConstructorUsedError;
|
||||
@@ -44,7 +44,7 @@ abstract class $DiaryModelCopyWith<$Res> {
|
||||
{int id,
|
||||
DateTime date,
|
||||
int closed,
|
||||
List<Meal>? meals,
|
||||
List<Meal> meals,
|
||||
String? comment,
|
||||
DateTime? wakeup,
|
||||
DateTime? retire});
|
||||
@@ -66,7 +66,7 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel>
|
||||
Object? id = null,
|
||||
Object? date = null,
|
||||
Object? closed = null,
|
||||
Object? meals = freezed,
|
||||
Object? meals = null,
|
||||
Object? comment = freezed,
|
||||
Object? wakeup = freezed,
|
||||
Object? retire = freezed,
|
||||
@@ -84,10 +84,10 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel>
|
||||
? _value.closed
|
||||
: closed // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
meals: freezed == meals
|
||||
meals: null == meals
|
||||
? _value.meals
|
||||
: meals // ignore: cast_nullable_to_non_nullable
|
||||
as List<Meal>?,
|
||||
as List<Meal>,
|
||||
comment: freezed == comment
|
||||
? _value.comment
|
||||
: comment // ignore: cast_nullable_to_non_nullable
|
||||
@@ -116,7 +116,7 @@ abstract class _$$DiaryModelImplCopyWith<$Res>
|
||||
{int id,
|
||||
DateTime date,
|
||||
int closed,
|
||||
List<Meal>? meals,
|
||||
List<Meal> meals,
|
||||
String? comment,
|
||||
DateTime? wakeup,
|
||||
DateTime? retire});
|
||||
@@ -136,7 +136,7 @@ class __$$DiaryModelImplCopyWithImpl<$Res>
|
||||
Object? id = null,
|
||||
Object? date = null,
|
||||
Object? closed = null,
|
||||
Object? meals = freezed,
|
||||
Object? meals = null,
|
||||
Object? comment = freezed,
|
||||
Object? wakeup = freezed,
|
||||
Object? retire = freezed,
|
||||
@@ -154,10 +154,10 @@ class __$$DiaryModelImplCopyWithImpl<$Res>
|
||||
? _value.closed
|
||||
: closed // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
meals: freezed == meals
|
||||
meals: null == meals
|
||||
? _value._meals
|
||||
: meals // ignore: cast_nullable_to_non_nullable
|
||||
as List<Meal>?,
|
||||
as List<Meal>,
|
||||
comment: freezed == comment
|
||||
? _value.comment
|
||||
: comment // ignore: cast_nullable_to_non_nullable
|
||||
@@ -181,7 +181,7 @@ class _$DiaryModelImpl implements _DiaryModel {
|
||||
{required this.id,
|
||||
required this.date,
|
||||
required this.closed,
|
||||
required final List<Meal>? meals,
|
||||
required final List<Meal> meals,
|
||||
this.comment,
|
||||
this.wakeup,
|
||||
this.retire})
|
||||
@@ -196,14 +196,12 @@ class _$DiaryModelImpl implements _DiaryModel {
|
||||
final DateTime date;
|
||||
@override
|
||||
final int closed;
|
||||
final List<Meal>? _meals;
|
||||
final List<Meal> _meals;
|
||||
@override
|
||||
List<Meal>? get meals {
|
||||
final value = _meals;
|
||||
if (value == null) return null;
|
||||
List<Meal> get meals {
|
||||
if (_meals is EqualUnmodifiableListView) return _meals;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(value);
|
||||
return EqualUnmodifiableListView(_meals);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -256,7 +254,7 @@ abstract class _DiaryModel implements DiaryModel {
|
||||
{required final int id,
|
||||
required final DateTime date,
|
||||
required final int closed,
|
||||
required final List<Meal>? meals,
|
||||
required final List<Meal> meals,
|
||||
final String? comment,
|
||||
final DateTime? wakeup,
|
||||
final DateTime? retire}) = _$DiaryModelImpl;
|
||||
@@ -271,7 +269,7 @@ abstract class _DiaryModel implements DiaryModel {
|
||||
@override
|
||||
int get closed;
|
||||
@override
|
||||
List<Meal>? get meals;
|
||||
List<Meal> get meals;
|
||||
@override
|
||||
String? get comment;
|
||||
@override
|
||||
|
||||
@@ -11,8 +11,8 @@ _$DiaryModelImpl _$$DiaryModelImplFromJson(Map<String, dynamic> json) =>
|
||||
id: (json['id'] as num).toInt(),
|
||||
date: DateTime.parse(json['date'] as String),
|
||||
closed: (json['closed'] as num).toInt(),
|
||||
meals: (json['meals'] as List<dynamic>?)
|
||||
?.map((e) => Meal.fromJson(e as Map<String, dynamic>))
|
||||
meals: (json['meals'] as List<dynamic>)
|
||||
.map((e) => Meal.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
comment: json['comment'] as String?,
|
||||
wakeup: json['wakeup'] == null
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
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/repositories/diary_repository.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
@@ -55,8 +56,13 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
try {
|
||||
Map<String, int> data = await diaryRepository.getDiaryID();
|
||||
final int? diaryID = data['id'];
|
||||
final DiaryModel diary = await diaryRepository.getDiary(diaryID ?? 45);
|
||||
final Meal currentMeal = diary.meals[0];
|
||||
emit(DiaryState.loaded(
|
||||
diary: await diaryRepository.getDiary(diaryID ?? 45),
|
||||
diary: diary,
|
||||
currentMeal: currentMeal,
|
||||
portions: currentMeal.portions,
|
||||
photos: currentMeal.photos,
|
||||
commentController: TextEditingController(),
|
||||
productNameController: TextEditingController(),
|
||||
productQuantityController: TextEditingController(),
|
||||
@@ -69,8 +75,9 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
moodExpanded: false,
|
||||
isLoading: false,
|
||||
isAdded: false,
|
||||
recommendedChartValues: [0, 0, 0, 0],
|
||||
consumedChartValues: [0, 0, 0, 0]));
|
||||
autocompleteList: [],
|
||||
recommendedChartValues: [1, 1, 1, 1],
|
||||
consumedChartValues: [1, 1, 1, 1]));
|
||||
} catch (e) {
|
||||
emit(DiaryState.error(errorMessage: e.toString()));
|
||||
print(e);
|
||||
@@ -143,13 +150,13 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
// Отправляем данные по HTTP маршруту и ждем ответ
|
||||
var response = await sendSatietyData(
|
||||
event.selectedElement,
|
||||
currentState.currentMeal?.id,
|
||||
currentState.currentMeal.id,
|
||||
currentState.diary.id,
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
print(
|
||||
'Satiety change success! meal_id: ${currentState.currentMeal?.id}, mood: ${event.selectedElement}',
|
||||
'Satiety change success! meal_id: ${currentState.currentMeal.id}, mood: ${event.selectedElement}',
|
||||
);
|
||||
emit(updatedState); // Передаем обновленное состояние в emit
|
||||
}
|
||||
@@ -189,13 +196,13 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
// Отправляем данные по HTTP маршруту и ждем ответ
|
||||
var response = await sendMoodData(
|
||||
event.selectedElement,
|
||||
currentState.currentMeal?.id,
|
||||
currentState.currentMeal.id,
|
||||
currentState.diary.id,
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
print(
|
||||
'Mood change success! meal_id: ${currentState.currentMeal?.id}, mood: ${event.selectedElement}',
|
||||
'Mood change success! meal_id: ${currentState.currentMeal.id}, mood: ${event.selectedElement}',
|
||||
);
|
||||
emit(updatedState); // Передаем обновленное состояние в emit
|
||||
}
|
||||
@@ -359,8 +366,8 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
) async {
|
||||
if (state is DiaryStateLoaded) {
|
||||
var currentState = state as DiaryStateLoaded;
|
||||
Meal? meal = currentState.diary.meals!
|
||||
.firstWhere((meal) => meal.id == event.value);
|
||||
Meal? meal =
|
||||
currentState.diary.meals.firstWhere((meal) => meal.id == event.value);
|
||||
|
||||
DiaryStateLoaded updatedState = currentState.copyWith(
|
||||
currentMeal: event.value,
|
||||
@@ -431,7 +438,7 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
currentState.productNameController?.text,
|
||||
currentState.portionController?.id == 0 ? 'pcs' : 'gr',
|
||||
int.parse(currentState.productQuantityController!.text),
|
||||
currentState.currentMeal!.id,
|
||||
currentState.currentMeal.id,
|
||||
currentState.diary.id,
|
||||
);
|
||||
|
||||
@@ -523,7 +530,7 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
var currentState = state as DiaryStateLoaded;
|
||||
|
||||
int? mealId =
|
||||
currentState.currentMeal?.id; // Rename id to mealId for clarity
|
||||
currentState.currentMeal.id; // Rename id to mealId for clarity
|
||||
|
||||
var response = await sendRemovePortion(
|
||||
event.portionId,
|
||||
@@ -570,7 +577,7 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
var response = await sendRemovePhoto(
|
||||
event.path,
|
||||
event.photoID,
|
||||
currentState.currentMeal?.id,
|
||||
currentState.currentMeal.id,
|
||||
currentState.diary.id,
|
||||
);
|
||||
print(response.statusCode);
|
||||
@@ -668,7 +675,7 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
await uploadImageToServer(
|
||||
event.image.path,
|
||||
currentState.diary.id,
|
||||
currentState.currentMeal!.id,
|
||||
currentState.currentMeal.id,
|
||||
);
|
||||
await reloadScreen(event, emit);
|
||||
}
|
||||
|
||||
@@ -18,23 +18,23 @@ abstract class DiaryState with _$DiaryState {
|
||||
const factory DiaryState.loaded({
|
||||
required DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
required List<dynamic> autocompleteList,
|
||||
required List<int> recommendedChartValues,
|
||||
required List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
required List<Portion> portions,
|
||||
required List<Photo> photos,
|
||||
required Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
required TextEditingController? commentController,
|
||||
required TextEditingController? productNameController,
|
||||
required TextEditingController? productQuantityController,
|
||||
required TextEditingController? caloriesController,
|
||||
required TextEditingController? fatsController,
|
||||
required TextEditingController? proteinsController,
|
||||
required TextEditingController? carbsController,
|
||||
required TextEditingController commentController,
|
||||
required TextEditingController productNameController,
|
||||
required TextEditingController productQuantityController,
|
||||
required TextEditingController caloriesController,
|
||||
required TextEditingController fatsController,
|
||||
required TextEditingController proteinsController,
|
||||
required TextEditingController carbsController,
|
||||
int? selectedMood,
|
||||
int? selectedSatiety,
|
||||
required bool wakeupExpanded,
|
||||
|
||||
@@ -23,12 +23,12 @@ mixin _$DiaryState {
|
||||
required TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -58,12 +58,12 @@ mixin _$DiaryState {
|
||||
TResult? Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -93,12 +93,12 @@ mixin _$DiaryState {
|
||||
TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -210,12 +210,12 @@ class _$DiaryStateImpl implements _DiaryState {
|
||||
required TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -248,12 +248,12 @@ class _$DiaryStateImpl implements _DiaryState {
|
||||
TResult? Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -286,12 +286,12 @@ class _$DiaryStateImpl implements _DiaryState {
|
||||
TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -405,12 +405,12 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
required TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -443,12 +443,12 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
TResult? Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -481,12 +481,12 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -566,12 +566,12 @@ abstract class _$$DiaryStateLoadedImplCopyWith<$Res> {
|
||||
$Res call(
|
||||
{DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -592,7 +592,7 @@ abstract class _$$DiaryStateLoadedImplCopyWith<$Res> {
|
||||
bool isAdded});
|
||||
|
||||
$DiaryModelCopyWith<$Res> get diary;
|
||||
$MealCopyWith<$Res>? get currentMeal;
|
||||
$MealCopyWith<$Res> get currentMeal;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -608,12 +608,12 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res>
|
||||
$Res call({
|
||||
Object? diary = null,
|
||||
Object? diaryDate = freezed,
|
||||
Object? autocompleteList = freezed,
|
||||
Object? autocompleteList = null,
|
||||
Object? recommendedChartValues = null,
|
||||
Object? consumedChartValues = null,
|
||||
Object? portions = freezed,
|
||||
Object? photos = freezed,
|
||||
Object? currentMeal = freezed,
|
||||
Object? portions = null,
|
||||
Object? photos = null,
|
||||
Object? currentMeal = null,
|
||||
Object? portionController = freezed,
|
||||
Object? wakeupController = freezed,
|
||||
Object? retireController = freezed,
|
||||
@@ -642,10 +642,10 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res>
|
||||
? _value.diaryDate
|
||||
: diaryDate // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
autocompleteList: freezed == autocompleteList
|
||||
autocompleteList: null == autocompleteList
|
||||
? _value._autocompleteList
|
||||
: autocompleteList // ignore: cast_nullable_to_non_nullable
|
||||
as List<dynamic>?,
|
||||
as List<dynamic>,
|
||||
recommendedChartValues: null == recommendedChartValues
|
||||
? _value._recommendedChartValues
|
||||
: recommendedChartValues // ignore: cast_nullable_to_non_nullable
|
||||
@@ -654,18 +654,18 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res>
|
||||
? _value._consumedChartValues
|
||||
: consumedChartValues // ignore: cast_nullable_to_non_nullable
|
||||
as List<int>,
|
||||
portions: freezed == portions
|
||||
portions: null == portions
|
||||
? _value._portions
|
||||
: portions // ignore: cast_nullable_to_non_nullable
|
||||
as List<Portion>?,
|
||||
photos: freezed == photos
|
||||
as List<Portion>,
|
||||
photos: null == photos
|
||||
? _value._photos
|
||||
: photos // ignore: cast_nullable_to_non_nullable
|
||||
as List<Photo>?,
|
||||
currentMeal: freezed == currentMeal
|
||||
as List<Photo>,
|
||||
currentMeal: null == currentMeal
|
||||
? _value.currentMeal
|
||||
: currentMeal // ignore: cast_nullable_to_non_nullable
|
||||
as Meal?,
|
||||
as Meal,
|
||||
portionController: freezed == portionController
|
||||
? _value.portionController
|
||||
: portionController // ignore: cast_nullable_to_non_nullable
|
||||
@@ -751,12 +751,8 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res>
|
||||
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$MealCopyWith<$Res>? get currentMeal {
|
||||
if (_value.currentMeal == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $MealCopyWith<$Res>(_value.currentMeal!, (value) {
|
||||
$MealCopyWith<$Res> get currentMeal {
|
||||
return $MealCopyWith<$Res>(_value.currentMeal, (value) {
|
||||
return _then(_value.copyWith(currentMeal: value));
|
||||
});
|
||||
}
|
||||
@@ -768,12 +764,12 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
const _$DiaryStateLoadedImpl(
|
||||
{required this.diary,
|
||||
this.diaryDate,
|
||||
final List<dynamic>? autocompleteList,
|
||||
required final List<dynamic> autocompleteList,
|
||||
required final List<int> recommendedChartValues,
|
||||
required final List<int> consumedChartValues,
|
||||
final List<Portion>? portions,
|
||||
final List<Photo>? photos,
|
||||
this.currentMeal,
|
||||
required final List<Portion> portions,
|
||||
required final List<Photo> photos,
|
||||
required this.currentMeal,
|
||||
this.portionController,
|
||||
this.wakeupController,
|
||||
this.retireController,
|
||||
@@ -802,15 +798,13 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
final DiaryModel diary;
|
||||
@override
|
||||
final String? diaryDate;
|
||||
final List<dynamic>? _autocompleteList;
|
||||
final List<dynamic> _autocompleteList;
|
||||
@override
|
||||
List<dynamic>? get autocompleteList {
|
||||
final value = _autocompleteList;
|
||||
if (value == null) return null;
|
||||
List<dynamic> get autocompleteList {
|
||||
if (_autocompleteList is EqualUnmodifiableListView)
|
||||
return _autocompleteList;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(value);
|
||||
return EqualUnmodifiableListView(_autocompleteList);
|
||||
}
|
||||
|
||||
final List<int> _recommendedChartValues;
|
||||
@@ -831,28 +825,24 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
return EqualUnmodifiableListView(_consumedChartValues);
|
||||
}
|
||||
|
||||
final List<Portion>? _portions;
|
||||
final List<Portion> _portions;
|
||||
@override
|
||||
List<Portion>? get portions {
|
||||
final value = _portions;
|
||||
if (value == null) return null;
|
||||
List<Portion> get portions {
|
||||
if (_portions is EqualUnmodifiableListView) return _portions;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(value);
|
||||
return EqualUnmodifiableListView(_portions);
|
||||
}
|
||||
|
||||
final List<Photo>? _photos;
|
||||
final List<Photo> _photos;
|
||||
@override
|
||||
List<Photo>? get photos {
|
||||
final value = _photos;
|
||||
if (value == null) return null;
|
||||
List<Photo> get photos {
|
||||
if (_photos is EqualUnmodifiableListView) return _photos;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(value);
|
||||
return EqualUnmodifiableListView(_photos);
|
||||
}
|
||||
|
||||
@override
|
||||
final Meal? currentMeal;
|
||||
final Meal currentMeal;
|
||||
@override
|
||||
final SelectionPopupModel? portionController;
|
||||
@override
|
||||
@@ -997,12 +987,12 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
required TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -1061,12 +1051,12 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
TResult? Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -1125,12 +1115,12 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -1227,12 +1217,12 @@ abstract class DiaryStateLoaded implements DiaryState {
|
||||
const factory DiaryStateLoaded(
|
||||
{required final DiaryModel diary,
|
||||
final String? diaryDate,
|
||||
final List<dynamic>? autocompleteList,
|
||||
required final List<dynamic> autocompleteList,
|
||||
required final List<int> recommendedChartValues,
|
||||
required final List<int> consumedChartValues,
|
||||
final List<Portion>? portions,
|
||||
final List<Photo>? photos,
|
||||
final Meal? currentMeal,
|
||||
required final List<Portion> portions,
|
||||
required final List<Photo> photos,
|
||||
required final Meal currentMeal,
|
||||
final SelectionPopupModel? portionController,
|
||||
final TimeOfDay? wakeupController,
|
||||
final TimeOfDay? retireController,
|
||||
@@ -1254,12 +1244,12 @@ abstract class DiaryStateLoaded implements DiaryState {
|
||||
|
||||
DiaryModel get diary;
|
||||
String? get diaryDate;
|
||||
List<dynamic>? get autocompleteList;
|
||||
List<dynamic> get autocompleteList;
|
||||
List<int> get recommendedChartValues;
|
||||
List<int> get consumedChartValues;
|
||||
List<Portion>? get portions;
|
||||
List<Photo>? get photos;
|
||||
Meal? get currentMeal;
|
||||
List<Portion> get portions;
|
||||
List<Photo> get photos;
|
||||
Meal get currentMeal;
|
||||
SelectionPopupModel? get portionController;
|
||||
TimeOfDay? get wakeupController;
|
||||
TimeOfDay? get retireController;
|
||||
@@ -1354,12 +1344,12 @@ class _$DiaryStateErrorImpl implements DiaryStateError {
|
||||
required TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -1392,12 +1382,12 @@ class _$DiaryStateErrorImpl implements DiaryStateError {
|
||||
TResult? Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
@@ -1430,12 +1420,12 @@ class _$DiaryStateErrorImpl implements DiaryStateError {
|
||||
TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
List<dynamic>? autocompleteList,
|
||||
List<dynamic> autocompleteList,
|
||||
List<int> recommendedChartValues,
|
||||
List<int> consumedChartValues,
|
||||
List<Portion>? portions,
|
||||
List<Photo>? photos,
|
||||
Meal? currentMeal,
|
||||
List<Portion> portions,
|
||||
List<Photo> photos,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel? portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
|
||||
@@ -274,8 +274,7 @@ class DiaryScreen extends StatelessWidget {
|
||||
_buildMeal(BuildContext context, DiaryStateLoaded state) {
|
||||
final digitsOnly = FilteringTextInputFormatter.digitsOnly;
|
||||
List<String> _options =
|
||||
state.autocompleteList!.map((dynamic item) => item as String).toList();
|
||||
//print(_options);
|
||||
state.autocompleteList.map((dynamic item) => item as String).toList();
|
||||
FocusNode focusNodeName = FocusNode();
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
@@ -350,7 +349,6 @@ class DiaryScreen extends StatelessWidget {
|
||||
horizontal: 10.h,
|
||||
vertical: 9.v,
|
||||
),
|
||||
defaultValue: mealsToDropdown(diary.meals)[0],
|
||||
onChanged: changeMeal(context, state),
|
||||
);
|
||||
},
|
||||
@@ -448,7 +446,6 @@ class DiaryScreen extends StatelessWidget {
|
||||
SelectionPopupModel(title: "gr"),
|
||||
SelectionPopupModel(title: "pcs")
|
||||
],
|
||||
defaultValue: SelectionPopupModel(title: "gr"),
|
||||
onChanged: changePortion(context, state),
|
||||
);
|
||||
},
|
||||
@@ -461,7 +458,7 @@ class DiaryScreen extends StatelessWidget {
|
||||
SizedBox(height: 30.v),
|
||||
_buildAddProduct(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
...state.portions!
|
||||
...state.portions
|
||||
.map((portion) => _buildProduct(context, portion))
|
||||
.toList(),
|
||||
SizedBox(height: 30.v),
|
||||
@@ -673,12 +670,12 @@ class DiaryScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
_buildCarousel(BuildContext context, DiaryStateLoaded state) {
|
||||
if (state.currentMeal!.photos.isEmpty) {
|
||||
if (state.currentMeal.photos.isEmpty) {
|
||||
return Text("Фото нет");
|
||||
} else {
|
||||
return CarouselSlider(
|
||||
options: CarouselOptions(height: 340.0),
|
||||
items: state.currentMeal!.photos.map<Widget>((photo) {
|
||||
items: state.currentMeal.photos.map<Widget>((photo) {
|
||||
return _buildPhoto(
|
||||
context, photo); // Assuming photos are stored as strings
|
||||
}).toList(),
|
||||
@@ -1314,7 +1311,7 @@ List<SelectionPopupModel> mealsToDropdown(List<Meal>? meals) {
|
||||
return meals!
|
||||
.map((meal) => SelectionPopupModel(
|
||||
id: meal.id,
|
||||
title: "Прием пищи ${meal.id}",
|
||||
title: "Прием пищи ${meal.type}",
|
||||
isSelected: false,
|
||||
))
|
||||
.toList();
|
||||
|
||||
Reference in New Issue
Block a user