Skip to content

Commit

Permalink
✏️ Add kNotificationSheetKeepOff constant to track sheet notification…
Browse files Browse the repository at this point in the history
… to show or not
  • Loading branch information
iqfareez committed Mar 31, 2024
1 parent a62c51c commit 0ac70dd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const kTasbihGradientColour = "tasbihColours";
const kNoAdsStartTime = "noAdsStartTime";
// store current user location name to be consumed by homescreen widget
const kWidgetLocation = "widgetLocation";
const kNotificationSheetKeepOff = "notifSheetKeepOff";

// API base
const kApiBaseUrl = 'mpt-server.vercel.app';
Expand Down
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ void initGetStorage() {
final localeName = Platform.localeName.split('_').first;
get.writeIfNull(kAppLanguage, localeName == "ms" ? "ms" : "en");
get.writeIfNull(kAppTheme, ThemeMode.light.name);
get.writeIfNull(kNotificationSheetKeepOff, false);
}

/// Launcher icon shortcuts
Expand Down
5 changes: 5 additions & 0 deletions lib/views/app_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class _AppBodyState extends State<AppBody> {
final isNotificationGranted = await Permission.notification.status;
debugPrint('Notification permission status: $isNotificationGranted');

// kalau user dah kata keep off, maka keep off je, takyah tnjuk any of this sheets
if (GetStorage().read(kNotificationSheetKeepOff)) return;

if (!isNotificationGranted.isGranted) {
final PermissionStatus? status = await showModalBottomSheet(
context: context,
Expand All @@ -91,6 +94,8 @@ class _AppBodyState extends State<AppBody> {
Navigator.pop(context, res);
},
onCancelModal: () {
// mark that the user doesn't want to be notified
GetStorage().write(kNotificationSheetKeepOff, true);
Navigator.pop(context);
},
);
Expand Down
10 changes: 7 additions & 3 deletions lib/views/settings/notification_page_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,13 @@ class _NotificationPageSettingState extends State<NotificationPageSetting> {
Icon(Icons.launch_rounded),
],
),
onTap: () => AppSettings.openAppSettings(
type: AppSettingsType.notification,
),
onTap: () {
// Kalau user tekan part ni, maybe dia berminat nak turn on notification, so
// disable keep off sheet notification [tengok dalam app_body.dart]
GetStorage().write(kNotificationSheetKeepOff, false);

AppSettings.openAppSettings(type: AppSettingsType.notification);
},
),
),
Padding(
Expand Down

0 comments on commit 0ac70dd

Please sign in to comment.