mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-30 20:24:25 +00:00
feat(notifications): option to disable in-app notifications
This commit is contained in:
@@ -387,6 +387,7 @@
|
||||
"settings.EmailSentSuccessMessage": "An email to reset your password has been sent!",
|
||||
"settings.EmailUpdated": "Email Updated",
|
||||
"settings.EmailValidation": "Invalid Email Address",
|
||||
"settings.EnableInAppNotifications": "Enable In-App Notifications",
|
||||
"settings.EnableModule": "Enable {}",
|
||||
"settings.EnabledProfile": "Enabled Profile",
|
||||
"settings.EncryptionKey": "Encryption Key",
|
||||
|
||||
@@ -20,6 +20,7 @@ enum LunaDatabaseValue {
|
||||
QUICK_ACTIONS_SEARCH,
|
||||
USE_24_HOUR_TIME,
|
||||
DEFAULT_LAUNCH_MODULE,
|
||||
ENABLE_IN_APP_NOTIFICATIONS,
|
||||
}
|
||||
|
||||
class LunaDatabase extends LunaModuleDatabase {
|
||||
@@ -167,6 +168,8 @@ extension LunaDatabaseValueExtension on LunaDatabaseValue {
|
||||
return value is LunaModule;
|
||||
case LunaDatabaseValue.NETWORKING_TLS_VALIDATION:
|
||||
return value is bool;
|
||||
case LunaDatabaseValue.ENABLE_IN_APP_NOTIFICATIONS:
|
||||
return value is bool;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,6 +211,8 @@ extension LunaDatabaseValueExtension on LunaDatabaseValue {
|
||||
return LunaModule.DASHBOARD;
|
||||
case LunaDatabaseValue.NETWORKING_TLS_VALIDATION:
|
||||
return false;
|
||||
case LunaDatabaseValue.ENABLE_IN_APP_NOTIFICATIONS:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,8 @@ class LunaFirebaseMessaging {
|
||||
/// This listens on [FirebaseMessaging.onMessage], where the application must be open and in the foreground.
|
||||
StreamSubscription<RemoteMessage> registerOnMessageListener() {
|
||||
return onMessage.listen((message) {
|
||||
if (LunaDatabaseValue.ENABLE_IN_APP_NOTIFICATIONS.data) return;
|
||||
|
||||
LunaModule? module = LunaModule.DASHBOARD.fromKey(message.data['module']);
|
||||
showLunaSnackBar(
|
||||
title: message.notification?.title ?? 'Unknown Content',
|
||||
|
||||
@@ -63,12 +63,25 @@ class _State extends State<_Widget> with LunaScrollControllerMixin {
|
||||
trailing: const LunaIconButton.arrow(),
|
||||
onTap: LunaLinks.NOTIFICATIONS_GETTING_STARTED.launch,
|
||||
),
|
||||
_enableInAppNotifications(),
|
||||
LunaDivider(),
|
||||
..._modules(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _enableInAppNotifications() {
|
||||
return LunaBlock(
|
||||
title: 'settings.EnableInAppNotifications'.tr(),
|
||||
trailing: LunaDatabaseValue.ENABLE_IN_APP_NOTIFICATIONS.listen(
|
||||
builder: (context, box, _) => LunaSwitch(
|
||||
value: LunaDatabaseValue.ENABLE_IN_APP_NOTIFICATIONS.data,
|
||||
onChanged: LunaDatabaseValue.ENABLE_IN_APP_NOTIFICATIONS.put,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _modules() {
|
||||
List<SettingsNotificationsModuleTile> modules = [];
|
||||
for (LunaModule module in LunaModule.values) {
|
||||
|
||||
@@ -121,6 +121,7 @@
|
||||
"settings.EmailSentSuccessMessage": "An email to reset your password has been sent!",
|
||||
"settings.EmailUpdated": "Email Updated",
|
||||
"settings.EmailValidation": "Invalid Email Address",
|
||||
"settings.EnableInAppNotifications": "Enable In-App Notifications",
|
||||
"settings.EnableModule": "Enable {}",
|
||||
"settings.EnabledProfile": "Enabled Profile",
|
||||
"settings.EncryptionKey": "Encryption Key",
|
||||
|
||||
Reference in New Issue
Block a user