Skip to content

Commit

Permalink
Add skip alarm filter action
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanSarwar45 committed Apr 18, 2024
1 parent 48c6d56 commit cbed855
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions lib/alarm/screens/alarm_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class _AlarmScreenState extends State<AlarmScreen> {
}
}

Future<void> _handleEnableChangeMultipleAlarms(
Future<void> _handleEnableChangeMultiple(
List<Alarm> alarms, bool value) async {
for (var alarm in alarms) {
if (!alarm.canBeDisabledWhenSnoozed && !value && alarm.isSnoozed) {
Expand All @@ -157,6 +157,13 @@ class _AlarmScreenState extends State<AlarmScreen> {
_listController.changeItems((alarms) {});
}

void _handleSkipChangeMultiple(List<Alarm> alarms, bool value) {
for (var alarm in alarms) {
alarm.setShouldSkip(value);
}
_listController.changeItems((alarms) {});
}

Future<void> _handleDismissAlarm(Alarm alarm) async {
await alarm.cancelSnooze();
await alarm.update("_handleDismissAlarm(): Alarm dismissed by user");
Expand Down Expand Up @@ -218,13 +225,25 @@ class _AlarmScreenState extends State<AlarmScreen> {
name: "Enable all filtered alarms",
icon: Icons.alarm_on_rounded,
action: (alarms) {
_handleEnableChangeMultipleAlarms(alarms, true);
_handleEnableChangeMultiple(alarms, true);
}),
ListFilterCustomAction(
name: "Disable all filtered alarms",
icon: Icons.alarm_off_rounded,
action: (alarms) {
_handleEnableChangeMultipleAlarms(alarms, false);
_handleEnableChangeMultiple(alarms, false);
}),
ListFilterCustomAction(
name: "Skip all filtered alarms",
icon: Icons.skip_next_rounded,
action: (alarms) {
_handleSkipChangeMultiple(alarms, true);
}),
ListFilterCustomAction(
name: "Cancel skip all filtered alarms",
icon: Icons.skip_next_rounded,
action: (alarms) {
_handleSkipChangeMultiple(alarms, false);
}),
]
: [],
Expand Down

0 comments on commit cbed855

Please sign in to comment.