forked from eatvio/eatvio_app
feat: diary time of meal
This commit is contained in:
@@ -26,7 +26,7 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
|
||||
setSelectedDay(DateTime day) async {
|
||||
selectedDay = day;
|
||||
await fetchDiary();
|
||||
await fetchDiary(true);
|
||||
}
|
||||
|
||||
setSelectedMeal(int meal) {
|
||||
@@ -34,9 +34,11 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
emit((state as DiaryStateLoaded).copyWith(selectedMeal: selectedMeal));
|
||||
}
|
||||
|
||||
fetchDiary() async {
|
||||
emit(const DiaryState.loading());
|
||||
selectedMeal = 1;
|
||||
fetchDiary([bool needLoading = false]) async {
|
||||
if (needLoading) {
|
||||
emit(const DiaryState.loading());
|
||||
selectedMeal = 1;
|
||||
}
|
||||
try {
|
||||
final diaryDay = await diaryRepository.getDiaryByDate('$selectedDay');
|
||||
emit(
|
||||
@@ -173,10 +175,11 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
required int diaryId,
|
||||
required String time,
|
||||
}) async {
|
||||
return await diaryRepository.fillTime(
|
||||
await diaryRepository.fillTime(
|
||||
diaryId: diaryId,
|
||||
mealId: selectedMeal,
|
||||
time: time,
|
||||
);
|
||||
await fetchDiary();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user