added diets to diary

This commit is contained in:
Username1548
2025-05-27 23:30:36 +07:00
parent b4dd9b3a3a
commit c36aabd9a4
12 changed files with 216 additions and 23 deletions

View File

@@ -49,12 +49,13 @@ class _CalendarWidgetState extends State<CalendarWidget> {
leftChevronVisible: false,
rightChevronVisible: false,
),
onDaySelected: (selectedDay, focusedDay) {
onDaySelected: (selectedDay, focusedDay) async {
if (!isSameDay(_selectedDay, selectedDay)) {
final today = DateTime.now();
if (selectedDay.isAfter(today)) {
if ((state is DiaryStateLoaded)) {
if (!state.diary.typeOfDiary.hasChosenDiet) {
final result = await context.read<DiaryCubit>().setSelectedDay(_selectedDay, forDietOnly: true);
if (result == false && context.mounted) {
showErrorDialog(context, title: s.want_to_see_tomorrow, description: s.can_not_see_next_day);
return;
}
@@ -62,11 +63,11 @@ class _CalendarWidgetState extends State<CalendarWidget> {
_selectedDay = selectedDay;
_focusedDay = focusedDay;
});
context.read<DiaryCubit>().setSelectedDay(_selectedDay, forDietOnly: true);
return;
}
if (state is DiaryStateLoadedTomorrowWithDiet) {
if (!state.diary.typeOfDiary.hasChosenDiet) {
final result = await context.read<DiaryCubit>().setSelectedDay(_selectedDay, forDietOnly: true);
if (result == false && context.mounted) {
showErrorDialog(context, title: s.want_to_see_tomorrow, description: s.can_not_see_next_day);
return;
}
@@ -74,7 +75,6 @@ class _CalendarWidgetState extends State<CalendarWidget> {
_selectedDay = selectedDay;
_focusedDay = focusedDay;
});
context.read<DiaryCubit>().setSelectedDay(_selectedDay, forDietOnly: true);
return;
}
}