Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Update notification settings design

AmanRajSinghMourya50124e3733be
diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arb
index 1ce14c4f95..409ad52ad2 100644
--- a/mobile/apps/photos/lib/l10n/intl_en.arb
+++ b/mobile/apps/photos/lib/l10n/intl_en.arb
@@ -835,9 +835,9 @@
"referrals": "Referrals",
"notifications": "Notifications",
"sharedPhotoNotifications": "New shared photos and albums",
- "sharedPhotoNotificationsExplanation": "Get notifications for new photos in shared albums you're in and for new albums shared with you.",
+ "sharedPhotoNotificationsExplanation": "New photos and albums you are in or shared with you",
"socialNotifications": "Likes and comments",
- "socialNotificationsExplanation": "Receive notifications for likes on your photos and comments on albums you're a part of",
+ "socialNotificationsExplanation": "Likes on your photos and comments on albums you are a part of",
"advanced": "Advanced",
"general": "General",
"security": "Security",
@@ -2448,13 +2448,13 @@
"newPhotosEmoji": " new πŸ“Έ",
"sorryWeHadToPauseYourBackups": "Sorry, we had to pause your backups",
"clickToInstallOurBestVersionYet": "Click to install our best version yet",
- "onThisDayNotificationExplanation": "Receive reminders about memories from this day in previous years.",
+ "onThisDayNotificationExplanation": "Memories from this day in previous years",
"addMemoriesWidgetPrompt": "Add a memories widget to your home screen to customize it here.",
"addAlbumWidgetPrompt": "Add an album widget to your home screen to customize it here.",
"addPeopleWidgetPrompt": "Add a people widget to your home screen to customize it here.",
"showTextOnWidget": "Show text on widget",
"birthdayNotifications": "Birthday notifications",
- "receiveRemindersOnBirthdays": "Receive reminders when it's someone's birthday. Tapping on the notification will take you to photos of the birthday person.",
+ "receiveRemindersOnBirthdays": "Reminders when it's someone's birthday",
"happyBirthday": "Happy birthday! πŸ₯³",
"birthdays": "Birthdays",
"wishThemAHappyBirthday": "Wish {name} a happy birthday! πŸŽ‰",
diff --git a/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart
index b79289b32f..61cf480e61 100644
--- a/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart
+++ b/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart
@@ -1,199 +1,106 @@
-import 'package:flutter/material.dart';
+import "package:ente_components/ente_components.dart";
+import "package:flutter/material.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/notification_service.dart";
-import 'package:photos/theme/ente_theme.dart';
-import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
-import 'package:photos/ui/components/toggle_switch_widget.dart';
+import "package:photos/ui/settings/components/settings_item.dart";
+import "package:photos/ui/settings/components/settings_page_scaffold.dart";
class NotificationSettingsScreen extends StatelessWidget {
const NotificationSettingsScreen({super.key});
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+ final l10n = AppLocalizations.of(context);
final showOnlyOnThisDay = isLocalGalleryMode;
- final pageBackgroundColor =
- isDarkMode ? const Color(0xFF161616) : const Color(0xFFFAFAFA);
-
- return Scaffold(
- backgroundColor: pageBackgroundColor,
- body: SafeArea(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const SizedBox(height: 24),
- GestureDetector(
- onTap: () => Navigator.of(context).pop(),
- child: Icon(
- Icons.arrow_back,
- color: colorScheme.strokeBase,
- size: 24,
- ),
- ),
- const SizedBox(height: 24),
- Text(
- AppLocalizations.of(context).notifications,
- style: textTheme.h3Bold,
- ),
- const SizedBox(height: 24),
- Expanded(
- child: SingleChildScrollView(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- if (!showOnlyOnThisDay) ...[
- MenuItemWidgetNew(
- title: AppLocalizations.of(
- context,
- ).sharedPhotoNotifications,
- trailingWidget: ToggleSwitchWidget(
- value: () =>
- NotificationService.instance
- .hasGrantedPermissions() &&
- NotificationService.instance
- .shouldShowNotificationsForSharedPhotosAndAlbums(),
- onChanged: () async {
- await NotificationService.instance
- .requestPermissions();
- await NotificationService.instance
- .setShouldShowNotificationsForSharedPhotosAndAlbums(
- !NotificationService.instance
- .shouldShowNotificationsForSharedPhotosAndAlbums(),
- );
- },
- ),
- ),
- Padding(
- padding: const EdgeInsets.only(
- left: 16,
- right: 16,
- top: 8,
- bottom: 16,
- ),
- child: Text(
- AppLocalizations.of(
- context,
- ).sharedPhotoNotificationsExplanation,
- style: textTheme.mini.copyWith(
- color: colorScheme.textMuted,
- ),
- ),
- ),
- MenuItemWidgetNew(
- title: AppLocalizations.of(
- context,
- ).socialNotifications,
- trailingWidget: ToggleSwitchWidget(
- value: () =>
- NotificationService.instance
- .hasGrantedPermissions() &&
- NotificationService.instance
- .shouldShowSocialNotifications(),
- onChanged: () async {
- await NotificationService.instance
- .requestPermissions();
- await NotificationService.instance
- .setShouldShowSocialNotifications(
- !NotificationService.instance
- .shouldShowSocialNotifications(),
- );
- },
- ),
- ),
- Padding(
- padding: const EdgeInsets.only(
- left: 16,
- right: 16,
- top: 8,
- bottom: 16,
- ),
- child: Text(
- AppLocalizations.of(
- context,
- ).socialNotificationsExplanation,
- style: textTheme.mini.copyWith(
- color: colorScheme.textMuted,
- ),
- ),
- ),
- ],
- MenuItemWidgetNew(
- title: AppLocalizations.of(context).onThisDayMemories,
- trailingWidget: ToggleSwitchWidget(
- value: () =>
- NotificationService.instance
- .hasGrantedPermissions() &&
- localSettings.isOnThisDayNotificationsEnabled,
- onChanged: () async {
- await NotificationService.instance
- .requestPermissions();
- await memoriesCacheService
- .toggleOnThisDayNotifications();
- },
- ),
- ),
- Padding(
- padding: const EdgeInsets.only(
- left: 16,
- right: 16,
- top: 8,
- bottom: 16,
- ),
- child: Text(
- AppLocalizations.of(
- context,
- ).onThisDayNotificationExplanation,
- style: textTheme.mini.copyWith(
- color: colorScheme.textMuted,
- ),
- ),
- ),
- if (!showOnlyOnThisDay) ...[
- MenuItemWidgetNew(
- title: AppLocalizations.of(context).birthdays,
- trailingWidget: ToggleSwitchWidget(
- value: () =>
- NotificationService.instance
- .hasGrantedPermissions() &&
- localSettings.birthdayNotificationsEnabled,
- onChanged: () async {
- await NotificationService.instance
- .requestPermissions();
- await memoriesCacheService
- .toggleBirthdayNotifications();
- },
- ),
- ),
- Padding(
- padding: const EdgeInsets.only(
- left: 16,
- right: 16,
- top: 8,
- bottom: 16,
- ),
- child: Text(
- AppLocalizations.of(
- context,
- ).receiveRemindersOnBirthdays,
- style: textTheme.mini.copyWith(
- color: colorScheme.textMuted,
- ),
- ),
- ),
- ],
- ],
- ),
- ),
- ),
- ],
+ return SettingsPageScaffold(
+ title: l10n.notifications,
+ children: [
+ if (!showOnlyOnThisDay) ...[
+ _buildNotificationToggleItem(
+ context,
+ title: l10n.sharedPhotoNotifications,
+ subtitle: l10n.sharedPhotoNotificationsExplanation,
+ value: () =>
+ NotificationService.instance.hasGrantedPermissions() &&
+ NotificationService.instance
+ .shouldShowNotificationsForSharedPhotosAndAlbums(),
+ onChanged: () async {
+ await NotificationService.instance.requestPermissions();
+ await NotificationService.instance
+ .setShouldShowNotificationsForSharedPhotosAndAlbums(
+ !NotificationService.instance
+ .shouldShowNotificationsForSharedPhotosAndAlbums(),
+ );
+ },
+ ),
+ const SizedBox(height: 8),
+ _buildNotificationToggleItem(
+ context,
+ title: l10n.socialNotifications,
+ subtitle: l10n.socialNotificationsExplanation,
+ value: () =>
+ NotificationService.instance.hasGrantedPermissions() &&
+ NotificationService.instance.shouldShowSocialNotifications(),
+ onChanged: () async {
+ await NotificationService.instance.requestPermissions();
+ await NotificationService.instance
+ .setShouldShowSocialNotifications(
+ !NotificationService.instance
+ .shouldShowSocialNotifications(),
+ );
+ },
),
+ const SizedBox(height: 8),
+ ],
+ _buildNotificationToggleItem(
+ context,
+ title: l10n.onThisDayMemories,
+ subtitle: l10n.onThisDayNotificationExplanation,
+ value: () =>
+ NotificationService.instance.hasGrantedPermissions() &&
+ localSettings.isOnThisDayNotificationsEnabled,
+ onChanged: () async {
+ await NotificationService.instance.requestPermissions();
+ await memoriesCacheService.toggleOnThisDayNotifications();
+ },
),
+ if (!showOnlyOnThisDay) ...[
+ const SizedBox(height: 8),
+ _buildNotificationToggleItem(
+ context,
+ title: l10n.birthdays,
+ subtitle: l10n.receiveRemindersOnBirthdays,
+ value: () =>
+ NotificationService.instance.hasGrantedPermissions() &&
+ localSettings.birthdayNotificationsEnabled,
+ onChanged: () async {
+ await NotificationService.instance.requestPermissions();
+ await memoriesCacheService.toggleBirthdayNotifications();
+ },
+ ),
+ ],
+ ],
+ );
+ }
+
+ SettingsItem _buildNotificationToggleItem(
+ BuildContext context, {
+ required String title,
+ required String subtitle,
+ required bool Function() value,
+ required Future<void> Function() onChanged,
+ }) {
+ return SettingsItem(
+ title: title,
+ subtitle: subtitle,
+ subtitleMaxLines: 2,
+ showChevron: false,
+ trailing: ToggleSwitchComponent.async(
+ value: value,
+ onChanged: onChanged,
+ showStateIcon: false,
),
);
}