feat(diary) dynnapic expandlists and mood/satiety scale

This commit is contained in:
2024-02-19 09:28:25 +03:00
parent faf0439349
commit 0091e00060
2 changed files with 25 additions and 11 deletions

View File

@@ -26,7 +26,7 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
on<AddPortionEvent>(_addPortion); //пользователь нажимает "Добавить продукт"
on<RemovePortionEvent>(
_removePortion); // пользователь нажимает на крестик около продукта
on<UploadImages>(_uploadImages); //пользователь нажимает "Добавить продукт"
on<UploadImages>(_uploadImages); //пользователь нажимает "Добавить фото"
}
Future<void> _onInitialize(
@@ -97,18 +97,16 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
}*/
}
/*_expandWakeup(
ToggleWakeupExpandedEvent event, Emitter<DiaryEditLoadedState> emit) {
emit(state.copyWith(wakeupExpanded: !state.wakeupExpanded));
}*/
Future<void> _changeSatiety(
ChangeSatiety event, Emitter<DiaryEditState> emit) async {
if (state is DiaryEditLoadedState) {
var currentState = state as DiaryEditLoadedState;
emit(currentState.copyWith(selectedSatiety: event.selectedElement));
var updatedState =
currentState.copyWith(selectedSatiety: event.selectedElement);
emit(updatedState); // Передаем обновленное состояние в emit
currentState.selectedSatiety = event.selectedElement;
print(currentState.selectedSatiety);
}
}
@@ -116,8 +114,11 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
ChangeMood event, Emitter<DiaryEditState> emit) async {
if (state is DiaryEditLoadedState) {
var currentState = state as DiaryEditLoadedState;
var updatedState =
currentState.copyWith(selectedMood: event.selectedElement);
emit(updatedState); // Передаем обновленное состояние в emit
emit(currentState.copyWith(selectedMood: event.selectedElement));
currentState.selectedMood = event.selectedElement;
}
}
@@ -129,6 +130,7 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
emit(currentState.copyWith(moodExpanded: !currentState.moodExpanded));
currentState.moodExpanded = !currentState.moodExpanded;
print(currentState.moodExpanded);
}
}

View File

@@ -46,8 +46,20 @@ class DiaryEditLoadedState extends DiaryEditState {
bool wakeupExpanded;
bool moodExpanded;
@override
List<Object?> get props =>
[diaryEditModelObj, wakeupController, retireController];
List<Object?> get props => [
diaryEditModelObj,
wakeupController,
retireController,
mealNameController,
mealTimeController,
commentController,
productNameController,
productQuantityController,
selectedMood,
selectedSatiety,
wakeupExpanded,
moodExpanded
];
DiaryEditLoadedState copyWith({
DiaryEditModel? diaryEditModelObj,
TimeOfDay? wakeupController,