From 2c83416ea30b8efd14d4cc6b87858b6076ec9f24 Mon Sep 17 00:00:00 2001 From: AhsanSarwar45 Date: Sun, 8 Sep 2024 23:48:31 +0500 Subject: [PATCH] Add alarm labels to different uis --- lib/alarm/logic/alarm_reminder_notifications.dart | 6 +++--- lib/alarm/screens/alarm_notification_screen.dart | 6 ++++++ lib/alarm/types/alarm.dart | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/alarm/logic/alarm_reminder_notifications.dart b/lib/alarm/logic/alarm_reminder_notifications.dart index 7989a165..9ae05cd0 100644 --- a/lib/alarm/logic/alarm_reminder_notifications.dart +++ b/lib/alarm/logic/alarm_reminder_notifications.dart @@ -15,7 +15,7 @@ Future cancelAlarmReminderNotification(int id) async { } Future createAlarmReminderNotification( - int id, DateTime time, bool tasksRequired) async { + int id, String label, DateTime time, bool tasksRequired) async { await cancelAlarmReminderNotification(id); bool shouldShow = appSettings .getGroup("Alarm") @@ -47,7 +47,7 @@ Future createAlarmReminderNotification( content: NotificationContent( id: id, channelKey: reminderNotificationChannelKey, - title: "Upcoming alarm", + title: "Upcoming alarm${label.isEmpty ? "" : ": $label"}", body: time.toTimeOfDay().formatToString(timeFormatString), category: NotificationCategory.Reminder, payload: { @@ -91,7 +91,7 @@ Future createSnoozeNotification(int id, DateTime time) async { content: NotificationContent( id: id, channelKey: reminderNotificationChannelKey, - title: "Snoozed alarm", + title: "Snoozed alarm${alarm.label.isEmpty ? "" : ": ${alarm.label}"}", body: time.toTimeOfDay().formatToString(timeFormatString), // wakeUpScreen: true, category: NotificationCategory.Reminder, diff --git a/lib/alarm/screens/alarm_notification_screen.dart b/lib/alarm/screens/alarm_notification_screen.dart index 3e3e3030..0d616f7e 100644 --- a/lib/alarm/screens/alarm_notification_screen.dart +++ b/lib/alarm/screens/alarm_notification_screen.dart @@ -121,6 +121,12 @@ class _AlarmNotificationScreenState extends State { child: Column( children: [ const Spacer(), + if (alarm.label.isNotEmpty) + Text( + alarm.label, + style: Theme.of(context).textTheme.titleMedium, + ), + const SizedBox(height: 8), const Clock( // dateTime: Date, horizontalAlignment: ElementAlignment.center, diff --git a/lib/alarm/types/alarm.dart b/lib/alarm/types/alarm.dart index cda6e805..66067aa7 100644 --- a/lib/alarm/types/alarm.dart +++ b/lib/alarm/types/alarm.dart @@ -262,7 +262,7 @@ class Alarm extends CustomizableListItem { currentScheduleDateTime != null && !shouldSkipNextAlarm) { await createAlarmReminderNotification( - id, currentScheduleDateTime!, tasks.isNotEmpty); + id, label, currentScheduleDateTime!, tasks.isNotEmpty); } else { for (var schedule in _schedules) { cancelAlarmReminderNotification(schedule.currentAlarmRunnerId);