Skip to content
This repository was archived by the owner on Apr 3, 2025. It is now read-only.

Commit da0c44c

Browse files
committed
feat(notifications): option to disable in-app notifications
1 parent de9281c commit da0c44c

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

assets/localization/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@
387387
"settings.EmailSentSuccessMessage": "An email to reset your password has been sent!",
388388
"settings.EmailUpdated": "Email Updated",
389389
"settings.EmailValidation": "Invalid Email Address",
390+
"settings.EnableInAppNotifications": "Enable In-App Notifications",
390391
"settings.EnableModule": "Enable {}",
391392
"settings.EnabledProfile": "Enabled Profile",
392393
"settings.EncryptionKey": "Encryption Key",

lib/core/database/luna_database.dart

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ enum LunaDatabaseValue {
2020
QUICK_ACTIONS_SEARCH,
2121
USE_24_HOUR_TIME,
2222
DEFAULT_LAUNCH_MODULE,
23+
ENABLE_IN_APP_NOTIFICATIONS,
2324
}
2425

2526
class LunaDatabase extends LunaModuleDatabase {
@@ -167,6 +168,8 @@ extension LunaDatabaseValueExtension on LunaDatabaseValue {
167168
return value is LunaModule;
168169
case LunaDatabaseValue.NETWORKING_TLS_VALIDATION:
169170
return value is bool;
171+
case LunaDatabaseValue.ENABLE_IN_APP_NOTIFICATIONS:
172+
return value is bool;
170173
}
171174
}
172175

@@ -208,6 +211,8 @@ extension LunaDatabaseValueExtension on LunaDatabaseValue {
208211
return LunaModule.DASHBOARD;
209212
case LunaDatabaseValue.NETWORKING_TLS_VALIDATION:
210213
return false;
214+
case LunaDatabaseValue.ENABLE_IN_APP_NOTIFICATIONS:
215+
return true;
211216
}
212217
}
213218
}

lib/firebase/messaging.dart

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class LunaFirebaseMessaging {
7979
/// This listens on [FirebaseMessaging.onMessage], where the application must be open and in the foreground.
8080
StreamSubscription<RemoteMessage> registerOnMessageListener() {
8181
return onMessage.listen((message) {
82+
if (LunaDatabaseValue.ENABLE_IN_APP_NOTIFICATIONS.data) return;
83+
8284
LunaModule? module = LunaModule.DASHBOARD.fromKey(message.data['module']);
8385
showLunaSnackBar(
8486
title: message.notification?.title ?? 'Unknown Content',

lib/modules/settings/routes/notifications/route.dart

+13
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,25 @@ class _State extends State<_Widget> with LunaScrollControllerMixin {
6363
trailing: const LunaIconButton.arrow(),
6464
onTap: LunaLinks.NOTIFICATIONS_GETTING_STARTED.launch,
6565
),
66+
_enableInAppNotifications(),
6667
LunaDivider(),
6768
..._modules(),
6869
],
6970
);
7071
}
7172

73+
Widget _enableInAppNotifications() {
74+
return LunaBlock(
75+
title: 'settings.EnableInAppNotifications'.tr(),
76+
trailing: LunaDatabaseValue.ENABLE_IN_APP_NOTIFICATIONS.listen(
77+
builder: (context, box, _) => LunaSwitch(
78+
value: LunaDatabaseValue.ENABLE_IN_APP_NOTIFICATIONS.data,
79+
onChanged: LunaDatabaseValue.ENABLE_IN_APP_NOTIFICATIONS.put,
80+
),
81+
),
82+
);
83+
}
84+
7285
List<Widget> _modules() {
7386
List<SettingsNotificationsModuleTile> modules = [];
7487
for (LunaModule module in LunaModule.values) {

localization/settings/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
"settings.EmailSentSuccessMessage": "An email to reset your password has been sent!",
122122
"settings.EmailUpdated": "Email Updated",
123123
"settings.EmailValidation": "Invalid Email Address",
124+
"settings.EnableInAppNotifications": "Enable In-App Notifications",
124125
"settings.EnableModule": "Enable {}",
125126
"settings.EnabledProfile": "Enabled Profile",
126127
"settings.EncryptionKey": "Encryption Key",

0 commit comments

Comments
 (0)