-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡ Enhance UX for azan notification (#230)
* ⚡ Change setting azan notification to alarmClock * ⚡ Add schedule notification permission checker and requestor in Notification Setting Page * ✏️ If notification is already granted, make able to open alarm setting * ✨ New notification permission onboarding screen * ✨ Add modal sheet on app startup to ask missing notification permissions * ✨ (Onboarding page) Skip permission dialog if not needed * ♻️ (Onboarding screen) Refactor out alert dialog components * 🌐 Add localizations to permission dialogs, page, sheets, etc.
- Loading branch information
Showing
17 changed files
with
588 additions
and
271 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
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,61 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.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) { | ||
final l10n = AppLocalizations.of(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), | ||
Text( | ||
l10n.notifSheetExactAlarmTitle, | ||
style: const TextStyle( | ||
fontSize: 18, | ||
fontWeight: FontWeight.bold, | ||
), | ||
textAlign: TextAlign.center, | ||
), | ||
const SizedBox(height: 8), | ||
Text( | ||
l10n.notifSheetExactAlarmDescription, | ||
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: Text(l10n.notifSheetExactAlarmPrimaryButton), | ||
), | ||
TextButton( | ||
onPressed: onCancelModal, | ||
child: Text(l10n.notifSheetExactAlarmCancel), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
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,61 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.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) { | ||
final l10n = AppLocalizations.of(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), | ||
Text( | ||
l10n.notifSheetNotificationTitle, | ||
style: const TextStyle( | ||
fontSize: 18, | ||
fontWeight: FontWeight.bold, | ||
), | ||
textAlign: TextAlign.center, | ||
), | ||
const SizedBox(height: 8), | ||
Text( | ||
l10n.notifSheetNotificationDescription, | ||
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: Text(l10n.notifSheetNotificationPrimaryButton), | ||
), | ||
TextButton( | ||
onPressed: onCancelModal, | ||
child: Text(l10n.notifSheetNotificationCancel), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
lib/features/onboarding/views/components/autostart_setting_dialog.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,34 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
|
||
class AutostartSettingDialog extends StatelessWidget { | ||
const AutostartSettingDialog({ | ||
super.key, | ||
required this.leadingCount, | ||
required this.onSkip, | ||
required this.onGrantPermission, | ||
}); | ||
|
||
final String leadingCount; | ||
final VoidCallback onSkip; | ||
final VoidCallback onGrantPermission; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final l10n = AppLocalizations.of(context)!; | ||
return AlertDialog( | ||
title: Text(l10n.permissionDialogTitle), | ||
content: Text('$leadingCount) ${l10n.autostartDialogPermissionContent}'), | ||
actions: [ | ||
TextButton( | ||
onPressed: onSkip, | ||
child: Text(l10n.permissionDialogSkip), | ||
), | ||
TextButton( | ||
onPressed: onGrantPermission, | ||
child: Text(l10n.permissionDialogGrant), | ||
) | ||
], | ||
); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
lib/features/onboarding/views/components/notification_exact_alarm_permission_dialog.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,35 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
|
||
class NotificationExactAlarmPermissionDialog extends StatelessWidget { | ||
const NotificationExactAlarmPermissionDialog({ | ||
super.key, | ||
required this.leadingCount, | ||
required this.onSkip, | ||
required this.onGrantPermission, | ||
}); | ||
|
||
final String leadingCount; | ||
final VoidCallback onSkip; | ||
final VoidCallback onGrantPermission; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final l10n = AppLocalizations.of(context)!; | ||
return AlertDialog( | ||
title: Text(l10n.permissionDialogTitle), | ||
content: | ||
Text('$leadingCount) ${l10n.notifExactAlarmDialogPermissionContent}'), | ||
actions: [ | ||
TextButton( | ||
onPressed: onSkip, | ||
child: Text(l10n.permissionDialogSkip), | ||
), | ||
TextButton( | ||
onPressed: onGrantPermission, | ||
child: Text(l10n.permissionDialogGrant), | ||
) | ||
], | ||
); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
lib/features/onboarding/views/components/notification_permission_dialog.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,25 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
|
||
class NotificationPermissionDialog extends StatelessWidget { | ||
const NotificationPermissionDialog( | ||
{super.key, required this.leadingCount, required this.onGrantPermission}); | ||
|
||
final String leadingCount; | ||
final VoidCallback onGrantPermission; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final l10n = AppLocalizations.of(context)!; | ||
return AlertDialog( | ||
title: Text(l10n.permissionDialogTitle), | ||
content: Text('$leadingCount) ${l10n.notifDialogPermissionContent}'), | ||
actions: [ | ||
TextButton( | ||
onPressed: onGrantPermission, | ||
child: Text(l10n.permissionDialogGrant), | ||
) | ||
], | ||
); | ||
} | ||
} |
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
Oops, something went wrong.