-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add modal sheet on app startup to ask missing notification permissions
Showing
5 changed files
with
227 additions
and
12 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
lib/features/home/views/components/exact_alarm_permission_off_sheet.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class ExactAlarmPermissionOffSheet extends StatelessWidget { | ||
const ExactAlarmPermissionOffSheet({ | ||
super.key, | ||
required this.onGrantPermission, | ||
required this.onCancelModal, | ||
}); | ||
|
||
/// What will happen when "Give permission" button is pressed | ||
final VoidCallback onGrantPermission; | ||
|
||
/// What will happen when "Cancel" button is pressed | ||
final VoidCallback onCancelModal; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.all(16.0), | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||
children: [ | ||
const Padding( | ||
padding: EdgeInsets.all(24.0), | ||
child: Icon(Icons.notifications_active_outlined, size: 80), | ||
), | ||
const SizedBox(height: 8), | ||
const Text( | ||
'We require one more permission to trigger the notification/azan at the right time', | ||
style: TextStyle( | ||
fontSize: 18, | ||
fontWeight: FontWeight.bold, | ||
), | ||
textAlign: TextAlign.center, | ||
), | ||
const SizedBox(height: 8), | ||
const Text( | ||
'This permission is needed to push the notification at the correct time. If you say no, the app might still schedule the notification, but the delivery may be delayed.', | ||
textAlign: TextAlign.center, | ||
), | ||
const SizedBox(height: 16), | ||
ElevatedButton( | ||
style: ElevatedButton.styleFrom( | ||
backgroundColor: Theme.of(context).colorScheme.primary, | ||
foregroundColor: Theme.of(context).colorScheme.onPrimary, | ||
), | ||
onPressed: onGrantPermission, | ||
child: const Text('Grant now'), | ||
), | ||
TextButton( | ||
onPressed: onCancelModal, | ||
child: const Text('Cancel'), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
lib/features/home/views/components/notification_permission_off_sheet.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class NotificationPermissionOffSheet extends StatelessWidget { | ||
const NotificationPermissionOffSheet({ | ||
super.key, | ||
required this.onTurnOnNotification, | ||
required this.onCancelModal, | ||
}); | ||
|
||
/// What will happen when "Turn On Notification" button is pressed | ||
final VoidCallback onTurnOnNotification; | ||
|
||
/// What will happen when "Keep it off for now" button is pressed | ||
final VoidCallback onCancelModal; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.all(16.0), | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||
children: [ | ||
const Padding( | ||
padding: EdgeInsets.all(24.0), | ||
child: Icon(Icons.notifications_off_outlined, size: 80), | ||
), | ||
const SizedBox(height: 8), | ||
const Text( | ||
'Notification/Azan is turned off', | ||
style: TextStyle( | ||
fontSize: 18, | ||
fontWeight: FontWeight.bold, | ||
), | ||
textAlign: TextAlign.center, | ||
), | ||
const SizedBox(height: 8), | ||
const Text( | ||
'We may require some permissions to be able to play the notification/azan', | ||
textAlign: TextAlign.center, | ||
), | ||
const SizedBox(height: 16), | ||
ElevatedButton( | ||
style: ElevatedButton.styleFrom( | ||
backgroundColor: Theme.of(context).colorScheme.primary, | ||
foregroundColor: Theme.of(context).colorScheme.onPrimary, | ||
), | ||
onPressed: onTurnOnNotification, | ||
child: const Text('Turn On Notification'), | ||
), | ||
TextButton( | ||
onPressed: onCancelModal, | ||
child: const Text('Keep it off for now'), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71d374e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example modal sheet popups: