diff --git a/lib/core/utils/settings/model.dart b/lib/core/utils/settings/model.dart index 95c08277..fb6f4d8b 100644 --- a/lib/core/utils/settings/model.dart +++ b/lib/core/utils/settings/model.dart @@ -5,6 +5,7 @@ class AgendaPageSettings { int lessonReminderDelay; bool enableDNDWhenOnGoingNotifEnabled; bool disableAtDayEnd; + bool hideSaturdayAndSunday; AgendaPageSettings({ required this.lighteningOverride, @@ -13,6 +14,7 @@ class AgendaPageSettings { required this.lessonReminderDelay, required this.enableDNDWhenOnGoingNotifEnabled, required this.disableAtDayEnd, + required this.hideSaturdayAndSunday, }); factory AgendaPageSettings.fromJson(Map json) => @@ -25,6 +27,7 @@ class AgendaPageSettings { enableDNDWhenOnGoingNotifEnabled: (json['enableDNDWhenOnGoingNotifEnabled'] as bool?) ?? false, disableAtDayEnd: (json['disableAtDayEnd'] as bool?) == false, + hideSaturdayAndSunday: (json['hideSaturdayAndSunday'] as bool?) ?? false, ); Map toJson() => { @@ -34,6 +37,7 @@ class AgendaPageSettings { 'lessonReminderDelay': lessonReminderDelay, 'enableDNDWhenOnGoingNotifEnabled': enableDNDWhenOnGoingNotifEnabled, 'disableAtDayEnd': disableAtDayEnd, + 'hideSaturdayAndSunday': hideSaturdayAndSunday, }; } diff --git a/lib/ui/screens/agenda/widgets/agenda_settings.dart b/lib/ui/screens/agenda/widgets/agenda_settings.dart index 41aa1c36..9848ad97 100644 --- a/lib/ui/screens/agenda/widgets/agenda_settings.dart +++ b/lib/ui/screens/agenda/widgets/agenda_settings.dart @@ -86,6 +86,18 @@ class _AgendaSettingsState extends State { color: ThemeUtils.textColor(), ), ), + SwitchListTile( + value: appSys.settings.user.agendaPage.hideSaturdayAndSunday, + title: Text("Passer le samedi et le dimanche", + style: TextStyle( + fontFamily: "Asap", color: ThemeUtils.textColor(), fontSize: screenSize.size.height / 10 * 0.21)), + onChanged: (value) { + appSys.settings.user.agendaPage.hideSaturdayAndSunday = value; + appSys.saveSettings(); + setState(() {}); + }, + secondary: Icon(MdiIcons.calendarWeekend, color: ThemeUtils.textColor()), + ), if (!kIsWeb && Platform.isAndroid) ListTile( title: Text("Notification constante", diff --git a/lib/ui/screens/agenda/widgets/buttons.dart b/lib/ui/screens/agenda/widgets/buttons.dart index 69bc67eb..361bfb75 100644 --- a/lib/ui/screens/agenda/widgets/buttons.dart +++ b/lib/ui/screens/agenda/widgets/buttons.dart @@ -56,7 +56,15 @@ class _AgendaButtonsState extends State { borderRadius: BorderRadius.circular(8), onTap: () async { setState(() { - agendaDate = CalendarTime(agendaDate).startOfDay.subtract(const Duration(hours: 24)); + if (agendaDate?.weekday == DateTime.monday && appSys.settings.user.agendaPage.hideSaturdayAndSunday) { + agendaDate = CalendarTime(agendaDate) + .startOfDay + .subtract(const Duration(hours: 72)); + } else { + agendaDate = CalendarTime(agendaDate) + .startOfDay + .subtract(const Duration(hours: 24)); + } }); await widget.getLessons!(agendaDate); }, @@ -140,7 +148,15 @@ class _AgendaButtonsState extends State { borderRadius: BorderRadius.circular(screenSize.size.width / 5 * 0.15), onTap: () async { setState(() { - agendaDate = CalendarTime(agendaDate).startOfDay.add(const Duration(hours: 25)); + if (agendaDate?.weekday == DateTime.friday && appSys.settings.user.agendaPage.hideSaturdayAndSunday) { + agendaDate = CalendarTime(agendaDate) + .startOfDay + .add(const Duration(hours: 73)); + } else { + agendaDate = CalendarTime(agendaDate) + .startOfDay + .add(const Duration(hours: 25)); + } }); await widget.getLessons!(agendaDate); },