Skip to content

Commit

Permalink
Add alarm labels to different uis
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanSarwar45 committed Sep 8, 2024
1 parent 482102e commit 2c83416
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/alarm/logic/alarm_reminder_notifications.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Future<void> cancelAlarmReminderNotification(int id) async {
}

Future<void> 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")
Expand Down Expand Up @@ -47,7 +47,7 @@ Future<void> 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: {
Expand Down Expand Up @@ -91,7 +91,7 @@ Future<void> 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,
Expand Down
6 changes: 6 additions & 0 deletions lib/alarm/screens/alarm_notification_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ class _AlarmNotificationScreenState extends State<AlarmNotificationScreen> {
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,
Expand Down
2 changes: 1 addition & 1 deletion lib/alarm/types/alarm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2c83416

Please sign in to comment.