diff --git a/lib/constants.dart b/lib/constants.dart index a9f9923..4bc466d 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -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'; diff --git a/lib/main.dart b/lib/main.dart index db02942..aa2fc82 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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 diff --git a/lib/views/app_body.dart b/lib/views/app_body.dart index 93bf353..916630d 100644 --- a/lib/views/app_body.dart +++ b/lib/views/app_body.dart @@ -81,6 +81,9 @@ class _AppBodyState extends State { 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, @@ -91,6 +94,8 @@ class _AppBodyState extends State { Navigator.pop(context, res); }, onCancelModal: () { + // mark that the user doesn't want to be notified + GetStorage().write(kNotificationSheetKeepOff, true); Navigator.pop(context); }, ); diff --git a/lib/views/settings/notification_page_setting.dart b/lib/views/settings/notification_page_setting.dart index 1df7232..7df79c8 100644 --- a/lib/views/settings/notification_page_setting.dart +++ b/lib/views/settings/notification_page_setting.dart @@ -176,9 +176,13 @@ class _NotificationPageSettingState extends State { 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(