Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Add skip saturday and sunday fonction #139

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/core/utils/settings/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class AgendaPageSettings {
int lessonReminderDelay;
bool enableDNDWhenOnGoingNotifEnabled;
bool disableAtDayEnd;
bool hideSaturdayAndSunday;

AgendaPageSettings({
required this.lighteningOverride,
Expand All @@ -13,6 +14,7 @@ class AgendaPageSettings {
required this.lessonReminderDelay,
required this.enableDNDWhenOnGoingNotifEnabled,
required this.disableAtDayEnd,
required this.hideSaturdayAndSunday,
});

factory AgendaPageSettings.fromJson(Map<String, dynamic> json) =>
Expand All @@ -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<String, Object> toJson() => {
Expand All @@ -34,6 +37,7 @@ class AgendaPageSettings {
'lessonReminderDelay': lessonReminderDelay,
'enableDNDWhenOnGoingNotifEnabled': enableDNDWhenOnGoingNotifEnabled,
'disableAtDayEnd': disableAtDayEnd,
'hideSaturdayAndSunday': hideSaturdayAndSunday,
};
}

Expand Down
12 changes: 12 additions & 0 deletions lib/ui/screens/agenda/widgets/agenda_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ class _AgendaSettingsState extends State<AgendaSettings> {
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",
Expand Down
20 changes: 18 additions & 2 deletions lib/ui/screens/agenda/widgets/buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ class _AgendaButtonsState extends State<AgendaButtons> {
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);
},
Expand Down Expand Up @@ -140,7 +148,15 @@ class _AgendaButtonsState extends State<AgendaButtons> {
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);
},
Expand Down