feat(diary) Dynamic Meal list and Meal List object

This commit is contained in:
2024-02-20 15:57:15 +03:00
parent f52c929b20
commit 3e4b683c33
6 changed files with 95 additions and 42 deletions

View File

@@ -21,6 +21,7 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
on<ChangeMood>(_changeMood); // пользователь нажимает на шкалу настроения
on<ChangeMealTime>(
_changeMealTime); // пользователь изменяет время приема пиши
on<ChangeMeal>(_changeMeal);
on<WakeupEvent>(_changeWakeup); // пользователь выбирает время пробуждения
on<RetireEvent>(_changeRetire); // пользователь выбирает время отхода ко сну
on<ToggleMoodExpandedEvent>(_toggleMood);
@@ -214,6 +215,8 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
currentState.mealTimeController = event.time;
}
}
FutureOr<void> _changeMeal(ChangeMeal event, Emitter<DiaryEditState> emit) {}
}
Future<String> uploadImageToServer(String imagePath) async {
@@ -241,3 +244,14 @@ TimeOfDay toTime(String timeStr) {
TimeOfDay timeOfDay = TimeOfDay(hour: hour, minute: minute);
return timeOfDay;
}
List<SelectionPopupModel> fillMealList() {
return [
SelectionPopupModel(id: 0, title: "Прием пищи 1", isSelected: true),
SelectionPopupModel(id: 1, title: "Прием пищи 2"),
SelectionPopupModel(id: 2, title: "Прием пищи 3"),
SelectionPopupModel(id: 3, title: "Прием пищи 4"),
SelectionPopupModel(id: 4, title: "Прием пищи 5"),
SelectionPopupModel(id: 5, title: "Прием пищи 6"),
];
}

View File

@@ -102,3 +102,14 @@ class UploadImages extends DiaryEditEvent {
@override
List<Object> get props => [image];
}
class ChangeMeal extends DiaryEditEvent {
ChangeMeal({required this.value});
SelectionPopupModel value;
@override
List<Object?> get props => [
value,
];
}

View File

@@ -29,6 +29,7 @@ class DiaryEditLoadedState extends DiaryEditState {
this.productNameController,
this.productQuantityController,
this.selectedMood,
this.currentMeal,
required this.diaryId,
required this.selectedSatiety,
required this.wakeupExpanded,
@@ -37,6 +38,7 @@ class DiaryEditLoadedState extends DiaryEditState {
DiaryEditModel? diaryEditModelObj;
String? diaryDate;
SelectionPopupModel? currentMeal;
TimeOfDay? wakeupController;
TimeOfDay? retireController;
TimeOfDay? mealTimeController;
@@ -64,10 +66,12 @@ class DiaryEditLoadedState extends DiaryEditState {
selectedSatiety,
diaryId,
wakeupExpanded,
moodExpanded
moodExpanded,
currentMeal
];
DiaryEditLoadedState copyWith({
DiaryEditModel? diaryEditModelObj,
SelectionPopupModel? currentMeal,
String? diaryDate,
TimeOfDay? wakeupController,
TimeOfDay? retireController,
@@ -97,6 +101,7 @@ class DiaryEditLoadedState extends DiaryEditState {
selectedMood: selectedMood ?? this.selectedMood,
selectedSatiety: selectedSatiety ?? this.selectedSatiety,
diaryId: diaryId ?? this.diaryId,
currentMeal: currentMeal ?? this.currentMeal,
wakeupExpanded: wakeupExpanded ?? this.wakeupExpanded,
moodExpanded: moodExpanded ?? this.moodExpanded);
}