gdelataillade / alarm

A Flutter plugin to easily manage alarms on iOS and Android
https://pub.dev/packages/alarm
MIT License
132 stars 86 forks source link

when tap cancel alarm button so redirect to ring screen this is wrong #259

Closed BhautikVaghasiya closed 1 month ago

BhautikVaghasiya commented 1 month ago

when tap the cancel alarm button so redirects to ring screen this is the wrong @override void initState() { super.initState(); AlarmPermissions.checkNotificationPermission(); if (Alarm.android) { AlarmPermissions.checkAndroidScheduleExactAlarmPermission(); } loadAlarms(); ringSubscription ??= Alarm.ringStream.stream.listen(navigateToRingScreen); updateSubscription ??= Alarm.updateStream.stream.listen((_) { loadAlarms(); }); }

gdelataillade commented 1 month ago

Provide steps to reproduce please.

gdelataillade commented 1 month ago

I don't understand. If you want to run code when alarm rings then modify the navigateToRingScreen callback.

BhautikVaghasiya commented 1 month ago

ringSubscription ??= Alarm.ringStream.stream.listen(navigateToRingScreen); if user tap to cancel alarm button so not navigateToRingScreen.

gdelataillade commented 1 month ago

In the example app, the cancel button means that you want to cancel the editing or creating of the alarm. If you want to cancel the alarm you have to press the stop button.

gdelataillade commented 1 month ago

Ok I understand now.

You need to listen for the Alarm.updateStream and in its callback you need to check if an alarm is ringing. If not, then navigate back to your home screen.

BhautikVaghasiya commented 1 month ago

https://github.com/user-attachments/assets/fe4a74cf-fa74-4802-8579-3d3369844c69 how to change font size. recived alarm notification.

gdelataillade commented 1 month ago

No, it is not possible (tell me if you think I'm wrong) to change the font size of the notification action buttons. The action buttons in notifications have a fixed style defined by the system and cannot be customized.

gdelataillade commented 1 month ago

Use Alarm.isRinging method.

gdelataillade commented 1 month ago

Set this:

updateSubscription ??= Alarm.updateStream.stream.listen(onAlarmsUpdate);

with callback:

  Future<void> onAlarmsUpdate(int id) async {
    loadAlarms();

    var isAnyAlarmRinging = false;
    for (final alarm in alarms) {
      final alarmIsRinging = await Alarm.isRinging(alarm.id);
      if (alarmIsRinging) {
        isAnyAlarmRinging = true;
        break;
      }
    }

    if (mounted && !isAnyAlarmRinging && Navigator.canPop(context)) {
      Navigator.pop(context);
    }
  }