Skip to content

armgit / ente

Public Imported from GitHub
0

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

Revamp photos settings UI

Neeraj Guptafb59f2a2ed28
diff --git a/mobile/apps/photos/assets/storage_card_background.png b/mobile/apps/photos/assets/storage_card_background.png
index b17627f01d..e960536d52 100644
Binary files a/mobile/apps/photos/assets/storage_card_background.png and b/mobile/apps/photos/assets/storage_card_background.png differ
diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arb
index fd50be47df..d697d72837 100644
--- a/mobile/apps/photos/lib/l10n/intl_en.arb
+++ b/mobile/apps/photos/lib/l10n/intl_en.arb
@@ -646,6 +646,7 @@
"reportBug": "Report bug",
"suggestFeatures": "Suggest features",
"support": "Support",
+ "appearance": "Appearance",
"theme": "Theme",
"lightTheme": "Light",
"darkTheme": "Dark",
@@ -1155,7 +1156,7 @@
"description": "Example: 1.2 GB of 2 GB used or 100 GB or 2TB used"
},
"availableStorageSpace": "{freeAmount} {storageUnit} free",
- "appVersion": "Version: {versionValue}",
+ "appVersion": "Version {versionValue}",
"verifyIDLabel": "Verify",
"fileInfoAddDescHint": "Add a description...",
"editLocationTagTitle": "Edit location",
diff --git a/mobile/apps/photos/lib/ui/components/menu_item_widget/menu_item_widget_new.dart b/mobile/apps/photos/lib/ui/components/menu_item_widget/menu_item_widget_new.dart
new file mode 100644
index 0000000000..5e2fa0e833
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/components/menu_item_widget/menu_item_widget_new.dart
@@ -0,0 +1,273 @@
+import 'package:ente_pure_utils/ente_pure_utils.dart';
+import 'package:flutter/material.dart';
+import 'package:photos/models/execution_states.dart';
+import 'package:photos/models/typedefs.dart';
+import 'package:photos/theme/ente_theme.dart';
+import 'package:photos/ui/components/menu_item_widget/menu_item_child_widgets.dart';
+
+/// A menu item widget with the new design system.
+/// Features:
+/// - 20px border radius
+/// - 16px padding
+/// - Background color: Light #FFFFFF, Dark #212121
+class MenuItemWidgetNew extends StatefulWidget {
+ final String title;
+
+ /// Color for the title text
+ final Color? titleColor;
+
+ /// leading icon can be passed without specifing size of icon,
+ /// this component sets size to 20x20 irrespective of passed icon's size
+ final IconData? leadingIcon;
+ final Color? leadingIconColor;
+
+ final Widget? leadingIconWidget;
+
+ // leadIconSize default value is 20.
+ final double leadingIconSize;
+
+ /// trailing icon can be passed without size as default size set by
+ /// flutter is what this component expects
+ final IconData? trailingIcon;
+ final Color? trailingIconColor;
+ final Widget? trailingWidget;
+ final bool trailingIconIsMuted;
+
+ /// If provided, add this much extra spacing to the right of the trailing icon.
+ final double trailingExtraMargin;
+ final FutureVoidCallback? onTap;
+ final VoidCallback? onDoubleTap;
+ final VoidCallback? onLongPress;
+ final Color? menuItemColor;
+
+ /// Border radius for the menu item, defaults to 20
+ final double borderRadius;
+ final Color? pressedColor;
+
+ /// disable gesture detector if not used
+ final bool isGestureDetectorDisabled;
+
+ /// Success state will not be shown if this flag is set to true, only idle and
+ /// loading state
+ final bool showOnlyLoadingState;
+
+ final bool surfaceExecutionStates;
+
+ /// To show success state even when execution time < debounce time, set this
+ /// flag to true.
+ final bool alwaysShowSuccessState;
+
+ const MenuItemWidgetNew({
+ required this.title,
+ this.titleColor,
+ this.leadingIcon,
+ this.leadingIconColor,
+ this.leadingIconSize = 20.0,
+ this.leadingIconWidget,
+ this.trailingIcon,
+ this.trailingIconColor,
+ this.trailingWidget,
+ this.trailingIconIsMuted = false,
+ this.trailingExtraMargin = 0.0,
+ this.onTap,
+ this.onDoubleTap,
+ this.onLongPress,
+ this.menuItemColor,
+ this.borderRadius = 20.0,
+ this.pressedColor,
+ this.isGestureDetectorDisabled = false,
+ this.showOnlyLoadingState = false,
+ this.surfaceExecutionStates = false,
+ this.alwaysShowSuccessState = false,
+ super.key,
+ });
+
+ @override
+ State<MenuItemWidgetNew> createState() => _MenuItemWidgetNewState();
+}
+
+class _MenuItemWidgetNewState extends State<MenuItemWidgetNew> {
+ final _debouncer = Debouncer(const Duration(milliseconds: 300));
+ ValueNotifier<ExecutionState> executionStateNotifier = ValueNotifier(
+ ExecutionState.idle,
+ );
+
+ Color? menuItemColor;
+
+ @override
+ void initState() {
+ menuItemColor = widget.menuItemColor;
+ super.initState();
+ }
+
+ @override
+ void didChangeDependencies() {
+ menuItemColor = widget.menuItemColor;
+ super.didChangeDependencies();
+ }
+
+ @override
+ void didUpdateWidget(covariant MenuItemWidgetNew oldWidget) {
+ menuItemColor = widget.menuItemColor;
+ super.didUpdateWidget(oldWidget);
+ }
+
+ @override
+ void dispose() {
+ executionStateNotifier.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return widget.isGestureDetectorDisabled || !hasPassedGestureCallbacks()
+ ? _buildMenuItemContainer(context)
+ : GestureDetector(
+ onTap: widget.onTap == null ? null : _onTap,
+ onDoubleTap: widget.onDoubleTap,
+ onLongPress: widget.onLongPress,
+ onTapDown: _onTapDown,
+ onTapUp: _onTapUp,
+ onTapCancel: _onCancel,
+ child: _buildMenuItemContainer(context),
+ );
+ }
+
+ Widget _buildMenuItemContainer(BuildContext context) {
+ final textTheme = getEnteTextTheme(context);
+ final circularRadius = Radius.circular(widget.borderRadius);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ // Figma colors: Light #FFFFFF, Dark #212121
+ final defaultMenuItemColor =
+ isDarkMode ? const Color(0xFF212121) : const Color(0xFFFFFFFF);
+
+ final effectiveMenuItemColor = menuItemColor ?? defaultMenuItemColor;
+
+ return AnimatedContainer(
+ duration: const Duration(milliseconds: 20),
+ width: double.infinity,
+ clipBehavior: Clip.none,
+ padding: const EdgeInsets.all(16),
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.all(circularRadius),
+ color: effectiveMenuItemColor,
+ ),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ if (widget.leadingIcon != null || widget.leadingIconWidget != null)
+ LeadingWidget(
+ leadingIconSize: widget.leadingIconSize,
+ leadingIcon: widget.leadingIcon,
+ leadingIconColor: widget.leadingIconColor,
+ leadingIconWidget: widget.leadingIconWidget,
+ ),
+ Expanded(
+ child: Text(
+ widget.title,
+ style: widget.titleColor != null
+ ? textTheme.small.copyWith(color: widget.titleColor)
+ : textTheme.small,
+ ),
+ ),
+ TrailingWidget(
+ executionStateNotifier: executionStateNotifier,
+ trailingIcon: widget.trailingIcon,
+ trailingIconColor: widget.trailingIconColor,
+ trailingWidget: widget.trailingWidget,
+ trailingIconIsMuted: widget.trailingIconIsMuted,
+ trailingExtraMargin: widget.trailingExtraMargin,
+ showExecutionStates: widget.surfaceExecutionStates,
+ key: ValueKey(widget.trailingIcon.hashCode),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Future<void> _onTap() async {
+ if (executionStateNotifier.value == ExecutionState.inProgress ||
+ executionStateNotifier.value == ExecutionState.successful) {
+ return;
+ }
+ _debouncer.run(
+ () => Future(() {
+ executionStateNotifier.value = ExecutionState.inProgress;
+ }),
+ );
+ final onTapResult = widget.onTap?.call();
+ if (onTapResult != null) {
+ await onTapResult.then(
+ (value) {
+ widget.alwaysShowSuccessState
+ ? executionStateNotifier.value = ExecutionState.successful
+ : null;
+ },
+ onError: (error, stackTrace) => _debouncer.cancelDebounceTimer(),
+ );
+ }
+ _debouncer.cancelDebounceTimer();
+ if (widget.alwaysShowSuccessState) {
+ Future.delayed(const Duration(seconds: 2), () {
+ executionStateNotifier.value = ExecutionState.idle;
+ });
+ return;
+ }
+ if (executionStateNotifier.value == ExecutionState.inProgress) {
+ if (widget.showOnlyLoadingState) {
+ executionStateNotifier.value = ExecutionState.idle;
+ } else {
+ executionStateNotifier.value = ExecutionState.successful;
+ Future.delayed(const Duration(seconds: 2), () {
+ executionStateNotifier.value = ExecutionState.idle;
+ });
+ }
+ }
+ }
+
+ void _onTapDown(details) {
+ if (executionStateNotifier.value == ExecutionState.inProgress ||
+ executionStateNotifier.value == ExecutionState.successful) {
+ return;
+ }
+ setState(() {
+ if (widget.pressedColor == null) {
+ hasPassedGestureCallbacks()
+ ? menuItemColor = getEnteColorScheme(context).fillFaintPressed
+ : menuItemColor = widget.menuItemColor;
+ } else {
+ menuItemColor = widget.pressedColor;
+ }
+ });
+ }
+
+ bool hasPassedGestureCallbacks() {
+ return widget.onDoubleTap != null ||
+ widget.onTap != null ||
+ widget.onLongPress != null;
+ }
+
+ void _onTapUp(details) {
+ if (executionStateNotifier.value == ExecutionState.inProgress ||
+ executionStateNotifier.value == ExecutionState.successful) {
+ return;
+ }
+ Future.delayed(
+ const Duration(milliseconds: 100),
+ () => setState(() {
+ menuItemColor = widget.menuItemColor;
+ }),
+ );
+ }
+
+ void _onCancel() {
+ if (executionStateNotifier.value == ExecutionState.inProgress ||
+ executionStateNotifier.value == ExecutionState.successful) {
+ return;
+ }
+ setState(() {
+ menuItemColor = widget.menuItemColor;
+ });
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/components/settings/settings_grouped_card.dart b/mobile/apps/photos/lib/ui/components/settings/settings_grouped_card.dart
new file mode 100644
index 0000000000..e2a347bfea
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/components/settings/settings_grouped_card.dart
@@ -0,0 +1,50 @@
+import "package:flutter/material.dart";
+
+/// A container for grouped settings items.
+/// Uses 20px border radius and the standard card colors.
+class SettingsGroupedCard extends StatelessWidget {
+ final List<Widget> children;
+
+ const SettingsGroupedCard({
+ required this.children,
+ super.key,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ // Card background: Light #FFFFFF, Dark #212121
+ final cardColor =
+ isDarkMode ? const Color(0xFF212121) : const Color(0xFFFFFFFF);
+
+ return Container(
+ decoration: BoxDecoration(
+ color: cardColor,
+ borderRadius: BorderRadius.circular(20),
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: _buildChildren(),
+ ),
+ );
+ }
+
+ List<Widget> _buildChildren() {
+ final List<Widget> result = [];
+ for (int i = 0; i < children.length; i++) {
+ result.add(
+ ClipRRect(
+ borderRadius: BorderRadius.vertical(
+ top: i == 0 ? const Radius.circular(20) : Radius.zero,
+ bottom: i == children.length - 1
+ ? const Radius.circular(20)
+ : Radius.zero,
+ ),
+ child: children[i],
+ ),
+ );
+ }
+ return result;
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/components/settings/settings_menu_item.dart b/mobile/apps/photos/lib/ui/components/settings/settings_menu_item.dart
new file mode 100644
index 0000000000..2e36b763cc
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/components/settings/settings_menu_item.dart
@@ -0,0 +1,64 @@
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:photos/models/typedefs.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
+
+/// A settings menu item with a 40x40 icon container.
+/// Used in the redesigned settings page.
+class SettingsMenuItem extends StatelessWidget {
+ final String title;
+ final List<List<dynamic>> icon;
+ final Color? iconColor;
+ final FutureVoidCallback? onTap;
+ final Widget? trailingWidget;
+ final bool showChevron;
+ final Color? titleColor;
+
+ const SettingsMenuItem({
+ required this.title,
+ required this.icon,
+ this.iconColor,
+ this.onTap,
+ this.trailingWidget,
+ this.showChevron = true,
+ this.titleColor,
+ super.key,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ // Icon container background: Light #F5F5F5, Dark #2C2C2C
+ final iconContainerColor =
+ isDarkMode ? const Color(0xFF2C2C2C) : const Color(0xFFF5F5F5);
+
+ return MenuItemWidgetNew(
+ title: title,
+ leadingIconWidget: Container(
+ width: 40,
+ height: 40,
+ decoration: BoxDecoration(
+ color: iconContainerColor,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Center(
+ child: HugeIcon(
+ icon: icon,
+ color: iconColor ?? colorScheme.strokeBase,
+ size: 20,
+ ),
+ ),
+ ),
+ leadingIconSize: 40,
+ trailingWidget: trailingWidget,
+ trailingIcon: showChevron && trailingWidget == null
+ ? Icons.chevron_right_outlined
+ : null,
+ trailingIconIsMuted: true,
+ onTap: onTap,
+ );
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/components/settings/social_icons_row.dart b/mobile/apps/photos/lib/ui/components/settings/social_icons_row.dart
new file mode 100644
index 0000000000..4ca4993ebc
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/components/settings/social_icons_row.dart
@@ -0,0 +1,84 @@
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:url_launcher/url_launcher_string.dart";
+
+/// A row of social media icons for the settings page.
+class SocialIconsRow extends StatelessWidget {
+ const SocialIconsRow({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+
+ const socialLinks = [
+ _SocialLink(
+ icon: HugeIcons.strokeRoundedDiscord,
+ url: "https://ente.io/discord",
+ label: "Discord",
+ ),
+ _SocialLink(
+ icon: HugeIcons.strokeRoundedYoutube,
+ url: "https://www.youtube.com/@entestudio",
+ label: "YouTube",
+ ),
+ _SocialLink(
+ icon: HugeIcons.strokeRoundedGithub,
+ url: "https://github.com/ente-io/ente",
+ label: "GitHub",
+ ),
+ _SocialLink(
+ icon: HugeIcons.strokeRoundedNewTwitter,
+ url: "https://twitter.com/enteio",
+ label: "X",
+ ),
+ _SocialLink(
+ icon: HugeIcons.strokeRoundedMastodon,
+ url: "https://fosstodon.org/@ente",
+ label: "Mastodon",
+ ),
+ _SocialLink(
+ icon: HugeIcons.strokeRoundedReddit,
+ url: "https://reddit.com/r/enteio",
+ label: "Reddit",
+ ),
+ ];
+
+ return Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: socialLinks.map((link) {
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 12),
+ child: GestureDetector(
+ onTap: () => _launchUrl(link.url),
+ child: Semantics(
+ label: link.label,
+ button: true,
+ child: HugeIcon(
+ icon: link.icon,
+ color: colorScheme.strokeMuted,
+ size: 24,
+ ),
+ ),
+ ),
+ );
+ }).toList(),
+ );
+ }
+
+ Future<void> _launchUrl(String url) async {
+ await launchUrlString(url, mode: LaunchMode.externalApplication);
+ }
+}
+
+class _SocialLink {
+ final List<List<dynamic>> icon;
+ final String url;
+ final String label;
+
+ const _SocialLink({
+ required this.icon,
+ required this.url,
+ required this.label,
+ });
+}
diff --git a/mobile/apps/photos/lib/ui/settings/about/about_us_page.dart b/mobile/apps/photos/lib/ui/settings/about/about_us_page.dart
new file mode 100644
index 0000000000..300bf7fa8a
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/settings/about/about_us_page.dart
@@ -0,0 +1,194 @@
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:photos/generated/l10n.dart";
+import "package:photos/service_locator.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/common/web_page.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
+import "package:photos/ui/components/settings/settings_grouped_card.dart";
+import "package:photos/ui/notification/toast.dart";
+import "package:photos/ui/settings/app_update_dialog.dart";
+import "package:photos/utils/dialog_util.dart";
+import "package:url_launcher/url_launcher.dart";
+
+class AboutUsPage extends StatelessWidget {
+ const AboutUsPage({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ 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).about,
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: SingleChildScrollView(
+ child: Column(
+ children: [
+ SettingsGroupedCard(
+ children: [
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).weAreOpenSource,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedGithub,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await launchUrl(
+ Uri.parse("https://github.com/ente-io/ente"),
+ );
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).blog,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedPencilEdit01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return WebPage(
+ AppLocalizations.of(context).blog,
+ "https://ente.io/blog",
+ );
+ },
+ ),
+ );
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).privacy,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedShield01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return WebPage(
+ AppLocalizations.of(context).privacy,
+ "https://ente.io/privacy",
+ );
+ },
+ ),
+ );
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context)
+ .termsOfServicesTitle,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedFile01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return WebPage(
+ AppLocalizations.of(context)
+ .termsOfServicesTitle,
+ "https://ente.io/terms",
+ );
+ },
+ ),
+ );
+ },
+ ),
+ if (updateService.isIndependent())
+ MenuItemWidgetNew(
+ title:
+ AppLocalizations.of(context).checkForUpdates,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedDownload04,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _checkForUpdates(context),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildIconWidget(BuildContext context, List<List<dynamic>> icon) {
+ final colorScheme = getEnteColorScheme(context);
+ return HugeIcon(
+ icon: icon,
+ color: colorScheme.strokeBase,
+ size: 20,
+ );
+ }
+
+ Future<void> _checkForUpdates(BuildContext context) async {
+ final dialog = createProgressDialog(
+ context,
+ AppLocalizations.of(context).checking,
+ );
+ await dialog.show();
+ final shouldUpdate = await updateService.shouldUpdate();
+ await dialog.hide();
+ if (shouldUpdate) {
+ await showDialog(
+ useRootNavigator: false,
+ context: context,
+ builder: (BuildContext context) {
+ return AppUpdateDialog(
+ updateService.getLatestVersionInfo(),
+ );
+ },
+ barrierColor: Colors.black.withValues(alpha: 0.85),
+ );
+ } else {
+ showShortToast(
+ context,
+ AppLocalizations.of(context).youAreOnTheLatestVersion,
+ );
+ }
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/settings/account/account_settings_page.dart b/mobile/apps/photos/lib/ui/settings/account/account_settings_page.dart
new file mode 100644
index 0000000000..b6be294e34
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/settings/account/account_settings_page.dart
@@ -0,0 +1,262 @@
+import "dart:async";
+
+import "package:ente_crypto/ente_crypto.dart";
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:photos/generated/l10n.dart";
+import "package:photos/services/account/user_service.dart";
+import "package:photos/services/local_authentication_service.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/account/change_email_dialog.dart";
+import "package:photos/ui/account/delete_account_page.dart";
+import "package:photos/ui/account/password_entry_page.dart";
+import "package:photos/ui/account/recovery_key_page.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
+import "package:photos/ui/payment/subscription.dart";
+import "package:photos/utils/dialog_util.dart";
+import "package:url_launcher/url_launcher_string.dart";
+
+class AccountSettingsPage extends StatelessWidget {
+ const AccountSettingsPage({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ 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).account,
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: SingleChildScrollView(
+ child: Column(
+ children: [
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).manageSubscription,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedCreditCard,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onManageSubscriptionTapped(context),
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).changeEmail,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedMail01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ showOnlyLoadingState: true,
+ onTap: () async => _onChangeEmailTapped(context),
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).changePassword,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedLockPassword,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ showOnlyLoadingState: true,
+ onTap: () async => _onChangePasswordTapped(context),
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).recoveryKey,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedKey01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ showOnlyLoadingState: true,
+ onTap: () async => _onRecoveryKeyTapped(context),
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).exportYourData,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedDownload04,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await launchUrlString(
+ "https://ente.io/help/photos/migration/export/",
+ );
+ },
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).deleteAccount,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedDelete02,
+ isDestructive: true,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onDeleteAccountTapped(context),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildIconWidget(
+ BuildContext context,
+ List<List<dynamic>> icon, {
+ bool isDestructive = false,
+ }) {
+ final colorScheme = getEnteColorScheme(context);
+ return HugeIcon(
+ icon: icon,
+ color: isDestructive ? colorScheme.warning700 : colorScheme.strokeBase,
+ size: 20,
+ );
+ }
+
+ void _onManageSubscriptionTapped(BuildContext context) {
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return getSubscriptionPage();
+ },
+ ),
+ );
+ }
+
+ Future<void> _onChangeEmailTapped(BuildContext context) async {
+ final hasAuthenticated =
+ await LocalAuthenticationService.instance.requestLocalAuthentication(
+ context,
+ AppLocalizations.of(context).authToChangeYourEmail,
+ );
+ if (hasAuthenticated) {
+ unawaited(
+ showDialog(
+ useRootNavigator: false,
+ context: context,
+ builder: (BuildContext context) {
+ return const ChangeEmailDialog();
+ },
+ barrierColor: Colors.black.withValues(alpha: 0.85),
+ barrierDismissible: false,
+ ),
+ );
+ }
+ }
+
+ Future<void> _onChangePasswordTapped(BuildContext context) async {
+ final hasAuthenticated =
+ await LocalAuthenticationService.instance.requestLocalAuthentication(
+ context,
+ AppLocalizations.of(context).authToChangeYourPassword,
+ );
+ if (hasAuthenticated) {
+ unawaited(
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return const PasswordEntryPage(
+ mode: PasswordEntryMode.update,
+ );
+ },
+ ),
+ ),
+ );
+ }
+ }
+
+ Future<void> _onRecoveryKeyTapped(BuildContext context) async {
+ final hasAuthenticated =
+ await LocalAuthenticationService.instance.requestLocalAuthentication(
+ context,
+ AppLocalizations.of(context).authToViewYourRecoveryKey,
+ );
+ if (hasAuthenticated) {
+ String recoveryKey;
+ try {
+ recoveryKey = await _getOrCreateRecoveryKey(context);
+ } catch (e) {
+ await showGenericErrorDialog(context: context, error: e);
+ return;
+ }
+ unawaited(
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return RecoveryKeyPage(
+ recoveryKey,
+ AppLocalizations.of(context).ok,
+ showAppBar: true,
+ onDone: () {},
+ );
+ },
+ ),
+ ),
+ );
+ }
+ }
+
+ Future<String> _getOrCreateRecoveryKey(BuildContext context) async {
+ return CryptoUtil.bin2hex(
+ await UserService.instance.getOrCreateRecoveryKey(context),
+ );
+ }
+
+ Future<void> _onDeleteAccountTapped(BuildContext context) async {
+ final hasAuthenticated =
+ await LocalAuthenticationService.instance.requestLocalAuthentication(
+ context,
+ AppLocalizations.of(context).authToInitiateAccountDeletion,
+ );
+ if (hasAuthenticated) {
+ unawaited(
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return const DeleteAccountPage();
+ },
+ ),
+ ),
+ );
+ }
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/settings/advanced_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/advanced_settings_screen.dart
index 54bec92054..cab7f99040 100644
--- a/mobile/apps/photos/lib/ui/settings/advanced_settings_screen.dart
+++ b/mobile/apps/photos/lib/ui/settings/advanced_settings_screen.dart
@@ -1,8 +1,6 @@
import 'package:ente_pure_utils/ente_pure_utils.dart';
import 'package:flutter/material.dart';
import "package:photos/core/error-reporting/super_logging.dart";
-import "package:photos/core/event_bus.dart";
-import "package:photos/events/christmas_banner_event.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
import 'package:photos/theme/ente_theme.dart';
@@ -13,7 +11,6 @@ import 'package:photos/ui/components/menu_section_description_widget.dart';
import 'package:photos/ui/components/title_bar_title_widget.dart';
import 'package:photos/ui/components/title_bar_widget.dart';
import "package:photos/ui/components/toggle_switch_widget.dart";
-import "package:photos/ui/home/christmas/christmas_utils.dart";
import 'package:photos/ui/notification/toast.dart';
import "package:photos/ui/settings/app_icon_selection_screen.dart";
import "package:photos/ui/settings/ml/machine_learning_settings_page.dart";
@@ -160,26 +157,6 @@ class AdvancedSettingsScreen extends StatelessWidget {
},
),
),
- if (isChristmasDateRange()) ...[
- const SizedBox(height: 24),
- MenuItemWidget(
- captionedTextWidget: const CaptionedTextWidget(
- title: "Christmas banner",
- ),
- menuItemColor: colorScheme.fillFaint,
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- trailingWidget: ToggleSwitchWidget(
- value: () => localSettings.isChristmasBannerEnabled,
- onChanged: () async {
- await localSettings.setChristmasBannerEnabled(
- !localSettings.isChristmasBannerEnabled,
- );
- Bus.instance.fire(ChristmasBannerEvent());
- },
- ),
- ),
- ],
],
),
);
diff --git a/mobile/apps/photos/lib/ui/settings/app_version_widget.dart b/mobile/apps/photos/lib/ui/settings/app_version_widget.dart
index 222879b60e..331e7ceba7 100644
--- a/mobile/apps/photos/lib/ui/settings/app_version_widget.dart
+++ b/mobile/apps/photos/lib/ui/settings/app_version_widget.dart
@@ -40,10 +40,12 @@ class _AppVersionWidgetState extends State<AppVersionWidget> {
if (snapshot.hasData) {
return Padding(
padding: const EdgeInsets.all(20),
- child: Text(
- AppLocalizations.of(context)
- .appVersion(versionValue: snapshot.data!),
- style: Theme.of(context).textTheme.bodySmall,
+ child: Center(
+ child: Text(
+ AppLocalizations.of(context)
+ .appVersion(versionValue: snapshot.data!),
+ style: Theme.of(context).textTheme.bodySmall,
+ ),
),
);
}
diff --git a/mobile/apps/photos/lib/ui/settings/appearance/appearance_settings_page.dart b/mobile/apps/photos/lib/ui/settings/appearance/appearance_settings_page.dart
new file mode 100644
index 0000000000..0f4791d761
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/settings/appearance/appearance_settings_page.dart
@@ -0,0 +1,287 @@
+import "dart:io";
+
+import "package:adaptive_theme/adaptive_theme.dart";
+import "package:ente_pure_utils/ente_pure_utils.dart";
+import "package:flutter/foundation.dart";
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:photos/app.dart";
+import "package:photos/generated/l10n.dart";
+import "package:photos/l10n/l10n.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/settings/app_icon_selection_screen.dart";
+import "package:photos/ui/settings/gallery_settings_screen.dart";
+import "package:photos/ui/settings/language_picker.dart";
+
+class AppearanceSettingsPage extends StatefulWidget {
+ const AppearanceSettingsPage({super.key});
+
+ @override
+ State<AppearanceSettingsPage> createState() => _AppearanceSettingsPageState();
+}
+
+class _AppearanceSettingsPageState extends State<AppearanceSettingsPage> {
+ AdaptiveThemeMode? _currentThemeMode;
+
+ @override
+ void initState() {
+ super.initState();
+ AdaptiveTheme.getThemeMode().then((value) {
+ _currentThemeMode = value ?? AdaptiveThemeMode.system;
+ if (mounted) {
+ setState(() {});
+ }
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ 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).appearance,
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: SingleChildScrollView(
+ child: Column(
+ children: [
+ if (Platform.isAndroid || kDebugMode) ...[
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).theme,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ isDarkMode
+ ? HugeIcons.strokeRoundedMoon02
+ : HugeIcons.strokeRoundedSun03,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _showThemePicker(context),
+ ),
+ const SizedBox(height: 8),
+ ],
+ MenuItemWidgetNew(
+ title: context.l10n.appIcon,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedImage02,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(
+ context,
+ const AppIconSelectionScreen(),
+ );
+ },
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).language,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedTranslation,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onLanguageTap(context),
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).gallery,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedImage01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(
+ context,
+ const GallerySettingsScreen(
+ fromGalleryLayoutSettingsCTA: false,
+ ),
+ );
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildIconWidget(BuildContext context, List<List<dynamic>> icon) {
+ final colorScheme = getEnteColorScheme(context);
+ return HugeIcon(
+ icon: icon,
+ color: colorScheme.strokeBase,
+ size: 20,
+ );
+ }
+
+ Future<void> _showThemePicker(BuildContext context) async {
+ await showModalBottomSheet(
+ context: context,
+ backgroundColor: Colors.transparent,
+ builder: (context) => _ThemePickerSheet(
+ currentThemeMode: _currentThemeMode,
+ onThemeChanged: (themeMode) {
+ AdaptiveTheme.of(context).setThemeMode(themeMode);
+ setState(() {
+ _currentThemeMode = themeMode;
+ });
+ },
+ ),
+ );
+ }
+
+ Future<void> _onLanguageTap(BuildContext context) async {
+ final locale = (await getLocale())!;
+ await routeToPage(
+ context,
+ LanguageSelectorPage(
+ appSupportedLocales,
+ (locale) async {
+ await setLocale(locale);
+ EnteApp.setLocale(context, locale);
+ },
+ locale,
+ ),
+ );
+ }
+}
+
+class _ThemePickerSheet extends StatelessWidget {
+ final AdaptiveThemeMode? currentThemeMode;
+ final Function(AdaptiveThemeMode) onThemeChanged;
+
+ const _ThemePickerSheet({
+ required this.currentThemeMode,
+ required this.onThemeChanged,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ final sheetColor =
+ isDarkMode ? const Color(0xFF1E1E1E) : const Color(0xFFFFFFFF);
+
+ return Container(
+ decoration: BoxDecoration(
+ color: sheetColor,
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(20)),
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const SizedBox(height: 8),
+ Container(
+ width: 36,
+ height: 4,
+ decoration: BoxDecoration(
+ color: colorScheme.strokeMuted,
+ borderRadius: BorderRadius.circular(2),
+ ),
+ ),
+ const SizedBox(height: 16),
+ Text(
+ AppLocalizations.of(context).theme,
+ style: textTheme.largeBold,
+ ),
+ const SizedBox(height: 16),
+ _ThemeOption(
+ title: AppLocalizations.of(context).lightTheme,
+ isSelected: currentThemeMode == AdaptiveThemeMode.light,
+ onTap: () {
+ onThemeChanged(AdaptiveThemeMode.light);
+ Navigator.pop(context);
+ },
+ ),
+ _ThemeOption(
+ title: AppLocalizations.of(context).darkTheme,
+ isSelected: currentThemeMode == AdaptiveThemeMode.dark,
+ onTap: () {
+ onThemeChanged(AdaptiveThemeMode.dark);
+ Navigator.pop(context);
+ },
+ ),
+ _ThemeOption(
+ title: AppLocalizations.of(context).systemTheme,
+ isSelected: currentThemeMode == AdaptiveThemeMode.system,
+ onTap: () {
+ onThemeChanged(AdaptiveThemeMode.system);
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(height: MediaQuery.of(context).padding.bottom + 16),
+ ],
+ ),
+ );
+ }
+}
+
+class _ThemeOption extends StatelessWidget {
+ final String title;
+ final bool isSelected;
+ final VoidCallback onTap;
+
+ const _ThemeOption({
+ required this.title,
+ required this.isSelected,
+ required this.onTap,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+
+ return ListTile(
+ title: Text(
+ title,
+ style: textTheme.body,
+ ),
+ trailing: isSelected
+ ? Icon(
+ Icons.check,
+ color: colorScheme.primary500,
+ )
+ : null,
+ onTap: onTap,
+ );
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/settings/backup/backup_settings_page.dart b/mobile/apps/photos/lib/ui/settings/backup/backup_settings_page.dart
new file mode 100644
index 0000000000..9554009bfb
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/settings/backup/backup_settings_page.dart
@@ -0,0 +1,113 @@
+import "package:ente_pure_utils/ente_pure_utils.dart";
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:photos/generated/l10n.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/common/backup_flow_helper.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
+import "package:photos/ui/settings/backup/backup_settings_screen.dart";
+import "package:photos/ui/settings/backup/backup_status_screen.dart";
+
+class BackupSettingsPage extends StatelessWidget {
+ const BackupSettingsPage({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ 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).backup,
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: SingleChildScrollView(
+ child: Column(
+ children: [
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).backedUpFolders,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedFolder01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await handleFolderSelectionBackupFlow(context);
+ },
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).backupStatus,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedCloudSavingDone01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(
+ context,
+ const BackupStatusScreen(),
+ );
+ },
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).backupSettings,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedSettings01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(
+ context,
+ const BackupSettingsScreen(),
+ );
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildIconWidget(BuildContext context, List<List<dynamic>> icon) {
+ final colorScheme = getEnteColorScheme(context);
+ return HugeIcon(
+ icon: icon,
+ color: colorScheme.strokeBase,
+ size: 20,
+ );
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/settings/backup/backup_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/backup/backup_settings_screen.dart
index 344bb6291a..96e7acc5e9 100644
--- a/mobile/apps/photos/lib/ui/settings/backup/backup_settings_screen.dart
+++ b/mobile/apps/photos/lib/ui/settings/backup/backup_settings_screen.dart
@@ -1,29 +1,23 @@
import "dart:io";
-import 'package:ente_pure_utils/ente_pure_utils.dart';
-import 'package:flutter/material.dart';
+import "package:ente_pure_utils/ente_pure_utils.dart";
+import "package:flutter/material.dart";
import "package:photo_manager/photo_manager.dart";
-import 'package:photos/core/configuration.dart';
-import 'package:photos/generated/l10n.dart';
-import 'package:photos/l10n/l10n.dart';
-import 'package:photos/service_locator.dart';
-import 'package:photos/services/sync/local_sync_service.dart';
-import 'package:photos/services/sync/sync_service.dart';
-import 'package:photos/services/wake_lock_service.dart';
-import 'package:photos/theme/ente_theme.dart';
-import 'package:photos/ui/common/backup_flow_helper.dart';
-import 'package:photos/ui/components/action_sheet_widget.dart';
-import 'package:photos/ui/components/buttons/button_widget.dart';
-import 'package:photos/ui/components/buttons/icon_button_widget.dart';
-import 'package:photos/ui/components/captioned_text_widget.dart';
-import 'package:photos/ui/components/divider_widget.dart';
-import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
-import 'package:photos/ui/components/menu_section_description_widget.dart';
-import 'package:photos/ui/components/models/button_type.dart';
-import 'package:photos/ui/components/title_bar_title_widget.dart';
-import 'package:photos/ui/components/title_bar_widget.dart';
-import 'package:photos/ui/components/toggle_switch_widget.dart';
-import 'package:photos/utils/dialog_util.dart';
+import "package:photos/core/configuration.dart";
+import "package:photos/generated/l10n.dart";
+import "package:photos/l10n/l10n.dart";
+import "package:photos/service_locator.dart";
+import "package:photos/services/sync/local_sync_service.dart";
+import "package:photos/services/sync/sync_service.dart";
+import "package:photos/services/wake_lock_service.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/common/backup_flow_helper.dart";
+import "package:photos/ui/components/action_sheet_widget.dart";
+import "package:photos/ui/components/buttons/button_widget.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
+import "package:photos/ui/components/models/button_type.dart";
+import "package:photos/ui/components/toggle_switch_widget.dart";
+import "package:photos/utils/dialog_util.dart";
class BackupSettingsScreen extends StatelessWidget {
const BackupSettingsScreen({super.key});
@@ -36,162 +30,125 @@ class BackupSettingsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ final pageBackgroundColor =
+ isDarkMode ? const Color(0xFF161616) : const Color(0xFFFAFAFA);
+
return Scaffold(
- body: CustomScrollView(
- primary: false,
- slivers: <Widget>[
- TitleBarWidget(
- flexibleSpaceTitle: TitleBarTitleWidget(
- title: AppLocalizations.of(context).backupSettings,
- ),
- actionIcons: [
- IconButtonWidget(
- icon: Icons.close_outlined,
- iconButtonType: IconButtonType.secondary,
- onTap: () {
- Navigator.pop(context);
- Navigator.pop(context);
- },
+ 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,
+ ),
),
- ],
- ),
- SliverList(
- delegate: SliverChildBuilderDelegate(
- (context, index) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 20),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Column(
- children: [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .backupOverMobileData,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: ToggleSwitchWidget(
- value: () => Configuration.instance
- .shouldBackupOverMobileData(),
- onChanged: () async {
- await Configuration.instance
- .setBackupOverMobileData(
- !Configuration.instance
- .shouldBackupOverMobileData(),
- );
- },
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- isBottomBorderRadiusRemoved: true,
- isGestureDetectorDisabled: true,
- ),
- DividerWidget(
- dividerType: DividerType.menuNoIcon,
- bgColor: colorScheme.fillFaint,
- ),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title:
- AppLocalizations.of(context).backupVideos,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: ToggleSwitchWidget(
- value: () =>
- Configuration.instance.shouldBackupVideos(),
- onChanged: () => Configuration.instance
- .setShouldBackupVideos(
- !Configuration.instance.shouldBackupVideos(),
- ),
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- isTopBorderRadiusRemoved: true,
- isGestureDetectorDisabled: true,
- isBottomBorderRadiusRemoved:
- flagService.enableMobMultiPart ||
- _shouldShowOnlyNewToggle(),
- ),
- if (_shouldShowOnlyNewToggle())
- ..._buildOnlyNewToggleSection(
- context,
- colorScheme,
- ),
- if (flagService.enableMobMultiPart)
- DividerWidget(
- dividerType: DividerType.menuNoIcon,
- bgColor: colorScheme.fillFaint,
- ),
- if (flagService.enableMobMultiPart)
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .resumableUploads,
- ),
- menuItemColor: colorScheme.fillFaint,
- singleBorderRadius: 8,
- trailingWidget: ToggleSwitchWidget(
- value: () =>
- localSettings.userEnabledMultiplePart,
- onChanged: () async {
- await localSettings
- .setUserEnabledMultiplePart(
- !localSettings.userEnabledMultiplePart,
- );
- },
- ),
- alignCaptionedTextToLeft: true,
- isTopBorderRadiusRemoved: true,
- isGestureDetectorDisabled: true,
- ),
- ],
+ const SizedBox(height: 24),
+ Text(
+ AppLocalizations.of(context).backupSettings,
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: SingleChildScrollView(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ MenuItemWidgetNew(
+ title:
+ AppLocalizations.of(context).backupOverMobileData,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => Configuration.instance
+ .shouldBackupOverMobileData(),
+ onChanged: () async {
+ await Configuration.instance
+ .setBackupOverMobileData(
+ !Configuration.instance
+ .shouldBackupOverMobileData(),
+ );
+ },
+ ),
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).backupVideos,
+ trailingWidget: ToggleSwitchWidget(
+ value: () =>
+ Configuration.instance.shouldBackupVideos(),
+ onChanged: () =>
+ Configuration.instance.setShouldBackupVideos(
+ !Configuration.instance.shouldBackupVideos(),
+ ),
+ ),
+ ),
+ if (_shouldShowOnlyNewToggle()) ...[
+ const SizedBox(height: 8),
+ _BackupOnlyNewPhotosToggle(
+ debouncer: _onlyNewToggleDebouncer,
),
+ ],
+ if (flagService.enableMobMultiPart) ...[
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).resumableUploads,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => localSettings.userEnabledMultiplePart,
+ onChanged: () async {
+ await localSettings.setUserEnabledMultiplePart(
+ !localSettings.userEnabledMultiplePart,
+ );
+ },
+ ),
+ ),
+ ],
+ if (Platform.isIOS) ...[
const SizedBox(height: 24),
- Platform.isIOS
- ? Column(
- children: [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .disableAutoLock,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: ToggleSwitchWidget(
- value: () => EnteWakeLockService.instance
- .shouldKeepAppAwakeAcrossSessions,
- onChanged: () async {
- EnteWakeLockService.instance
- .updateWakeLock(
- enable: !EnteWakeLockService.instance
- .shouldKeepAppAwakeAcrossSessions,
- wakeLockFor: WakeLockFor
- .fasterBackupsOniOSByKeepingScreenAwake,
- );
- },
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- isGestureDetectorDisabled: true,
- ),
- MenuSectionDescriptionWidget(
- content: AppLocalizations.of(context)
- .deviceLockExplanation,
- ),
- ],
- )
- : const SizedBox.shrink(),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).disableAutoLock,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => EnteWakeLockService
+ .instance.shouldKeepAppAwakeAcrossSessions,
+ onChanged: () async {
+ EnteWakeLockService.instance.updateWakeLock(
+ enable: !EnteWakeLockService
+ .instance.shouldKeepAppAwakeAcrossSessions,
+ wakeLockFor: WakeLockFor
+ .fasterBackupsOniOSByKeepingScreenAwake,
+ );
+ },
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.only(
+ left: 16,
+ right: 16,
+ top: 8,
+ bottom: 16,
+ ),
+ child: Text(
+ AppLocalizations.of(context).deviceLockExplanation,
+ style: textTheme.mini
+ .copyWith(color: colorScheme.textMuted),
+ ),
+ ),
],
- ),
+ ],
),
- );
- },
- childCount: 1,
- ),
+ ),
+ ),
+ ],
),
- ],
+ ),
),
);
}
@@ -199,57 +156,47 @@ class BackupSettingsScreen extends StatelessWidget {
bool _shouldShowOnlyNewToggle() {
return flagService.enableOnlyBackupFuturePhotos;
}
+}
- List<Widget> _buildOnlyNewToggleSection(
- BuildContext context,
- dynamic colorScheme,
- ) {
- return [
- DividerWidget(
- dividerType: DividerType.menuNoIcon,
- bgColor: colorScheme.fillFaint,
- ),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: context.l10n.backupOnlyNewPhotos,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: ToggleSwitchWidget(
- value: () => backupPreferenceService.isOnlyNewBackupEnabled,
- onChanged: () async {
- final hasPermission = await _ensurePhotoPermissions(context);
- if (!hasPermission) {
- return;
- }
- final shouldProceed = await _maybeHandleFolderSelection(
- context: context,
+class _BackupOnlyNewPhotosToggle extends StatelessWidget {
+ final Debouncer debouncer;
+
+ const _BackupOnlyNewPhotosToggle({required this.debouncer});
+
+ @override
+ Widget build(BuildContext context) {
+ return MenuItemWidgetNew(
+ title: context.l10n.backupOnlyNewPhotos,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => backupPreferenceService.isOnlyNewBackupEnabled,
+ onChanged: () async {
+ final hasPermission = await _ensurePhotoPermissions(context);
+ if (!hasPermission) {
+ return;
+ }
+ final shouldProceed = await _maybeHandleFolderSelection(
+ context: context,
+ );
+ if (!shouldProceed) {
+ return;
+ }
+ final isEnabled = backupPreferenceService.isOnlyNewBackupEnabled;
+ if (!isEnabled) {
+ await backupPreferenceService.setOnlyNewSinceNow();
+ } else {
+ await backupPreferenceService.clearOnlyNewSinceEpoch();
+ }
+ debouncer.run(() async {
+ await SyncService.instance.sync();
+ });
+ if (backupPreferenceService.hasSkippedOnboardingPermission) {
+ await backupPreferenceService.setOnboardingPermissionSkipped(
+ false,
);
- if (!shouldProceed) {
- return;
- }
- final isEnabled = backupPreferenceService.isOnlyNewBackupEnabled;
- if (!isEnabled) {
- await backupPreferenceService.setOnlyNewSinceNow();
- } else {
- await backupPreferenceService.clearOnlyNewSinceEpoch();
- }
- _onlyNewToggleDebouncer.run(() async {
- await SyncService.instance.sync();
- });
- if (backupPreferenceService.hasSkippedOnboardingPermission) {
- await backupPreferenceService.setOnboardingPermissionSkipped(
- false,
- );
- }
- },
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- isTopBorderRadiusRemoved: true,
- isBottomBorderRadiusRemoved: flagService.enableMobMultiPart,
- isGestureDetectorDisabled: true,
+ }
+ },
),
- ];
+ );
}
Future<bool> _ensurePhotoPermissions(BuildContext context) async {
diff --git a/mobile/apps/photos/lib/ui/settings/backup/free_space_options.dart b/mobile/apps/photos/lib/ui/settings/backup/free_space_options.dart
index 6b2ba39a0c..19ce1b0894 100644
--- a/mobile/apps/photos/lib/ui/settings/backup/free_space_options.dart
+++ b/mobile/apps/photos/lib/ui/settings/backup/free_space_options.dart
@@ -13,14 +13,9 @@ import "package:photos/services/deduplication_service.dart";
import "package:photos/services/files_service.dart";
import 'package:photos/theme/ente_theme.dart';
import 'package:photos/ui/components/buttons/button_widget.dart';
-import 'package:photos/ui/components/buttons/icon_button_widget.dart';
-import 'package:photos/ui/components/captioned_text_widget.dart';
import "package:photos/ui/components/dialog_widget.dart";
-import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
-import "package:photos/ui/components/menu_section_description_widget.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
import "package:photos/ui/components/models/button_type.dart";
-import 'package:photos/ui/components/title_bar_title_widget.dart';
-import 'package:photos/ui/components/title_bar_widget.dart';
import "package:photos/ui/notification/toast.dart";
import "package:photos/ui/tools/debug/app_storage_viewer.dart";
import "package:photos/ui/tools/deduplicate_page.dart";
@@ -47,320 +42,281 @@ class _FreeUpSpaceOptionsScreenState extends State<FreeUpSpaceOptionsScreen> {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
- return Scaffold(
- body: CustomScrollView(
- primary: false,
- slivers: <Widget>[
- TitleBarWidget(
- flexibleSpaceTitle: TitleBarTitleWidget(
- title: AppLocalizations.of(context).freeUpSpace,
- ),
- actionIcons: [
- IconButtonWidget(
- icon: Icons.close_outlined,
- iconButtonType: IconButtonType.secondary,
- onTap: () {
- Navigator.pop(context);
- Navigator.pop(context);
- },
- ),
- ],
- ),
- SliverList(
- delegate: SliverChildBuilderDelegate(
- (delegateBuildContext, index) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 20),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Column(
- children: [
- Column(
- children: [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .freeUpDeviceSpace,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: Icon(
- Icons.chevron_right_outlined,
- color: colorScheme.strokeBase,
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- showOnlyLoadingState: true,
- onTap: () async {
- BackupStatus status;
- try {
- status = await FilesService.instance
- .getBackupStatus();
- } catch (e) {
- await showGenericErrorDialog(
- context: context,
- error: e,
- );
- return;
- }
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
- if (status.localIDs.isEmpty) {
- // ignore: unawaited_futures
- showErrorDialog(
- context,
- AppLocalizations.of(context).allClear,
- AppLocalizations.of(context)
- .noDeviceThatCanBeDeleted,
- );
- } else {
- final bool? result = await routeToPage(
- context,
- FreeSpacePage(status),
- );
- if (result == true) {
- _showSpaceFreedDialog(status);
- }
- }
- },
- ),
- MenuSectionDescriptionWidget(
- content: AppLocalizations.of(context)
- .freeUpDeviceSpaceDesc,
- ),
- const SizedBox(
- height: 24,
- ),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .removeDuplicates,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: Icon(
- Icons.chevron_right_outlined,
- color: colorScheme.strokeBase,
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- trailingIconIsMuted: true,
- showOnlyLoadingState: true,
- onTap: () async {
- List<DuplicateFiles> duplicates;
- try {
- duplicates = await DeduplicationService
- .instance
- .getDuplicateFiles();
- } catch (e) {
- await showGenericErrorDialog(
- context: context,
- error: e,
- );
- return;
- }
+ final pageBackgroundColor =
+ isDarkMode ? const Color(0xFF161616) : const Color(0xFFFAFAFA);
- if (duplicates.isEmpty) {
- unawaited(
- showErrorDialog(
- context,
- AppLocalizations.of(context)
- .noDuplicates,
- AppLocalizations.of(context)
- .youveNoDuplicateFilesThatCanBeCleared,
- ),
- );
- } else {
- final DeduplicationResult? result =
- await routeToPage(
- context,
- DeduplicatePage(duplicates),
- );
- if (result != null) {
- _showDuplicateFilesDeletedDialog(
- result,
- );
- }
- }
- },
- ),
- Align(
- alignment: Alignment.centerLeft,
- child: MenuSectionDescriptionWidget(
- content: AppLocalizations.of(context)
- .removeDuplicatesDesc,
- ),
- ),
- const SizedBox(
- height: 24,
- ),
- if (flagService.enableVectorDb)
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .similarImages,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: Icon(
- Icons.chevron_right_outlined,
- color: colorScheme.strokeBase,
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- trailingIconIsMuted: true,
- showOnlyLoadingState: true,
- onTap: () async {
- await routeToPage(
- context,
- const SimilarImagesPage(
- debugScreen: kDebugMode,
- ),
- );
- },
- ),
- if (flagService.enableVectorDb)
- Align(
- alignment: Alignment.centerLeft,
- child: MenuSectionDescriptionWidget(
- content: AppLocalizations.of(context)
- .useMLToFindSimilarImages,
- ),
- ),
- if (flagService.enableVectorDb)
- const SizedBox(
- height: 24,
- ),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .viewLargeFiles,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: Icon(
- Icons.chevron_right_outlined,
- color: colorScheme.strokeBase,
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- trailingIconIsMuted: true,
- showOnlyLoadingState: true,
- onTap: () async {
- await routeToPage(
- context,
- LargeFilesPagePage(),
- );
- },
- ),
- Align(
- alignment: Alignment.centerLeft,
- child: MenuSectionDescriptionWidget(
- content: AppLocalizations.of(context)
- .viewLargeFilesDesc,
- ),
- ),
- const SizedBox(
- height: 24,
- ),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .deleteSuggestions,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: Icon(
- Icons.chevron_right_outlined,
- color: colorScheme.strokeBase,
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- showOnlyLoadingState: true,
- onTap: () async {
- List<int> suggestionFileIDs;
- try {
- suggestionFileIDs =
- await CollectionsService.instance
- .fetchDeleteSuggestionFileIDs();
- } catch (e) {
- await showGenericErrorDialog(
- context: context,
- error: e,
- );
- return;
- }
-
- if (suggestionFileIDs.isEmpty) {
- unawaited(
- showErrorDialog(
- context,
- AppLocalizations.of(context)
- .noDeleteSuggestion,
- AppLocalizations.of(context)
- .youHaveNoFileSuggestedForDeletion,
- ),
- );
- } else {
- await routeToPage(
- context,
- DeleteSuggestionsPage(),
- );
- }
- },
- ),
- Align(
- alignment: Alignment.centerLeft,
- child: MenuSectionDescriptionWidget(
- content: AppLocalizations.of(context)
- .deleteSuggestionsDesc,
- ),
- ),
- const SizedBox(
- height: 24,
- ),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .manageDeviceStorage,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: Icon(
- Icons.chevron_right_outlined,
- color: colorScheme.strokeBase,
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- onTap: () async {
- // ignore: unawaited_futures
- routeToPage(
- context,
- const AppStorageViewer(),
- );
- },
- ),
- Align(
- alignment: Alignment.centerLeft,
- child: MenuSectionDescriptionWidget(
- content: AppLocalizations.of(context)
- .manageDeviceStorageDesc,
- ),
- ),
- ],
- ),
- ],
+ 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).freeUpSpace,
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: SingleChildScrollView(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).freeUpDeviceSpace,
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ showOnlyLoadingState: true,
+ onTap: () async => _onFreeUpDeviceSpaceTapped(),
+ ),
+ Padding(
+ padding: const EdgeInsets.only(
+ left: 16,
+ right: 16,
+ top: 8,
+ bottom: 16,
+ ),
+ child: Text(
+ AppLocalizations.of(context).freeUpDeviceSpaceDesc,
+ style: textTheme.mini
+ .copyWith(color: colorScheme.textMuted),
+ ),
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).removeDuplicates,
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ showOnlyLoadingState: true,
+ onTap: () async => _onRemoveDuplicatesTapped(),
+ ),
+ Padding(
+ padding: const EdgeInsets.only(
+ left: 16,
+ right: 16,
+ top: 8,
+ bottom: 16,
+ ),
+ child: Text(
+ AppLocalizations.of(context).removeDuplicatesDesc,
+ style: textTheme.mini
+ .copyWith(color: colorScheme.textMuted),
+ ),
+ ),
+ if (flagService.enableVectorDb) ...[
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).similarImages,
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ showOnlyLoadingState: true,
+ onTap: () async {
+ await routeToPage(
+ context,
+ const SimilarImagesPage(
+ debugScreen: kDebugMode,
+ ),
+ );
+ },
+ ),
+ Padding(
+ padding: const EdgeInsets.only(
+ left: 16,
+ right: 16,
+ top: 8,
+ bottom: 16,
+ ),
+ child: Text(
+ AppLocalizations.of(context)
+ .useMLToFindSimilarImages,
+ style: textTheme.mini
+ .copyWith(color: colorScheme.textMuted),
+ ),
),
],
- ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).viewLargeFiles,
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ showOnlyLoadingState: true,
+ onTap: () async {
+ await routeToPage(
+ context,
+ LargeFilesPagePage(),
+ );
+ },
+ ),
+ Padding(
+ padding: const EdgeInsets.only(
+ left: 16,
+ right: 16,
+ top: 8,
+ bottom: 16,
+ ),
+ child: Text(
+ AppLocalizations.of(context).viewLargeFilesDesc,
+ style: textTheme.mini
+ .copyWith(color: colorScheme.textMuted),
+ ),
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).deleteSuggestions,
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ showOnlyLoadingState: true,
+ onTap: () async => _onDeleteSuggestionsTapped(),
+ ),
+ Padding(
+ padding: const EdgeInsets.only(
+ left: 16,
+ right: 16,
+ top: 8,
+ bottom: 16,
+ ),
+ child: Text(
+ AppLocalizations.of(context).deleteSuggestionsDesc,
+ style: textTheme.mini
+ .copyWith(color: colorScheme.textMuted),
+ ),
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).manageDeviceStorage,
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(
+ context,
+ const AppStorageViewer(),
+ );
+ },
+ ),
+ Padding(
+ padding: const EdgeInsets.only(
+ left: 16,
+ right: 16,
+ top: 8,
+ bottom: 16,
+ ),
+ child: Text(
+ AppLocalizations.of(context).manageDeviceStorageDesc,
+ style: textTheme.mini
+ .copyWith(color: colorScheme.textMuted),
+ ),
+ ),
+ ],
),
- );
- },
- childCount: 1,
- ),
+ ),
+ ),
+ ],
),
- ],
+ ),
),
);
}
+ Future<void> _onFreeUpDeviceSpaceTapped() async {
+ BackupStatus status;
+ try {
+ status = await FilesService.instance.getBackupStatus();
+ } catch (e) {
+ await showGenericErrorDialog(
+ context: context,
+ error: e,
+ );
+ return;
+ }
+
+ if (status.localIDs.isEmpty) {
+ unawaited(
+ showErrorDialog(
+ context,
+ AppLocalizations.of(context).allClear,
+ AppLocalizations.of(context).noDeviceThatCanBeDeleted,
+ ),
+ );
+ } else {
+ final bool? result = await routeToPage(
+ context,
+ FreeSpacePage(status),
+ );
+ if (result == true) {
+ _showSpaceFreedDialog(status);
+ }
+ }
+ }
+
+ Future<void> _onRemoveDuplicatesTapped() async {
+ List<DuplicateFiles> duplicates;
+ try {
+ duplicates = await DeduplicationService.instance.getDuplicateFiles();
+ } catch (e) {
+ await showGenericErrorDialog(
+ context: context,
+ error: e,
+ );
+ return;
+ }
+
+ if (duplicates.isEmpty) {
+ unawaited(
+ showErrorDialog(
+ context,
+ AppLocalizations.of(context).noDuplicates,
+ AppLocalizations.of(context).youveNoDuplicateFilesThatCanBeCleared,
+ ),
+ );
+ } else {
+ final DeduplicationResult? result = await routeToPage(
+ context,
+ DeduplicatePage(duplicates),
+ );
+ if (result != null) {
+ _showDuplicateFilesDeletedDialog(result);
+ }
+ }
+ }
+
+ Future<void> _onDeleteSuggestionsTapped() async {
+ List<int> suggestionFileIDs;
+ try {
+ suggestionFileIDs =
+ await CollectionsService.instance.fetchDeleteSuggestionFileIDs();
+ } catch (e) {
+ await showGenericErrorDialog(
+ context: context,
+ error: e,
+ );
+ return;
+ }
+
+ if (suggestionFileIDs.isEmpty) {
+ unawaited(
+ showErrorDialog(
+ context,
+ AppLocalizations.of(context).noDeleteSuggestion,
+ AppLocalizations.of(context).youHaveNoFileSuggestedForDeletion,
+ ),
+ );
+ } else {
+ await routeToPage(
+ context,
+ DeleteSuggestionsPage(),
+ );
+ }
+ }
+
void _showSpaceFreedDialog(BackupStatus status) {
if (localSettings.shouldPromptToRateUs()) {
localSettings.setRateUsShownCount(
diff --git a/mobile/apps/photos/lib/ui/settings/debug/debug_settings_page.dart b/mobile/apps/photos/lib/ui/settings/debug/debug_settings_page.dart
new file mode 100644
index 0000000000..be7ca3e9e9
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/settings/debug/debug_settings_page.dart
@@ -0,0 +1,291 @@
+import "package:ente_crypto/ente_crypto.dart";
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:photos/core/configuration.dart";
+import "package:photos/core/event_bus.dart";
+import "package:photos/events/christmas_banner_event.dart";
+import "package:photos/service_locator.dart";
+import "package:photos/services/ignored_files_service.dart";
+import "package:photos/services/sync/local_sync_service.dart";
+import "package:photos/services/sync/sync_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/settings/settings_grouped_card.dart";
+import "package:photos/ui/components/toggle_switch_widget.dart";
+import "package:photos/ui/home/christmas/christmas_utils.dart";
+import "package:photos/ui/notification/toast.dart";
+import "package:photos/ui/settings/debug/social_debug_screen.dart";
+
+class DebugSettingsPage extends StatefulWidget {
+ const DebugSettingsPage({super.key});
+
+ @override
+ State<DebugSettingsPage> createState() => _DebugSettingsPageState();
+}
+
+class _DebugSettingsPageState extends State<DebugSettingsPage> {
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ 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(
+ "Debug",
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: SingleChildScrollView(
+ child: Column(
+ children: [
+ SettingsGroupedCard(
+ children: [
+ MenuItemWidgetNew(
+ title: "Disable internal user features",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedUserBlock01,
+ ),
+ trailingWidget: ToggleSwitchWidget(
+ value: () => localSettings.isInternalUserDisabled,
+ onChanged: () async {
+ final newValue =
+ !localSettings.isInternalUserDisabled;
+ await localSettings
+ .setInternalUserDisabled(newValue);
+ setState(() {});
+ showShortToast(
+ context,
+ newValue
+ ? "Internal user disabled. Restart app."
+ : "Internal user enabled. Restart app.",
+ );
+ },
+ ),
+ ),
+ MenuItemWidgetNew(
+ title: "Enable database logging",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedDatabase01,
+ ),
+ trailingWidget: ToggleSwitchWidget(
+ value: () => localSettings.enableDatabaseLogging,
+ onChanged: () async {
+ final newValue =
+ !localSettings.enableDatabaseLogging;
+ await localSettings
+ .setEnableDatabaseLogging(newValue);
+ setState(() {});
+ showShortToast(
+ context,
+ newValue
+ ? "Database logging enabled. Restart app."
+ : "Database logging disabled. Restart app.",
+ );
+ },
+ ),
+ ),
+ MenuItemWidgetNew(
+ title: "Show local ID over thumbnails",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedImage01,
+ ),
+ trailingWidget: ToggleSwitchWidget(
+ value: () =>
+ localSettings.showLocalIDOverThumbnails,
+ onChanged: () async {
+ await localSettings
+ .setShowLocalIDOverThumbnails(
+ !localSettings.showLocalIDOverThumbnails,
+ );
+ setState(() {});
+ showShortToast(
+ context,
+ localSettings.showLocalIDOverThumbnails
+ ? "Local IDs will be shown. Restart app."
+ : "Local IDs hidden. Restart app.",
+ );
+ },
+ ),
+ ),
+ if (isChristmasDateRange())
+ MenuItemWidgetNew(
+ title: "Christmas banner",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedSparkles,
+ ),
+ trailingWidget: ToggleSwitchWidget(
+ value: () =>
+ localSettings.isChristmasBannerEnabled,
+ onChanged: () async {
+ await localSettings
+ .setChristmasBannerEnabled(
+ !localSettings.isChristmasBannerEnabled,
+ );
+ Bus.instance.fire(ChristmasBannerEvent());
+ setState(() {});
+ },
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(height: 8),
+ SettingsGroupedCard(
+ children: [
+ MenuItemWidgetNew(
+ title: "Key attributes",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedKey01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await updateService.resetChangeLog();
+ _showKeyAttributesDialog(context);
+ },
+ ),
+ MenuItemWidgetNew(
+ title: "Delete Local Import DB",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedDelete02,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await LocalSyncService.instance.resetLocalSync();
+ showShortToast(context, "Done");
+ },
+ ),
+ MenuItemWidgetNew(
+ title: "Allow auto-upload for ignored files",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedUpload04,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await IgnoredFilesService.instance.reset();
+ SyncService.instance.sync().ignore();
+ showShortToast(context, "Done");
+ },
+ ),
+ MenuItemWidgetNew(
+ title: "Social settings",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedShare01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (context) =>
+ const SocialDebugScreen(),
+ ),
+ );
+ },
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildIconWidget(BuildContext context, List<List<dynamic>> icon) {
+ final colorScheme = getEnteColorScheme(context);
+ return HugeIcon(
+ icon: icon,
+ color: colorScheme.strokeBase,
+ size: 20,
+ );
+ }
+
+ void _showKeyAttributesDialog(BuildContext context) {
+ final keyAttributes = Configuration.instance.getKeyAttributes()!;
+ final AlertDialog alert = AlertDialog(
+ title: const Text("key attributes"),
+ content: SingleChildScrollView(
+ child: Column(
+ children: [
+ const Text(
+ "Key",
+ style: TextStyle(fontWeight: FontWeight.bold),
+ ),
+ Text(CryptoUtil.bin2base64(Configuration.instance.getKey()!)),
+ const Padding(padding: EdgeInsets.all(12)),
+ const Text(
+ "Encrypted Key",
+ style: TextStyle(fontWeight: FontWeight.bold),
+ ),
+ Text(keyAttributes.encryptedKey),
+ const Padding(padding: EdgeInsets.all(12)),
+ const Text(
+ "Key Decryption Nonce",
+ style: TextStyle(fontWeight: FontWeight.bold),
+ ),
+ Text(keyAttributes.keyDecryptionNonce),
+ const Padding(padding: EdgeInsets.all(12)),
+ const Text(
+ "KEK Salt",
+ style: TextStyle(fontWeight: FontWeight.bold),
+ ),
+ Text(keyAttributes.kekSalt),
+ const Padding(padding: EdgeInsets.all(12)),
+ ],
+ ),
+ ),
+ actions: [
+ TextButton(
+ child: const Text("OK"),
+ onPressed: () {
+ Navigator.of(context).pop('dialog');
+ },
+ ),
+ ],
+ );
+
+ showDialog(
+ useRootNavigator: false,
+ context: context,
+ builder: (BuildContext context) {
+ return alert;
+ },
+ );
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/settings/debug/ml_debug_settings_page.dart b/mobile/apps/photos/lib/ui/settings/debug/ml_debug_settings_page.dart
new file mode 100644
index 0000000000..3eb378e091
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/settings/debug/ml_debug_settings_page.dart
@@ -0,0 +1,529 @@
+import "dart:async";
+
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:logging/logging.dart";
+import "package:photos/core/event_bus.dart";
+import "package:photos/db/ml/db.dart";
+import "package:photos/events/people_changed_event.dart";
+import "package:photos/models/ml/face/person.dart";
+import "package:photos/service_locator.dart";
+import "package:photos/services/machine_learning/face_ml/person/person_service.dart";
+import "package:photos/services/machine_learning/ml_indexing_isolate.dart";
+import "package:photos/services/machine_learning/ml_service.dart";
+import "package:photos/services/machine_learning/semantic_search/semantic_search_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/settings/settings_grouped_card.dart";
+import "package:photos/ui/components/toggle_switch_widget.dart";
+import "package:photos/ui/notification/toast.dart";
+import "package:photos/utils/dialog_util.dart";
+
+class MLDebugSettingsPage extends StatefulWidget {
+ const MLDebugSettingsPage({super.key});
+
+ @override
+ State<MLDebugSettingsPage> createState() => _MLDebugSettingsPageState();
+}
+
+class _MLDebugSettingsPageState extends State<MLDebugSettingsPage> {
+ final Logger logger = Logger("MLDebugSettingsPage");
+ late final mlDataDB = MLDataDB.instance;
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ 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(
+ "ML Debug",
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: SingleChildScrollView(
+ child: Column(
+ children: [
+ _buildMLControlsCard(context),
+ const SizedBox(height: 8),
+ _buildMLActionsCard(context),
+ const SizedBox(height: 8),
+ _buildResetActionsCard(context),
+ const SizedBox(height: 60),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildMLControlsCard(BuildContext context) {
+ return SettingsGroupedCard(
+ children: [
+ MenuItemWidgetNew(
+ title: "ML Consent",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedAiBrain01,
+ ),
+ trailingWidget: ToggleSwitchWidget(
+ value: () => flagService.hasGrantedMLConsent,
+ onChanged: _onMLConsentChanged,
+ ),
+ ),
+ MenuItemWidgetNew(
+ title: "Remote fetch",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedCloud,
+ ),
+ trailingWidget: ToggleSwitchWidget(
+ value: () => localSettings.remoteFetchEnabled,
+ onChanged: _onRemoteFetchChanged,
+ ),
+ ),
+ MenuItemWidgetNew(
+ title: "Local indexing",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedSmartPhone01,
+ ),
+ trailingWidget: ToggleSwitchWidget(
+ value: () => localSettings.isMLLocalIndexingEnabled,
+ onChanged: _onLocalIndexingChanged,
+ ),
+ ),
+ MenuItemWidgetNew(
+ title: "Auto indexing",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedRefresh,
+ ),
+ trailingWidget: ToggleSwitchWidget(
+ value: () => !MLService.instance.debugIndexingDisabled,
+ onChanged: _onAutoIndexingChanged,
+ ),
+ ),
+ ],
+ );
+ }
+
+ Widget _buildMLActionsCard(BuildContext context) {
+ return SettingsGroupedCard(
+ children: [
+ MenuItemWidgetNew(
+ title: "Trigger run ML",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedPlay,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onTriggerRunML(context),
+ ),
+ MenuItemWidgetNew(
+ title: "Trigger run indexing",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedSearch01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onTriggerRunIndexing(context),
+ ),
+ MenuItemWidgetNew(
+ title: "Trigger clustering",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedUserMultiple,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onTriggerClustering(context),
+ ),
+ MenuItemWidgetNew(
+ title: "Update discover",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedCompass01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onUpdateDiscover(context),
+ ),
+ MenuItemWidgetNew(
+ title: "Update memories",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedSparkles,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onUpdateMemories(context),
+ ),
+ MenuItemWidgetNew(
+ title: "Sync person mappings",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedUserSettings01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onSyncPersonMappings(context),
+ ),
+ ],
+ );
+ }
+
+ Widget _buildResetActionsCard(BuildContext context) {
+ return SettingsGroupedCard(
+ children: [
+ if (wrappedService.isEnabled)
+ MenuItemWidgetNew(
+ title: "Recompute Ente Rewind",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedReload,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onRecomputeWrapped(context),
+ ),
+ MenuItemWidgetNew(
+ title: "Clear memories cache",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedDelete02,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onClearMemoriesCache(context),
+ ),
+ MenuItemWidgetNew(
+ title: "Reset faces feedback",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedUserRemove01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onResetFacesFeedback(context),
+ ),
+ MenuItemWidgetNew(
+ title: "Reset faces feedback and clustering",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedUserRemove02,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onResetFacesAndClustering(context),
+ ),
+ MenuItemWidgetNew(
+ title: "Reset all local faces",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedFaceId,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onResetAllLocalFaces(context),
+ ),
+ MenuItemWidgetNew(
+ title: "Reset all local clip",
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedAiSearch,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onResetAllLocalClip(context),
+ ),
+ ],
+ );
+ }
+
+ Widget _buildIconWidget(BuildContext context, List<List<dynamic>> icon) {
+ final colorScheme = getEnteColorScheme(context);
+ return HugeIcon(
+ icon: icon,
+ color: colorScheme.strokeBase,
+ size: 20,
+ );
+ }
+
+ Future<void> _onMLConsentChanged() async {
+ try {
+ final oldMlConsent = flagService.hasGrantedMLConsent;
+ final mlConsent = !oldMlConsent;
+ await flagService.setMLConsent(mlConsent);
+ logger.info('ML consent turned ${mlConsent ? 'on' : 'off'}');
+ if (!mlConsent) {
+ MLService.instance.pauseIndexingAndClustering();
+ unawaited(MLIndexingIsolate.instance.cleanupLocalIndexingModels());
+ } else {
+ await MLService.instance.init();
+ await SemanticSearchService.instance.init();
+ unawaited(MLService.instance.runAllML(force: true));
+ }
+ if (mounted) {
+ setState(() {});
+ }
+ } catch (e, s) {
+ logger.warning('indexing failed ', e, s);
+ if (mounted) {
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+ }
+
+ Future<void> _onRemoteFetchChanged() async {
+ try {
+ await localSettings.toggleRemoteFetch();
+ logger.info(
+ 'Remote fetch is turned ${localSettings.remoteFetchEnabled ? 'on' : 'off'}',
+ );
+ if (mounted) {
+ setState(() {});
+ }
+ } catch (e, s) {
+ logger.warning('Remote fetch toggle failed ', e, s);
+ if (mounted) {
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+ }
+
+ Future<void> _onLocalIndexingChanged() async {
+ final localIndexing = await localSettings.toggleLocalMLIndexing();
+ if (localIndexing) {
+ unawaited(MLService.instance.runAllML(force: true));
+ } else {
+ MLService.instance.pauseIndexingAndClustering();
+ unawaited(MLIndexingIsolate.instance.cleanupLocalIndexingModels());
+ }
+ if (mounted) {
+ setState(() {});
+ }
+ }
+
+ Future<void> _onAutoIndexingChanged() async {
+ try {
+ MLService.instance.debugIndexingDisabled =
+ !MLService.instance.debugIndexingDisabled;
+ if (MLService.instance.debugIndexingDisabled) {
+ MLService.instance.pauseIndexingAndClustering();
+ } else {
+ unawaited(MLService.instance.runAllML());
+ }
+ if (mounted) {
+ setState(() {});
+ }
+ } catch (e, s) {
+ logger.warning('debugIndexingDisabled toggle failed ', e, s);
+ if (mounted) {
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+ }
+
+ Future<void> _onTriggerRunML(BuildContext context) async {
+ try {
+ MLService.instance.debugIndexingDisabled = false;
+ unawaited(MLService.instance.runAllML());
+ showShortToast(context, "ML started");
+ } catch (e, s) {
+ logger.warning('indexAndClusterAll failed ', e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+
+ Future<void> _onTriggerRunIndexing(BuildContext context) async {
+ try {
+ MLService.instance.debugIndexingDisabled = false;
+ unawaited(MLService.instance.fetchAndIndexAllImages());
+ showShortToast(context, "Indexing started");
+ } catch (e, s) {
+ logger.warning('indexing failed ', e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+
+ Future<void> _onTriggerClustering(BuildContext context) async {
+ try {
+ await PersonService.instance.fetchRemoteClusterFeedback();
+ MLService.instance.debugIndexingDisabled = false;
+ await MLService.instance.clusterAllImages();
+ Bus.instance.fire(PeopleChangedEvent());
+ showShortToast(context, "Done");
+ } catch (e, s) {
+ logger.warning('clustering failed ', e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+
+ Future<void> _onUpdateDiscover(BuildContext context) async {
+ try {
+ await magicCacheService.updateCache(forced: true);
+ showShortToast(context, "Done");
+ } catch (e, s) {
+ logger.warning('Update discover failed', e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+
+ Future<void> _onUpdateMemories(BuildContext context) async {
+ try {
+ final now = DateTime.now();
+ await memoriesCacheService.updateCache(forced: true);
+ final duration = DateTime.now().difference(now);
+ showShortToast(context, "Done in ${duration.inSeconds} seconds");
+ } catch (e, s) {
+ logger.warning('Update memories failed', e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+
+ Future<void> _onSyncPersonMappings(BuildContext context) async {
+ try {
+ await faceRecognitionService.syncPersonFeedback();
+ showShortToast(context, "Done");
+ } catch (e, s) {
+ logger.warning('sync person mappings failed ', e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+
+ Future<void> _onRecomputeWrapped(BuildContext context) async {
+ try {
+ await wrappedService.forceRecompute();
+ await localSettings.resetWrapped2025Complete();
+ showShortToast(context, "Ente Rewind recomputed");
+ } catch (e, s) {
+ logger.severe('Wrapped recompute failed ', e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+
+ Future<void> _onClearMemoriesCache(BuildContext context) async {
+ try {
+ final now = DateTime.now();
+ await memoriesCacheService.clearMemoriesCache();
+ final duration = DateTime.now().difference(now);
+ showShortToast(context, "Done in ${duration.inSeconds} seconds");
+ } catch (e, s) {
+ logger.warning('Clear memories cache failed', e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+
+ Future<void> _onResetFacesFeedback(BuildContext context) async {
+ await showChoiceDialog(
+ context,
+ title: "Are you sure?",
+ body:
+ "This will drop all people and their related feedback stored locally.",
+ firstButtonLabel: "Yes, confirm",
+ firstButtonOnTap: () async {
+ try {
+ await mlDataDB.dropFacesFeedbackTables();
+ Bus.instance.fire(PeopleChangedEvent());
+ showShortToast(context, "Done");
+ } catch (e, s) {
+ logger.warning('reset feedback failed ', e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ },
+ );
+ }
+
+ Future<void> _onResetFacesAndClustering(BuildContext context) async {
+ await showChoiceDialog(
+ context,
+ title: "Are you sure?",
+ body:
+ "This will delete all people (also from remote), their related feedback and clustering labels.",
+ firstButtonLabel: "Yes, confirm",
+ firstButtonOnTap: () async {
+ try {
+ final List<PersonEntity> persons =
+ await PersonService.instance.getPersons();
+ for (final PersonEntity p in persons) {
+ await PersonService.instance.deletePerson(p.remoteID);
+ }
+ await mlDataDB.dropClustersAndPersonTable();
+ Bus.instance.fire(PeopleChangedEvent());
+ showShortToast(context, "Done");
+ } catch (e, s) {
+ logger.warning('peopleToPersonMapping remove failed ', e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ },
+ );
+ }
+
+ Future<void> _onResetAllLocalFaces(BuildContext context) async {
+ await showChoiceDialog(
+ context,
+ title: "Are you sure?",
+ body:
+ "This will drop all local faces data. You will need to again re-index faces.",
+ firstButtonLabel: "Yes, confirm",
+ firstButtonOnTap: () async {
+ try {
+ await mlDataDB.dropClustersAndPersonTable(faces: true);
+ Bus.instance.fire(PeopleChangedEvent());
+ showShortToast(context, "Done");
+ } catch (e, s) {
+ logger.warning('drop feedback failed ', e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ },
+ );
+ }
+
+ Future<void> _onResetAllLocalClip(BuildContext context) async {
+ await showChoiceDialog(
+ context,
+ title: "Are you sure?",
+ body:
+ "You will need to again re-index or fetch all clip image embeddings.",
+ firstButtonLabel: "Yes, confirm",
+ firstButtonOnTap: () async {
+ try {
+ await SemanticSearchService.instance.clearIndexes();
+ showShortToast(context, "Done");
+ } catch (e, s) {
+ logger.warning('drop clip embeddings failed ', e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ },
+ );
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart
index e2882c32b2..41238a2057 100644
--- a/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart
+++ b/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart
@@ -6,13 +6,8 @@ import "package:photos/events/swipe_to_select_enabled_event.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/components/buttons/icon_button_widget.dart";
-import "package:photos/ui/components/captioned_text_widget.dart";
-import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
-import "package:photos/ui/components/title_bar_title_widget.dart";
-import "package:photos/ui/components/title_bar_widget.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/viewer/gallery/component/group/type.dart";
import "package:photos/ui/viewer/gallery/gallery_group_type_picker_page.dart";
import "package:photos/ui/viewer/gallery/photo_grid_size_picker_page.dart";
@@ -41,162 +36,126 @@ class _GallerySettingsScreenState extends State<GallerySettingsScreen> {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ final pageBackgroundColor =
+ isDarkMode ? const Color(0xFF161616) : const Color(0xFFFAFAFA);
+
return Scaffold(
- body: CustomScrollView(
- primary: false,
- slivers: <Widget>[
- TitleBarWidget(
- flexibleSpaceTitle: TitleBarTitleWidget(
- title: AppLocalizations.of(context).gallery,
- ),
- actionIcons: widget.fromGalleryLayoutSettingsCTA
- ? null
- : [
- IconButtonWidget(
- icon: Icons.close_outlined,
- iconButtonType: IconButtonType.secondary,
- onTap: () {
- Navigator.pop(context);
- if (!widget.fromGalleryLayoutSettingsCTA) {
- Navigator.pop(context);
- }
- },
- ),
- ],
- ),
- SliverList(
- delegate: SliverChildBuilderDelegate(
- (delegateBuildContext, index) {
- return Padding(
- padding:
- const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
+ 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).gallery,
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: SingleChildScrollView(
child: Column(
- mainAxisSize: MainAxisSize.min,
children: [
- GestureDetector(
- onTap: () {
- routeToPage(
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).photoGridSize,
+ trailingWidget: Text(
+ _photoGridSize.toString(),
+ style: textTheme.small,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(
context,
const PhotoGridSizePickerPage(),
- ).then((value) {
- setState(() {
- _photoGridSize = localSettings.getPhotoGridSize();
- });
+ );
+ setState(() {
+ _photoGridSize = localSettings.getPhotoGridSize();
});
},
- child: MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).photoGridSize,
- subTitle: _photoGridSize.toString(),
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: Icon(
- Icons.chevron_right_outlined,
- color: colorScheme.strokeBase,
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- isGestureDetectorDisabled: true,
- ),
),
- const SizedBox(
- height: 24,
- ),
- GestureDetector(
- onTap: () {
- routeToPage(
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).groupBy,
+ trailingWidget: Text(
+ _groupType,
+ style: textTheme.small,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(
context,
const GalleryGroupTypePickerPage(),
- ).then((value) {
- setState(() {
- _groupType =
- localSettings.getGalleryGroupType().name;
- });
+ );
+ setState(() {
+ _groupType =
+ localSettings.getGalleryGroupType().name;
});
},
- child: MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).groupBy,
- subTitle: _groupType,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: Icon(
- Icons.chevron_right_outlined,
- color: colorScheme.strokeBase,
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- isGestureDetectorDisabled: true,
- ),
),
- const SizedBox(
- height: 24,
- ),
- widget.fromGalleryLayoutSettingsCTA
- ? const SizedBox.shrink()
- : MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .hideSharedItemsFromHomeGallery,
- ),
- menuItemColor: colorScheme.fillFaint,
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- trailingWidget: ToggleSwitchWidget(
- value: () => localSettings
- .hideSharedItemsFromHomeGallery,
- onChanged: () async {
- final prevSetting = localSettings
- .hideSharedItemsFromHomeGallery;
- await localSettings
- .setHideSharedItemsFromHomeGallery(
- !prevSetting,
- );
+ if (!widget.fromGalleryLayoutSettingsCTA) ...[
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context)
+ .hideSharedItemsFromHomeGallery,
+ trailingWidget: ToggleSwitchWidget(
+ value: () =>
+ localSettings.hideSharedItemsFromHomeGallery,
+ onChanged: () async {
+ final prevSetting =
+ localSettings.hideSharedItemsFromHomeGallery;
+ await localSettings
+ .setHideSharedItemsFromHomeGallery(
+ !prevSetting,
+ );
- Bus.instance.fire(
- HideSharedItemsFromHomeGalleryEvent(
- !prevSetting,
- ),
- );
- },
- ),
- ),
- const SizedBox(
- height: 24,
- ),
- widget.fromGalleryLayoutSettingsCTA
- ? const SizedBox.shrink()
- : MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title:
- AppLocalizations.of(context).swipeToSelect,
- ),
- menuItemColor: colorScheme.fillFaint,
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- trailingWidget: ToggleSwitchWidget(
- value: () =>
- localSettings.isSwipeToSelectEnabled,
- onChanged: () async {
- final prevSetting =
- localSettings.isSwipeToSelectEnabled;
- await localSettings
- .setSwipeToSelectEnabled(!prevSetting);
+ Bus.instance.fire(
+ HideSharedItemsFromHomeGalleryEvent(
+ !prevSetting,
+ ),
+ );
+ },
+ ),
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).swipeToSelect,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => localSettings.isSwipeToSelectEnabled,
+ onChanged: () async {
+ final prevSetting =
+ localSettings.isSwipeToSelectEnabled;
+ await localSettings
+ .setSwipeToSelectEnabled(!prevSetting);
- Bus.instance.fire(
- SwipeToSelectEnabledEvent(!prevSetting),
- );
- },
- ),
- ),
+ Bus.instance.fire(
+ SwipeToSelectEnabledEvent(!prevSetting),
+ );
+ },
+ ),
+ ),
+ ],
],
),
- );
- },
- childCount: 1,
- ),
+ ),
+ ),
+ ],
),
- ],
+ ),
),
);
}
diff --git a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_options.dart b/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_options.dart
index cb702141ed..1378bae2f6 100644
--- a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_options.dart
+++ b/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_options.dart
@@ -1,19 +1,11 @@
import "dart:io";
-import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:flutter/material.dart";
import "package:photos/core/configuration.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/components/captioned_text_widget.dart";
-import "package:photos/ui/components/divider_widget.dart";
-import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
-import "package:photos/ui/components/title_bar_title_widget.dart";
-import "package:photos/ui/components/title_bar_widget.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/lock_screen/lock_screen_auto_lock.dart";
-import "package:photos/ui/settings/lock_screen/lock_screen_password.dart";
-import "package:photos/ui/settings/lock_screen/lock_screen_pin.dart";
import "package:photos/ui/tools/app_lock.dart";
import "package:photos/utils/lock_screen_settings.dart";
@@ -28,20 +20,14 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {
final Configuration _configuration = Configuration.instance;
final LockScreenSettings _lockscreenSetting = LockScreenSettings.instance;
late bool appLock;
- bool isPinEnabled = false;
- bool isPasswordEnabled = false;
- late int autoLockTimeInMilliseconds;
late bool hideAppContent;
@override
void initState() {
super.initState();
hideAppContent = _lockscreenSetting.getShouldHideAppContent();
- autoLockTimeInMilliseconds = _lockscreenSetting.getAutoLockTime();
+ appLock = _configuration.shouldShowSystemLockScreen();
_initializeSettings();
- appLock = isPinEnabled ||
- isPasswordEnabled ||
- _configuration.shouldShowSystemLockScreen();
}
Future<void> _initializeSettings() async {
@@ -50,61 +36,10 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {
final bool shouldShowAppContent =
_lockscreenSetting.getShouldHideAppContent();
setState(() {
- isPasswordEnabled = passwordEnabled;
- isPinEnabled = pinEnabled;
hideAppContent = shouldShowAppContent;
- });
- }
-
- Future<void> _deviceLock() async {
- await _lockscreenSetting.removePinAndPassword();
- await _initializeSettings();
- }
-
- Future<void> _pinLock() async {
- final bool result = await Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return const LockScreenPin();
- },
- ),
- );
- setState(() {
- _initializeSettings();
- if (result) {
- appLock = isPinEnabled ||
- isPasswordEnabled ||
- _configuration.shouldShowSystemLockScreen();
- }
- });
- }
-
- Future<void> _passwordLock() async {
- final bool result = await Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return const LockScreenPassword();
- },
- ),
- );
- setState(() {
- _initializeSettings();
- if (result) {
- appLock = isPinEnabled ||
- isPasswordEnabled ||
- _configuration.shouldShowSystemLockScreen();
- }
- });
- }
-
- Future<void> _onAutolock() async {
- await routeToPage(
- context,
- const LockScreenAutoLock(),
- ).then((value) {
- setState(() {
- autoLockTimeInMilliseconds = _lockscreenSetting.getAutoLockTime();
- });
+ appLock = pinEnabled ||
+ passwordEnabled ||
+ _configuration.shouldShowSystemLockScreen();
});
}
@@ -127,225 +62,91 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {
);
}
- String _formatTime(Duration duration) {
- if (duration.inHours != 0) {
- return "in ${duration.inHours} hour${duration.inHours > 1 ? 's' : ''}";
- } else if (duration.inMinutes != 0) {
- return "in ${duration.inMinutes} minute${duration.inMinutes > 1 ? 's' : ''}";
- } else if (duration.inSeconds != 0) {
- return "in ${duration.inSeconds} second${duration.inSeconds > 1 ? 's' : ''}";
- } else {
- return AppLocalizations.of(context).immediately;
- }
- }
-
@override
Widget build(BuildContext context) {
- final colorTheme = getEnteColorScheme(context);
+ final colorScheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ // Figma colors: Light #FAFAFA, Dark #161616
+ final pageBackgroundColor =
+ isDarkMode ? const Color(0xFF161616) : const Color(0xFFFAFAFA);
+
return Scaffold(
- body: CustomScrollView(
- primary: false,
- slivers: <Widget>[
- TitleBarWidget(
- flexibleSpaceTitle: TitleBarTitleWidget(
- title: AppLocalizations.of(context).appLock,
- ),
- ),
- SliverList(
- delegate: SliverChildBuilderDelegate(
- (context, index) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 20),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Column(
- children: [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).appLock,
- ),
- alignCaptionedTextToLeft: true,
- singleBorderRadius: 8,
- menuItemColor: colorTheme.fillFaint,
- trailingWidget: ToggleSwitchWidget(
- value: () => appLock,
- onChanged: () => _onToggleSwitch(),
- ),
- ),
- AnimatedSwitcher(
- duration: const Duration(milliseconds: 210),
- switchInCurve: Curves.easeOut,
- switchOutCurve: Curves.easeIn,
- child: !appLock
- ? Padding(
- padding: const EdgeInsets.only(
- top: 14,
- left: 14,
- right: 12,
- ),
- child: Text(
- AppLocalizations.of(context)
- .appLockDescriptions,
- style: textTheme.miniFaint,
- textAlign: TextAlign.left,
- ),
- )
- : const SizedBox(),
- ),
- const Padding(
- padding: EdgeInsets.only(top: 24),
- ),
- ],
+ backgroundColor: pageBackgroundColor,
+ body: SafeArea(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 24),
+ 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).appLock,
+ style: textTheme.body.copyWith(
+ fontSize: 20,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ const SizedBox(height: 16),
+ Expanded(
+ child: SingleChildScrollView(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).appLock,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => appLock,
+ onChanged: () => _onToggleSwitch(),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.only(top: 8),
+ child: Text(
+ AppLocalizations.of(context).appLockDescriptions,
+ style: textTheme.mini.copyWith(
+ color: colorScheme.textMuted,
+ ),
),
- AnimatedSwitcher(
- duration: const Duration(milliseconds: 210),
- switchInCurve: Curves.easeOut,
- switchOutCurve: Curves.easeIn,
- child: appLock
- ? Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .deviceLock,
- ),
- alignCaptionedTextToLeft: true,
- isTopBorderRadiusRemoved: false,
- isBottomBorderRadiusRemoved: true,
- menuItemColor: colorTheme.fillFaint,
- trailingIcon:
- !(isPasswordEnabled || isPinEnabled)
- ? Icons.check
- : null,
- trailingIconColor: colorTheme.tabIcon,
- onTap: () => _deviceLock(),
- ),
- DividerWidget(
- dividerType: DividerType.menuNoIcon,
- bgColor: colorTheme.fillFaint,
- ),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .pinLock,
- ),
- alignCaptionedTextToLeft: true,
- isTopBorderRadiusRemoved: true,
- isBottomBorderRadiusRemoved: true,
- menuItemColor: colorTheme.fillFaint,
- trailingIcon:
- isPinEnabled ? Icons.check : null,
- trailingIconColor: colorTheme.tabIcon,
- onTap: () => _pinLock(),
- ),
- DividerWidget(
- dividerType: DividerType.menuNoIcon,
- bgColor: colorTheme.fillFaint,
- ),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .passwordLock,
- ),
- alignCaptionedTextToLeft: true,
- isTopBorderRadiusRemoved: true,
- isBottomBorderRadiusRemoved: false,
- menuItemColor: colorTheme.fillFaint,
- trailingIcon: isPasswordEnabled
- ? Icons.check
- : null,
- trailingIconColor: colorTheme.tabIcon,
- onTap: () => _passwordLock(),
- ),
- const SizedBox(
- height: 24,
- ),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .autoLock,
- subTitle: _formatTime(
- Duration(
- milliseconds:
- autoLockTimeInMilliseconds,
- ),
- ),
- ),
- trailingIcon:
- Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- alignCaptionedTextToLeft: true,
- singleBorderRadius: 8,
- menuItemColor: colorTheme.fillFaint,
- trailingIconColor: colorTheme.tabIcon,
- onTap: () => _onAutolock(),
- ),
- Padding(
- padding: const EdgeInsets.only(
- top: 14,
- left: 14,
- right: 12,
- ),
- child: Text(
- AppLocalizations.of(context)
- .autoLockFeatureDescription,
- style: textTheme.miniFaint,
- textAlign: TextAlign.left,
- ),
- ),
- ],
- )
- : Container(),
+ ),
+ const SizedBox(height: 16),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).hideContent,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => hideAppContent,
+ onChanged: () => _tapHideContent(),
),
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- SizedBox(height: appLock ? 24 : 8),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).hideContent,
- ),
- alignCaptionedTextToLeft: true,
- singleBorderRadius: 8,
- menuItemColor: colorTheme.fillFaint,
- trailingWidget: ToggleSwitchWidget(
- value: () => hideAppContent,
- onChanged: () => _tapHideContent(),
- ),
- trailingIconColor: colorTheme.tabIcon,
- ),
- Padding(
- padding: const EdgeInsets.only(
- top: 14,
- left: 14,
- right: 12,
- ),
- child: Text(
- Platform.isAndroid
- ? AppLocalizations.of(context)
- .hideContentDescriptionAndroid
- : AppLocalizations.of(context)
- .hideContentDescriptionIos,
- style: textTheme.miniFaint,
- textAlign: TextAlign.left,
- ),
- ),
- ],
+ ),
+ Padding(
+ padding: const EdgeInsets.only(top: 8),
+ child: Text(
+ Platform.isAndroid
+ ? AppLocalizations.of(context)
+ .hideContentDescriptionAndroid
+ : AppLocalizations.of(context)
+ .hideContentDescriptionIos,
+ style: textTheme.mini.copyWith(
+ color: colorScheme.textMuted,
+ ),
),
- ],
- ),
+ ),
+ ],
),
- );
- },
- childCount: 1,
- ),
+ ),
+ ),
+ ],
),
- ],
+ ),
),
);
}
diff --git a/mobile/apps/photos/lib/ui/settings/memories_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/memories_settings_screen.dart
index d490f67267..7734589fab 100644
--- a/mobile/apps/photos/lib/ui/settings/memories_settings_screen.dart
+++ b/mobile/apps/photos/lib/ui/settings/memories_settings_screen.dart
@@ -7,11 +7,7 @@ import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/memory_home_widget_service.dart";
import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/components/buttons/icon_button_widget.dart";
-import "package:photos/ui/components/captioned_text_widget.dart";
-import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
-import "package:photos/ui/components/title_bar_title_widget.dart";
-import "package:photos/ui/components/title_bar_widget.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
import "package:photos/ui/components/toggle_switch_widget.dart";
class MemoriesSettingsScreen extends StatefulWidget {
@@ -27,41 +23,41 @@ class _MemoriesSettingsScreenState extends State<MemoriesSettingsScreen> {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ final pageBackgroundColor =
+ isDarkMode ? const Color(0xFF161616) : const Color(0xFFFAFAFA);
+
return Scaffold(
- body: CustomScrollView(
- primary: false,
- slivers: <Widget>[
- TitleBarWidget(
- flexibleSpaceTitle: TitleBarTitleWidget(
- title: AppLocalizations.of(context).memories,
- ),
- actionIcons: [
- IconButtonWidget(
- icon: Icons.close_outlined,
- iconButtonType: IconButtonType.secondary,
- onTap: () {
- Navigator.pop(context);
- Navigator.pop(context);
- },
+ 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,
+ ),
),
- ],
- ),
- SliverList(
- delegate: SliverChildBuilderDelegate(
- (delegateBuildContext, index) {
- return Padding(
- padding:
- const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
+ const SizedBox(height: 24),
+ Text(
+ AppLocalizations.of(context).memories,
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: SingleChildScrollView(
child: Column(
- mainAxisSize: MainAxisSize.min,
children: [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).showMemories,
- ),
- menuItemColor: colorScheme.fillFaint,
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).showMemories,
trailingWidget: ToggleSwitchWidget(
value: () => memoriesCacheService.showAnyMemories,
onChanged: () async {
@@ -77,52 +73,37 @@ class _MemoriesSettingsScreenState extends State<MemoriesSettingsScreen> {
},
),
),
- const SizedBox(
- height: 24,
- ),
- memoriesCacheService.curatedMemoriesOption
- ? MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .curatedMemories,
- ),
- menuItemColor: colorScheme.fillFaint,
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- trailingWidget: ToggleSwitchWidget(
- value: () =>
- localSettings.isSmartMemoriesEnabled,
- onChanged: () async {
- unawaited(_toggleUpdateMemories());
- },
- ),
- )
- : const SizedBox(),
- memoriesCacheService.curatedMemoriesOption
- ? const SizedBox(
- height: 24,
- )
- : const SizedBox(),
+ if (memoriesCacheService.curatedMemoriesOption) ...[
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).curatedMemories,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => localSettings.isSmartMemoriesEnabled,
+ onChanged: () async {
+ unawaited(_toggleUpdateMemories());
+ },
+ ),
+ ),
+ ],
],
),
- );
- },
- childCount: 1,
- ),
+ ),
+ ),
+ ],
),
- ],
+ ),
),
);
}
-}
-Future<void> _toggleUpdateMemories() async {
- await localSettings.setSmartMemories(
- !localSettings.isSmartMemoriesEnabled,
- );
- await memoriesCacheService.clearMemoriesCache(
- fromDisk: false,
- );
- await memoriesCacheService.getMemories();
- Bus.instance.fire(MemoriesChangedEvent());
+ Future<void> _toggleUpdateMemories() async {
+ await localSettings.setSmartMemories(
+ !localSettings.isSmartMemoriesEnabled,
+ );
+ await memoriesCacheService.clearMemoriesCache(
+ fromDisk: false,
+ );
+ await memoriesCacheService.getMemories();
+ Bus.instance.fire(MemoriesChangedEvent());
+ }
}
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 6feffd86e0..50be5f24d7 100644
--- a/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart
+++ b/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart
@@ -3,14 +3,8 @@ 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/buttons/icon_button_widget.dart';
-import 'package:photos/ui/components/captioned_text_widget.dart';
-import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
-import 'package:photos/ui/components/menu_section_description_widget.dart';
-import 'package:photos/ui/components/title_bar_title_widget.dart';
-import 'package:photos/ui/components/title_bar_widget.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/common_settings.dart";
class NotificationSettingsScreen extends StatelessWidget {
const NotificationSettingsScreen({super.key});
@@ -18,133 +12,139 @@ class NotificationSettingsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ final pageBackgroundColor =
+ isDarkMode ? const Color(0xFF161616) : const Color(0xFFFAFAFA);
+
return Scaffold(
- body: CustomScrollView(
- primary: false,
- slivers: <Widget>[
- TitleBarWidget(
- flexibleSpaceTitle: TitleBarTitleWidget(
- title: AppLocalizations.of(context).notifications,
- ),
- actionIcons: [
- IconButtonWidget(
- icon: Icons.close_outlined,
- iconButtonType: IconButtonType.secondary,
- onTap: () {
- Navigator.pop(context);
- Navigator.pop(context);
- },
+ 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,
+ ),
),
- ],
- ),
- SliverList(
- delegate: SliverChildBuilderDelegate(
- (context, index) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 20),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .sharedPhotoNotifications,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: ToggleSwitchWidget(
- value: () =>
- NotificationService.instance
- .hasGrantedPermissions() &&
- NotificationService.instance
- .shouldShowNotificationsForSharedPhotos(),
- onChanged: () async {
- await NotificationService.instance
- .requestPermissions();
- await NotificationService.instance
- .setShouldShowNotificationsForSharedPhotos(
- !NotificationService.instance
- .shouldShowNotificationsForSharedPhotos(),
- );
- },
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- isGestureDetectorDisabled: true,
- ),
- MenuSectionDescriptionWidget(
- content: AppLocalizations.of(context)
- .sharedPhotoNotificationsExplanation,
- ),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context)
- .onThisDayMemories,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: ToggleSwitchWidget(
- value: () =>
- NotificationService.instance
- .hasGrantedPermissions() &&
- localSettings
- .isOnThisDayNotificationsEnabled,
- onChanged: () async {
- await NotificationService.instance
- .requestPermissions();
- await memoriesCacheService
- .toggleOnThisDayNotifications();
- },
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- isGestureDetectorDisabled: true,
- ),
- MenuSectionDescriptionWidget(
- content: AppLocalizations.of(context)
- .onThisDayNotificationExplanation,
- ),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).birthdays,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: ToggleSwitchWidget(
- value: () =>
- NotificationService.instance
- .hasGrantedPermissions() &&
- localSettings.birthdayNotificationsEnabled,
- onChanged: () async {
- await NotificationService.instance
- .requestPermissions();
- await memoriesCacheService
- .toggleBirthdayNotifications();
- },
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- isGestureDetectorDisabled: true,
- ),
- MenuSectionDescriptionWidget(
- content: AppLocalizations.of(context)
- .receiveRemindersOnBirthdays,
- ),
- ],
+ 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: [
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context)
+ .sharedPhotoNotifications,
+ trailingWidget: ToggleSwitchWidget(
+ value: () =>
+ NotificationService.instance
+ .hasGrantedPermissions() &&
+ NotificationService.instance
+ .shouldShowNotificationsForSharedPhotos(),
+ onChanged: () async {
+ await NotificationService.instance
+ .requestPermissions();
+ await NotificationService.instance
+ .setShouldShowNotificationsForSharedPhotos(
+ !NotificationService.instance
+ .shouldShowNotificationsForSharedPhotos(),
+ );
+ },
+ ),
+ ),
+ 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).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),
+ ),
+ ),
+ 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),
+ ),
+ ),
+ ],
),
- );
- },
- childCount: 1,
- ),
+ ),
+ ),
+ ],
),
- ],
+ ),
),
);
}
diff --git a/mobile/apps/photos/lib/ui/settings/security/security_settings_page.dart b/mobile/apps/photos/lib/ui/settings/security/security_settings_page.dart
new file mode 100644
index 0000000000..032561ef96
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/settings/security/security_settings_page.dart
@@ -0,0 +1,352 @@
+import "dart:async";
+import "dart:typed_data";
+
+import "package:ente_crypto/ente_crypto.dart";
+import "package:ente_pure_utils/ente_pure_utils.dart";
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:local_auth/local_auth.dart";
+import "package:logging/logging.dart";
+import "package:photos/core/configuration.dart";
+import "package:photos/core/event_bus.dart";
+import "package:photos/events/two_factor_status_change_event.dart";
+import "package:photos/generated/l10n.dart";
+import "package:photos/l10n/l10n.dart";
+import "package:photos/models/user_details.dart";
+import "package:photos/services/account/passkey_service.dart";
+import "package:photos/services/account/user_service.dart";
+import "package:photos/services/local_authentication_service.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/account/request_pwd_verification_page.dart";
+import "package:photos/ui/account/sessions_page.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/notification/toast.dart";
+import "package:photos/ui/settings/lock_screen/lock_screen_options.dart";
+import "package:photos/utils/auth_util.dart";
+import "package:photos/utils/dialog_util.dart";
+
+class SecuritySettingsPage extends StatefulWidget {
+ const SecuritySettingsPage({super.key});
+
+ @override
+ State<SecuritySettingsPage> createState() => _SecuritySettingsPageState();
+}
+
+class _SecuritySettingsPageState extends State<SecuritySettingsPage> {
+ final _config = Configuration.instance;
+ late StreamSubscription<TwoFactorStatusChangeEvent>
+ _twoFactorStatusChangeEvent;
+ final Logger _logger = Logger("SecuritySettingsPage");
+
+ @override
+ void initState() {
+ super.initState();
+ _twoFactorStatusChangeEvent =
+ Bus.instance.on<TwoFactorStatusChangeEvent>().listen((event) async {
+ if (mounted) {
+ setState(() {});
+ }
+ });
+ }
+
+ @override
+ void dispose() {
+ _twoFactorStatusChangeEvent.cancel();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ 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).security,
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: SingleChildScrollView(
+ child: Column(
+ children: [
+ if (_config.hasConfiguredAccount()) ...[
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).twofactor,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedSmartPhone01,
+ ),
+ trailingWidget: ToggleSwitchWidget(
+ value: () =>
+ UserService.instance.hasEnabledTwoFactor(),
+ onChanged: () => _onTwoFactorToggle(context),
+ ),
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context)
+ .emailVerificationToggle,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedMailSecure01,
+ ),
+ trailingWidget: ToggleSwitchWidget(
+ value: () =>
+ UserService.instance.hasEmailMFAEnabled(),
+ onChanged: () => _onEmailMFAToggle(context),
+ ),
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: context.l10n.passkey,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedFingerAccess,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onPasskeyTap(context),
+ ),
+ const SizedBox(height: 8),
+ ],
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).appLock,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedSquareLock02,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => _onAppLockTap(context),
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).activeSessions,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedComputerPhoneSync,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ showOnlyLoadingState: true,
+ onTap: () async => _onActiveSessionsTap(context),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildIconWidget(BuildContext context, List<List<dynamic>> icon) {
+ final colorScheme = getEnteColorScheme(context);
+ return HugeIcon(
+ icon: icon,
+ color: colorScheme.strokeBase,
+ size: 20,
+ );
+ }
+
+ Future<void> _onTwoFactorToggle(BuildContext context) async {
+ final completer = Completer();
+ final hasAuthenticated =
+ await LocalAuthenticationService.instance.requestLocalAuthentication(
+ context,
+ AppLocalizations.of(context).authToConfigureTwofactorAuthentication,
+ );
+ final isTwoFactorEnabled = UserService.instance.hasEnabledTwoFactor();
+ if (hasAuthenticated) {
+ if (isTwoFactorEnabled) {
+ await _disableTwoFactor();
+ completer.isCompleted ? null : completer.complete();
+ } else {
+ await UserService.instance.setupTwoFactor(context, completer);
+ }
+ return completer.future;
+ }
+ }
+
+ Future<void> _disableTwoFactor() async {
+ final alert = AlertDialog(
+ title: Text(AppLocalizations.of(context).disableTwofactor),
+ content: Text(
+ AppLocalizations.of(context).confirm2FADisable,
+ ),
+ actions: [
+ TextButton(
+ child: Text(
+ AppLocalizations.of(context).no,
+ style: TextStyle(
+ color: getEnteColorScheme(context).primary500,
+ ),
+ ),
+ onPressed: () {
+ Navigator.of(context).pop("dialog");
+ },
+ ),
+ TextButton(
+ child: Text(
+ AppLocalizations.of(context).yes,
+ style: const TextStyle(
+ color: Colors.red,
+ ),
+ ),
+ onPressed: () async {
+ await UserService.instance.disableTwoFactor(context);
+ Navigator.of(context).pop("dialog");
+ },
+ ),
+ ],
+ );
+
+ await showDialog(
+ useRootNavigator: false,
+ context: context,
+ builder: (BuildContext context) {
+ return alert;
+ },
+ );
+ }
+
+ Future<void> _onEmailMFAToggle(BuildContext context) async {
+ final hasAuthenticated =
+ await LocalAuthenticationService.instance.requestLocalAuthentication(
+ context,
+ AppLocalizations.of(context).authToChangeEmailVerificationSetting,
+ );
+ final isEmailMFAEnabled = UserService.instance.hasEmailMFAEnabled();
+ if (hasAuthenticated) {
+ await _updateEmailMFA(!isEmailMFAEnabled);
+ }
+ }
+
+ Future<void> _updateEmailMFA(bool isEnabled) async {
+ try {
+ final UserDetails details =
+ await UserService.instance.getUserDetailsV2(memoryCount: false);
+ if ((details.profileData?.canDisableEmailMFA ?? false) == false) {
+ await routeToPage(
+ context,
+ RequestPasswordVerificationPage(
+ onPasswordVerified: (Uint8List keyEncryptionKey) async {
+ final Uint8List loginKey =
+ await CryptoUtil.deriveLoginKey(keyEncryptionKey);
+ await UserService.instance.registerOrUpdateSrp(loginKey);
+ },
+ ),
+ );
+ }
+ await UserService.instance.updateEmailMFA(isEnabled);
+ } catch (e) {
+ showToast(context, AppLocalizations.of(context).somethingWentWrong);
+ }
+ }
+
+ Future<void> _onPasskeyTap(BuildContext context) async {
+ final hasAuthenticated =
+ await LocalAuthenticationService.instance.requestLocalAuthentication(
+ context,
+ AppLocalizations.of(context).authToViewPasskey,
+ );
+ if (hasAuthenticated) {
+ await _handlePasskeyClick(context);
+ }
+ }
+
+ Future<void> _handlePasskeyClick(BuildContext buildContext) async {
+ try {
+ final isPassKeyResetEnabled =
+ await PasskeyService.instance.isPasskeyRecoveryEnabled();
+ if (!isPassKeyResetEnabled) {
+ final Uint8List recoveryKey =
+ await UserService.instance.getOrCreateRecoveryKey(context);
+ final resetKey = CryptoUtil.generateKey();
+ final resetKeyBase64 = CryptoUtil.bin2base64(resetKey);
+ final encryptionResult = CryptoUtil.encryptSync(
+ resetKey,
+ recoveryKey,
+ );
+ await PasskeyService.instance.configurePasskeyRecovery(
+ resetKeyBase64,
+ CryptoUtil.bin2base64(encryptionResult.encryptedData!),
+ CryptoUtil.bin2base64(encryptionResult.nonce!),
+ );
+ }
+ PasskeyService.instance.openPasskeyPage(buildContext).ignore();
+ } catch (e, s) {
+ _logger.severe("failed to open passkey page", e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+
+ Future<void> _onAppLockTap(BuildContext context) async {
+ if (await LocalAuthentication().isDeviceSupported()) {
+ final bool result = await requestAuthentication(
+ context,
+ AppLocalizations.of(context).authToChangeLockscreenSetting,
+ );
+ if (result) {
+ await Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return const LockScreenOptions();
+ },
+ ),
+ );
+ }
+ } else {
+ await showErrorDialog(
+ context,
+ AppLocalizations.of(context).noSystemLockFound,
+ AppLocalizations.of(context)
+ .toEnableAppLockPleaseSetupDevicePasscodeOrScreen,
+ );
+ }
+ }
+
+ Future<void> _onActiveSessionsTap(BuildContext context) async {
+ final hasAuthenticated =
+ await LocalAuthenticationService.instance.requestLocalAuthentication(
+ context,
+ AppLocalizations.of(context).authToViewYourActiveSessions,
+ );
+ if (hasAuthenticated) {
+ unawaited(
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return const SessionsPage();
+ },
+ ),
+ ),
+ );
+ }
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/settings/storage_card_widget.dart b/mobile/apps/photos/lib/ui/settings/storage_card_widget.dart
index 6ac3cdba5b..08fe5eb02d 100644
--- a/mobile/apps/photos/lib/ui/settings/storage_card_widget.dart
+++ b/mobile/apps/photos/lib/ui/settings/storage_card_widget.dart
@@ -1,14 +1,12 @@
-import 'dart:math';
-
import 'package:ente_pure_utils/ente_pure_utils.dart';
import 'package:flutter/material.dart';
+import 'package:intl/intl.dart';
import 'package:logging/logging.dart';
import 'package:photos/core/constants.dart';
import "package:photos/generated/l10n.dart";
import 'package:photos/models/user_details.dart';
import 'package:photos/states/user_details_state.dart';
import 'package:photos/theme/colors.dart';
-import 'package:photos/theme/ente_theme.dart';
import "package:photos/ui/common/loading_widget.dart";
import 'package:photos/ui/payment/subscription.dart';
import 'package:photos/ui/settings/storage_progress_widget.dart';
@@ -21,35 +19,10 @@ class StorageCardWidget extends StatefulWidget {
}
class _StorageCardWidgetState extends State<StorageCardWidget> {
- late Image _background;
final _logger = Logger((_StorageCardWidgetState).toString());
- final ValueNotifier<bool> _isStorageCardPressed = ValueNotifier(false);
int? familyMemberStorageLimit;
bool showFamilyBreakup = false;
- @override
- void initState() {
- super.initState();
- _background = const Image(
- image: AssetImage("assets/storage_card_background.png"),
- fit: BoxFit.fill,
- );
- }
-
- @override
- void didChangeDependencies() {
- super.didChangeDependencies();
- // precache background image to avoid flicker
- // https://stackoverflow.com/questions/51343735/flutter-image-preload
- precacheImage(_background.image, context);
- }
-
- @override
- void dispose() {
- _isStorageCardPressed.dispose();
- super.dispose();
- }
-
@override
Widget build(BuildContext context) {
final inheritedUserDetails = InheritedUserDetails.of(context);
@@ -73,9 +46,6 @@ class _StorageCardWidgetState extends State<StorageCardWidget> {
),
);
},
- onTapDown: (details) => _isStorageCardPressed.value = true,
- onTapCancel: () => _isStorageCardPressed.value = false,
- onTapUp: (details) => _isStorageCardPressed.value = false,
child: containerForUserDetails(userDetails),
);
}
@@ -84,37 +54,24 @@ class _StorageCardWidgetState extends State<StorageCardWidget> {
Widget containerForUserDetails(
UserDetails? userDetails,
) {
- return Stack(
- children: [
- SizedBox(
- width: double.infinity,
- child: _background,
+ return Container(
+ width: double.infinity,
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(15),
+ gradient: const LinearGradient(
+ begin: Alignment.bottomCenter,
+ end: Alignment.topCenter,
+ colors: [
+ Color(0xFF212121),
+ Color(0xFF434343),
+ ],
),
- Positioned.fill(
- child: userDetails is UserDetails
- ? _userDetails(userDetails)
- : const EnteLoadingWidget(
- color: strokeBaseDark,
- ),
- ),
- Positioned.fill(
- child: Align(
- alignment: Alignment.centerRight,
- child: Padding(
- padding: const EdgeInsets.only(right: 4),
- child: ValueListenableBuilder<bool>(
- builder: (BuildContext context, bool value, Widget? child) {
- return Icon(
- Icons.chevron_right_outlined,
- color: value ? strokeMutedDark : strokeBaseDark,
- );
- },
- valueListenable: _isStorageCardPressed,
- ),
+ ),
+ child: userDetails is UserDetails
+ ? _userDetails(userDetails)
+ : const EnteLoadingWidget(
+ color: strokeBaseDark,
),
- ),
- ),
- ],
);
}
@@ -137,8 +94,6 @@ class _StorageCardWidgetState extends State<StorageCardWidget> {
final isMobileScreenSmall =
MediaQuery.of(context).size.width <= mobileSmallThreshold;
- final shouldShowFreeSpaceInMBs = freeStorageInBytes < hundredMBinBytes;
- final shouldShowFreeSpaceInTBs = freeStorageInBytes >= oneTBinBytes;
final shouldShowUsedStorageInTBs = usedStorageInBytes >= oneTBinBytes;
final shouldShowTotalStorageInTBs = totalStorageInBytes >= oneTBinBytes;
final shouldShowUsedStorageInMBs = usedStorageInBytes < hundredMBinBytes;
@@ -151,146 +106,127 @@ class _StorageCardWidgetState extends State<StorageCardWidget> {
final usedStorageInTB = roundGBsToTBs(usedStorageInGB);
final totalStorageInTB = roundGBsToTBs(totalStorageInGB);
- late String freeSpace, freeSpaceUnit;
-
-// Determine the appropriate free space and units
- if (shouldShowFreeSpaceInTBs) {
- freeSpace =
- _roundedFreeSpace(totalStorageInTB, usedStorageInTB).toString();
- freeSpaceUnit = "TB";
- } else if (shouldShowFreeSpaceInMBs) {
- freeSpace = max(0, convertBytesToMBs(freeStorageInBytes)).toString();
- freeSpaceUnit = "MB";
- } else {
- freeSpace =
- _roundedFreeSpace(totalStorageInGB, usedStorageInGB).toString();
- freeSpaceUnit = "GB";
- }
return Padding(
- padding: EdgeInsets.fromLTRB(
- 16,
- 20,
- 16,
- isMobileScreenSmall ? 12 : 20,
- ),
+ padding: const EdgeInsets.fromLTRB(16, 20, 16, 16),
child: Column(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Align(
- alignment: Alignment.topLeft,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- isMobileScreenSmall
- ? AppLocalizations.of(context).usedSpace
- : AppLocalizations.of(context).storage,
- style: getEnteTextTheme(context)
- .small
- .copyWith(color: textMutedDark),
- ),
- const SizedBox(height: 2),
- RichText(
- overflow: TextOverflow.ellipsis,
- maxLines: 1,
- text: TextSpan(
- style: getEnteTextTheme(context)
- .h3Bold
- .copyWith(color: textBaseDark),
- children: _usedStorageDetails(
- isMobileScreenSmall: isMobileScreenSmall,
- shouldShowTotalStorageInTBs: shouldShowTotalStorageInTBs,
- shouldShowUsedStorageInTBs: shouldShowUsedStorageInTBs,
- shouldShowUsedStorageInMBs: shouldShowUsedStorageInMBs,
- usedStorageInBytes: usedStorageInBytes,
- usedStorageInGB: usedStorageInGB,
- totalStorageInTB: totalStorageInTB,
- usedStorageInTB: usedStorageInTB,
- totalStorageInGB: totalStorageInGB,
- ),
- ),
- ),
- ],
+ Text(
+ isMobileScreenSmall
+ ? AppLocalizations.of(context).usedSpace
+ : AppLocalizations.of(context).storage,
+ style: const TextStyle(
+ fontFamily: 'Montserrat',
+ fontSize: 11,
+ fontWeight: FontWeight.w500,
+ color: textMutedDark,
),
),
- Column(
- children: [
- Stack(
- children: <Widget>[
- const StorageProgressWidget(
- color:
- Color.fromRGBO(255, 255, 255, 0.2), //hardcoded in figma
- fractionOfStorage: 1,
- ),
- showFamilyBreakup
- ? StorageProgressWidget(
- color: strokeBaseDark,
- fractionOfStorage:
- ((usedStorageInBytes) / totalStorageInBytes),
- )
- : const SizedBox.shrink(),
- StorageProgressWidget(
- color: showFamilyBreakup
- ? getEnteColorScheme(context).primary300
- : strokeBaseDark,
- fractionOfStorage:
- (userDetails.usage / totalStorageInBytes),
- ),
- ],
+ const SizedBox(height: 2),
+ RichText(
+ overflow: TextOverflow.ellipsis,
+ maxLines: 1,
+ text: TextSpan(
+ style: const TextStyle(
+ fontFamily: 'Montserrat',
+ fontSize: 24,
+ fontWeight: FontWeight.bold,
+ color: textBaseDark,
+ letterSpacing: -1,
),
- const SizedBox(height: 12),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- showFamilyBreakup
- ? Row(
- children: [
- Container(
- width: 8.71,
- height: 8.99,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: getEnteColorScheme(context).primary300,
- ),
- ),
- const SizedBox(width: 4),
- Text(
- AppLocalizations.of(context).storageBreakupYou,
- style: getEnteTextTheme(context)
- .miniBold
- .copyWith(color: textBaseDark),
- ),
- const SizedBox(width: 12),
- Container(
- width: 8.71,
- height: 8.99,
- decoration: const BoxDecoration(
- shape: BoxShape.circle,
- color: textBaseDark,
- ),
- ),
- const SizedBox(width: 4),
- Text(
- AppLocalizations.of(context).storageBreakupFamily,
- style: getEnteTextTheme(context)
- .miniBold
- .copyWith(color: textBaseDark),
- ),
- ],
- )
- : const SizedBox.shrink(),
- Text(
- AppLocalizations.of(context).availableStorageSpace(
- freeAmount: freeSpace,
- storageUnit: freeSpaceUnit,
- ),
- style: getEnteTextTheme(context)
- .mini
- .copyWith(color: textFaintDark),
- ),
- ],
+ children: _usedStorageDetails(
+ isMobileScreenSmall: isMobileScreenSmall,
+ shouldShowTotalStorageInTBs: shouldShowTotalStorageInTBs,
+ shouldShowUsedStorageInTBs: shouldShowUsedStorageInTBs,
+ shouldShowUsedStorageInMBs: shouldShowUsedStorageInMBs,
+ usedStorageInBytes: usedStorageInBytes,
+ usedStorageInGB: usedStorageInGB,
+ totalStorageInTB: totalStorageInTB,
+ usedStorageInTB: usedStorageInTB,
+ totalStorageInGB: totalStorageInGB,
+ ),
+ ),
+ ),
+ const SizedBox(height: 16),
+ Stack(
+ children: <Widget>[
+ const StorageProgressWidget(
+ color: Color.fromRGBO(193, 193, 193, 0.11),
+ fractionOfStorage: 1,
+ ),
+ showFamilyBreakup
+ ? StorageProgressWidget(
+ color: const Color(0xFFF4D93B), // Family: yellow
+ fractionOfStorage:
+ ((usedStorageInBytes) / totalStorageInBytes),
+ )
+ : const SizedBox.shrink(),
+ StorageProgressWidget(
+ color: const Color(0xFF08C225),
+ fractionOfStorage: (userDetails.usage / totalStorageInBytes),
+ ),
+ ],
+ ),
+ const SizedBox(height: 12),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ showFamilyBreakup
+ ? Row(
+ children: [
+ Container(
+ width: 7,
+ height: 7,
+ decoration: const BoxDecoration(
+ shape: BoxShape.circle,
+ color: Color(0xFF08C225),
+ ),
+ ),
+ const SizedBox(width: 4),
+ Text(
+ AppLocalizations.of(context).storageBreakupYou,
+ style: const TextStyle(
+ fontFamily: 'Montserrat',
+ fontSize: 9,
+ fontWeight: FontWeight.w600,
+ color: textBaseDark,
+ ),
+ ),
+ const SizedBox(width: 12),
+ Container(
+ width: 7,
+ height: 7,
+ decoration: const BoxDecoration(
+ shape: BoxShape.circle,
+ color: Color(0xFFF4D93B),
+ ),
+ ),
+ const SizedBox(width: 4),
+ Text(
+ AppLocalizations.of(context).storageBreakupFamily,
+ style: const TextStyle(
+ fontFamily: 'Montserrat',
+ fontSize: 9,
+ fontWeight: FontWeight.w600,
+ color: textBaseDark,
+ ),
+ ),
+ ],
+ )
+ : const SizedBox.shrink(),
+ Text(
+ AppLocalizations.of(context).memoryCount(
+ count: userDetails.fileCount,
+ formattedCount: NumberFormat().format(userDetails.fileCount),
+ ),
+ style: const TextStyle(
+ fontFamily: 'Montserrat',
+ fontSize: 10,
+ fontWeight: FontWeight.w600,
+ color: Color.fromRGBO(165, 165, 165, 0.79),
+ ),
),
],
),
@@ -299,27 +235,6 @@ class _StorageCardWidgetState extends State<StorageCardWidget> {
);
}
- num _roundedFreeSpace(num totalStorageInGB, num usedStorageInGB) {
- int fractionDigits;
- //subtracting usedSpace from totalStorage in GB instead of converting from bytes so that free space and used space adds up in the UI
- final freeStorage = totalStorageInGB - usedStorageInGB;
-
- if (freeStorage >= 1000) {
- return roundGBsToTBs(freeStorage);
- }
- //show one decimal place if free space is less than 10GB
- if (freeStorage < 10) {
- fractionDigits = 1;
- } else {
- fractionDigits = 0;
- }
- //omit decimal if decimal is 0
- if (fractionDigits == 1 && freeStorage.remainder(1) == 0) {
- fractionDigits = 0;
- }
- return num.parse(freeStorage.toStringAsFixed(fractionDigits));
- }
-
List<TextSpan> _usedStorageDetails({
@required isMobileScreenSmall,
@required shouldShowUsedStorageInTBs,
@@ -339,7 +254,7 @@ class _StorageCardWidgetState extends State<StorageCardWidget> {
late num currentUsage, totalStorage;
late String currentUsageUnit, totalStorageUnit;
-// Determine the appropriate usage and units
+ // Determine the appropriate usage and units
if (shouldShowUsedStorageInTBs) {
currentUsage = usedStorageInTB;
currentUsageUnit = "TB";
@@ -351,7 +266,7 @@ class _StorageCardWidgetState extends State<StorageCardWidget> {
currentUsageUnit = "GB";
}
-// Determine the appropriate total storage and units
+ // Determine the appropriate total storage and units
if (shouldShowTotalStorageInTBs) {
totalStorage = totalStorageInTB;
totalStorageUnit = "TB";
@@ -361,14 +276,12 @@ class _StorageCardWidgetState extends State<StorageCardWidget> {
}
return [
- TextSpan(
- text: AppLocalizations.of(context).storageUsageInfo(
- usedAmount: currentUsage,
- usedStorageUnit: currentUsageUnit,
- totalAmount: totalStorage,
- totalStorageUnit: totalStorageUnit,
- ),
+ TextSpan(text: '$currentUsage $currentUsageUnit '),
+ const TextSpan(
+ text: 'of',
+ style: TextStyle(color: textMutedDark),
),
+ TextSpan(text: ' $totalStorage $totalStorageUnit used'),
];
}
}
diff --git a/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart b/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart
index 8e72ebfb76..c7dd3ebd0c 100644
--- a/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart
@@ -12,11 +12,8 @@ import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/common/loading_widget.dart";
import "package:photos/ui/common/web_page.dart";
import "package:photos/ui/components/buttons/button_widget.dart";
-import "package:photos/ui/components/captioned_text_widget.dart";
-import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
import "package:photos/ui/components/models/button_type.dart";
-import "package:photos/ui/components/title_bar_title_widget.dart";
-import "package:photos/ui/components/title_bar_widget.dart";
import "package:photos/ui/components/toggle_switch_widget.dart";
const helpUrl =
@@ -44,8 +41,17 @@ class _VideoStreamingSettingsPageState
@override
Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ final pageBackgroundColor =
+ isDarkMode ? const Color(0xFF161616) : const Color(0xFFFAFAFA);
+
final hasEnabled = VideoPreviewService.instance.isVideoStreamingEnabled;
+
return Scaffold(
+ backgroundColor: pageBackgroundColor,
bottomNavigationBar: !hasEnabled
? SafeArea(
child: Padding(
@@ -67,119 +73,125 @@ class _VideoStreamingSettingsPageState
),
)
: null,
- appBar: hasEnabled
- ? null
- : PreferredSize(
- preferredSize: const Size.fromHeight(154),
- child: TitleBarWidget(
- reducedExpandedHeight: 16,
- flexibleSpaceTitle: TitleBarTitleWidget(
- title: AppLocalizations.of(context).videoStreaming,
+ 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,
),
- actionIcons: const [],
- isSliver: false,
),
- ),
- body: hasEnabled
- ? CustomScrollView(
- primary: false,
- slivers: <Widget>[
- TitleBarWidget(
- reducedExpandedHeight: 16,
- flexibleSpaceTitle: TitleBarTitleWidget(
- title: AppLocalizations.of(context).videoStreaming,
- ),
- actionIcons: const [],
- ),
- SliverToBoxAdapter(
- child: Container(
- padding: const EdgeInsets.only(left: 16, right: 16),
- child: Column(
- children: [
- Text.rich(
- TextSpan(
- children: [
+ const SizedBox(height: 24),
+ Text(
+ AppLocalizations.of(context).videoStreaming,
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: hasEnabled
+ ? SingleChildScrollView(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text.rich(
TextSpan(
- text: AppLocalizations.of(context)
- .videoStreamingDescriptionLine1,
+ children: [
+ TextSpan(
+ text: AppLocalizations.of(context)
+ .videoStreamingDescriptionLine1,
+ ),
+ const TextSpan(text: " "),
+ TextSpan(
+ text: AppLocalizations.of(context)
+ .videoStreamingDescriptionLine2,
+ ),
+ const TextSpan(text: " "),
+ TextSpan(
+ text: AppLocalizations.of(context)
+ .moreDetails,
+ style: TextStyle(
+ color: colorScheme.primary500,
+ ),
+ recognizer: TapGestureRecognizer()
+ ..onTap = openHelp,
+ ),
+ ],
),
- const TextSpan(text: " "),
- TextSpan(
- text: AppLocalizations.of(context)
- .videoStreamingDescriptionLine2,
+ style: textTheme.mini
+ .copyWith(color: colorScheme.textMuted),
+ ),
+ const SizedBox(height: 24),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).enabled,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => hasEnabled,
+ onChanged: () async {
+ await toggleVideoStreaming();
+ },
),
- const TextSpan(text: " "),
- TextSpan(
- text: AppLocalizations.of(context).moreDetails,
- style: TextStyle(
- color: getEnteColorScheme(context).primary500,
+ ),
+ const SizedBox(height: 8),
+ const VideoStreamingStatusWidget(),
+ ],
+ ),
+ )
+ : Center(
+ child: SingleChildScrollView(
+ child: Column(
+ children: [
+ Image.asset(
+ "assets/enable-streaming-static.png",
+ height: 160,
+ ),
+ const SizedBox(height: 16),
+ Padding(
+ padding:
+ const EdgeInsets.symmetric(horizontal: 12),
+ child: Text.rich(
+ TextSpan(
+ children: [
+ TextSpan(
+ text: AppLocalizations.of(context)
+ .videoStreamingDescriptionLine1,
+ ),
+ const TextSpan(text: "\n"),
+ TextSpan(
+ text: AppLocalizations.of(context)
+ .videoStreamingDescriptionLine2,
+ ),
+ const TextSpan(text: "\n"),
+ TextSpan(
+ text: AppLocalizations.of(context)
+ .moreDetails,
+ style: TextStyle(
+ color: colorScheme.primary500,
+ ),
+ recognizer: TapGestureRecognizer()
+ ..onTap = openHelp,
+ ),
+ ],
+ ),
+ style: textTheme.smallMuted,
+ textAlign: TextAlign.center,
),
- recognizer: TapGestureRecognizer()
- ..onTap = openHelp,
),
+ const SizedBox(height: 140),
],
),
- style: getEnteTextTheme(context).mini.copyWith(
- color: getEnteColorScheme(context).textMuted,
- ),
),
- ],
- ),
- ),
- ),
- SliverToBoxAdapter(
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 10,
- ).copyWith(top: 30),
- child: _getStreamingSettings(context),
- ),
- ),
- ],
- )
- : Center(
- child: SingleChildScrollView(
- child: Column(
- children: [
- Image.asset(
- "assets/enable-streaming-static.png",
- height: 160,
- ),
- const SizedBox(height: 16),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12),
- child: Text.rich(
- TextSpan(
- children: [
- TextSpan(
- text: AppLocalizations.of(context)
- .videoStreamingDescriptionLine1,
- ),
- const TextSpan(text: "\n"),
- TextSpan(
- text: AppLocalizations.of(context)
- .videoStreamingDescriptionLine2,
- ),
- const TextSpan(text: "\n"),
- TextSpan(
- text: AppLocalizations.of(context).moreDetails,
- style: TextStyle(
- color: getEnteColorScheme(context).primary500,
- ),
- recognizer: TapGestureRecognizer()
- ..onTap = openHelp,
- ),
- ],
- ),
- style: getEnteTextTheme(context).smallMuted,
- textAlign: TextAlign.center,
),
- ),
- const SizedBox(height: 140),
- ],
- ),
),
- ),
+ ],
+ ),
+ ),
+ ),
);
}
@@ -200,32 +212,6 @@ class _VideoStreamingSettingsPageState
if (!mounted) return;
setState(() {});
}
-
- Widget _getStreamingSettings(BuildContext context) {
- final hasEnabled = VideoPreviewService.instance.isVideoStreamingEnabled;
- final colorScheme = getEnteColorScheme(context);
-
- return Column(
- children: [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).enabled,
- ),
- trailingWidget: ToggleSwitchWidget(
- value: () => hasEnabled,
- onChanged: () async {
- await toggleVideoStreaming();
- },
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- menuItemColor: colorScheme.fillFaint,
- ),
- const SizedBox(height: 8),
- const VideoStreamingStatusWidget(),
- ],
- );
- }
}
class VideoStreamingStatusWidget extends StatefulWidget {
@@ -272,37 +258,31 @@ class VideoStreamingStatusWidgetState
@override
Widget build(BuildContext context) {
+ final textTheme = getEnteTextTheme(context);
final colorScheme = getEnteColorScheme(context);
+
return Column(
children: [
if (_netProcessed != null)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).processed,
- ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).processed,
trailingWidget: Text(
_netProcessed == 0
? '0%'
: '${(_netProcessed! * 100.0).toStringAsFixed(2)}%',
- style: Theme.of(context).textTheme.bodySmall,
+ style: textTheme.small,
),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- isGestureDetectorDisabled: true,
- key: ValueKey("processed_items_" + _netProcessed.toString()),
- menuItemColor: colorScheme.fillFaint,
+ key: ValueKey("processed_items_$_netProcessed"),
),
const SizedBox(height: 12),
Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8.0),
+ padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
AppLocalizations.of(context).videoStreamingNote,
- style: getEnteTextTheme(context).mini.copyWith(
- color: getEnteColorScheme(context).textMuted,
- ),
+ style: textTheme.mini.copyWith(color: colorScheme.textMuted),
),
),
],
diff --git a/mobile/apps/photos/lib/ui/settings/support/help_support_page.dart b/mobile/apps/photos/lib/ui/settings/support/help_support_page.dart
new file mode 100644
index 0000000000..a6ee6f416c
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/settings/support/help_support_page.dart
@@ -0,0 +1,160 @@
+import "dart:io";
+
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:photos/core/constants.dart";
+import "package:photos/core/error-reporting/super_logging.dart";
+import "package:photos/generated/l10n.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/common/web_page.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
+import "package:photos/ui/components/settings/settings_grouped_card.dart";
+import "package:photos/ui/components/toggle_switch_widget.dart";
+import "package:photos/utils/email_util.dart";
+import "package:url_launcher/url_launcher_string.dart";
+
+class HelpSupportPage extends StatelessWidget {
+ const HelpSupportPage({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ final pageBackgroundColor =
+ isDarkMode ? const Color(0xFF161616) : const Color(0xFFFAFAFA);
+
+ final String bugsEmail =
+ Platform.isAndroid ? "[email protected]" : "[email protected]";
+
+ 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).support,
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: SingleChildScrollView(
+ child: Column(
+ children: [
+ SettingsGroupedCard(
+ children: [
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).help,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedHelpCircle,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return WebPage(
+ AppLocalizations.of(context).help,
+ "https://ente.io/help",
+ );
+ },
+ ),
+ );
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).reportABug,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedBug02,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await sendLogs(
+ context,
+ AppLocalizations.of(context).reportBug,
+ bugsEmail,
+ );
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).contactSupport,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedMail01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await sendEmail(context, to: supportEmail);
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).suggestFeatures,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedIdea01,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await launchUrlString(
+ githubDiscussionsUrl,
+ mode: LaunchMode.externalApplication,
+ );
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).crashReporting,
+ leadingIconWidget: _buildIconWidget(
+ context,
+ HugeIcons.strokeRoundedAlert02,
+ ),
+ trailingWidget: ToggleSwitchWidget(
+ value: () => SuperLogging.shouldReportCrashes(),
+ onChanged: () async {
+ await SuperLogging.setShouldReportCrashes(
+ !SuperLogging.shouldReportCrashes(),
+ );
+ },
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildIconWidget(BuildContext context, List<List<dynamic>> icon) {
+ final colorScheme = getEnteColorScheme(context);
+ return HugeIcon(
+ icon: icon,
+ color: colorScheme.strokeBase,
+ size: 20,
+ );
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/settings/widget_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/widget_settings_screen.dart
index b609e7c673..9d77fb0e58 100644
--- a/mobile/apps/photos/lib/ui/settings/widget_settings_screen.dart
+++ b/mobile/apps/photos/lib/ui/settings/widget_settings_screen.dart
@@ -4,11 +4,7 @@ import "package:flutter_svg/flutter_svg.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
import 'package:photos/theme/ente_theme.dart';
-import 'package:photos/ui/components/buttons/icon_button_widget.dart';
-import 'package:photos/ui/components/captioned_text_widget.dart';
-import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
-import 'package:photos/ui/components/title_bar_title_widget.dart';
-import 'package:photos/ui/components/title_bar_widget.dart';
+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
import "package:photos/ui/settings/ml/enable_ml_consent.dart";
import "package:photos/ui/settings/widgets/albums_widget_settings.dart";
import "package:photos/ui/settings/widgets/memories_widget_settings.dart";
@@ -50,98 +46,93 @@ class WidgetSettingsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ final pageBackgroundColor =
+ isDarkMode ? const Color(0xFF161616) : const Color(0xFFFAFAFA);
+
return Scaffold(
- body: CustomScrollView(
- primary: false,
- slivers: <Widget>[
- TitleBarWidget(
- flexibleSpaceTitle: TitleBarTitleWidget(
- title: AppLocalizations.of(context).widgets,
- ),
- actionIcons: [
- IconButtonWidget(
- icon: Icons.close_outlined,
- iconButtonType: IconButtonType.secondary,
- onTap: () {
- Navigator.pop(context);
- Navigator.pop(context);
- },
+ 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,
+ ),
),
- ],
- ),
- SliverList(
- delegate: SliverChildBuilderDelegate(
- (context, index) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 20),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Column(
- children: [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).people,
- ),
- leadingIconWidget: SvgPicture.asset(
- "assets/icons/people-widget-icon.svg",
- colorFilter: ColorFilter.mode(
- colorScheme.textBase,
- BlendMode.srcIn,
- ),
- ),
- menuItemColor: colorScheme.fillFaint,
- singleBorderRadius: 8,
- trailingIcon: Icons.chevron_right_outlined,
- onTap: () async => onPeopleTapped(context),
- ),
- const SizedBox(height: 8),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).albums,
- ),
- leadingIconWidget: SvgPicture.asset(
- "assets/icons/albums-widget-icon.svg",
- colorFilter: ColorFilter.mode(
- colorScheme.textBase,
- BlendMode.srcIn,
- ),
- ),
- menuItemColor: colorScheme.fillFaint,
- singleBorderRadius: 8,
- trailingIcon: Icons.chevron_right_outlined,
- onTap: () async => onAlbumsTapped(context),
- ),
- const SizedBox(height: 8),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).memories,
- ),
- leadingIconWidget: SvgPicture.asset(
- "assets/icons/memories-widget-icon.svg",
- colorFilter: ColorFilter.mode(
- colorScheme.textBase,
- BlendMode.srcIn,
- ),
- ),
- menuItemColor: colorScheme.fillFaint,
- singleBorderRadius: 8,
- trailingIcon: Icons.chevron_right_outlined,
- onTap: () async => onMemoriesTapped(context),
- ),
- ],
+ const SizedBox(height: 24),
+ Text(
+ AppLocalizations.of(context).widgets,
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Expanded(
+ child: SingleChildScrollView(
+ child: Column(
+ children: [
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).people,
+ leadingIconWidget: SvgPicture.asset(
+ "assets/icons/people-widget-icon.svg",
+ colorFilter: ColorFilter.mode(
+ colorScheme.strokeBase,
+ BlendMode.srcIn,
+ ),
+ width: 20,
+ height: 20,
),
- ],
- ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => onPeopleTapped(context),
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).albums,
+ leadingIconWidget: SvgPicture.asset(
+ "assets/icons/albums-widget-icon.svg",
+ colorFilter: ColorFilter.mode(
+ colorScheme.strokeBase,
+ BlendMode.srcIn,
+ ),
+ width: 20,
+ height: 20,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => onAlbumsTapped(context),
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).memories,
+ leadingIconWidget: SvgPicture.asset(
+ "assets/icons/memories-widget-icon.svg",
+ colorFilter: ColorFilter.mode(
+ colorScheme.strokeBase,
+ BlendMode.srcIn,
+ ),
+ width: 20,
+ height: 20,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async => onMemoriesTapped(context),
+ ),
+ ],
),
- );
- },
- childCount: 1,
- ),
+ ),
+ ),
+ ],
),
- ],
+ ),
),
);
}
diff --git a/mobile/apps/photos/lib/ui/settings_page.dart b/mobile/apps/photos/lib/ui/settings_page.dart
index 5c199294da..33d50a7185 100644
--- a/mobile/apps/photos/lib/ui/settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings_page.dart
@@ -1,35 +1,45 @@
-import 'dart:io';
-
import "package:ente_pure_utils/ente_pure_utils.dart";
-import 'package:flutter/foundation.dart';
-import 'package:flutter/material.dart';
-import "package:flutter_animate/flutter_animate.dart";
+import "package:flutter/foundation.dart";
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
import "package:log_viewer/log_viewer.dart";
-import 'package:photos/core/configuration.dart';
-import 'package:photos/core/event_bus.dart';
-import 'package:photos/events/opened_settings_event.dart';
+import "package:photos/core/configuration.dart";
+import "package:photos/core/event_bus.dart";
+import "package:photos/emergency/emergency_page.dart";
+import "package:photos/events/opened_settings_event.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
-import 'package:photos/theme/colors.dart';
-import 'package:photos/theme/ente_theme.dart';
-import "package:photos/ui/components/notification_widget.dart";
+import "package:photos/services/account/user_service.dart";
+import "package:photos/services/local_authentication_service.dart";
+import "package:photos/theme/colors.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/theme/text_style.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
+import "package:photos/ui/components/settings/settings_grouped_card.dart";
+import "package:photos/ui/components/settings/social_icons_row.dart";
+import "package:photos/ui/components/toggle_switch_widget.dart";
import "package:photos/ui/growth/referral_screen.dart";
-import 'package:photos/ui/settings/about_section_widget.dart';
-import 'package:photos/ui/settings/account_section_widget.dart';
-import 'package:photos/ui/settings/app_version_widget.dart';
-import 'package:photos/ui/settings/backup/backup_section_widget.dart';
-import 'package:photos/ui/settings/debug/debug_section_widget.dart';
-import "package:photos/ui/settings/debug/ml_debug_section_widget.dart";
-import "package:photos/ui/settings/developer_settings_widget.dart";
-import 'package:photos/ui/settings/general_section_widget.dart';
-import 'package:photos/ui/settings/inherited_settings_state.dart';
-import 'package:photos/ui/settings/security_section_widget.dart';
-import 'package:photos/ui/settings/settings_title_bar_widget.dart';
-import 'package:photos/ui/settings/social_section_widget.dart';
-import 'package:photos/ui/settings/storage_card_widget.dart';
-import 'package:photos/ui/settings/support_section_widget.dart';
-import 'package:photos/ui/settings/theme_switch_widget.dart';
+import "package:photos/ui/notification/toast.dart";
+import "package:photos/ui/settings/about/about_us_page.dart";
+import "package:photos/ui/settings/account/account_settings_page.dart";
+import "package:photos/ui/settings/app_version_widget.dart";
+import "package:photos/ui/settings/appearance/appearance_settings_page.dart";
+import "package:photos/ui/settings/backup/backup_settings_page.dart";
+import "package:photos/ui/settings/backup/free_space_options.dart";
+import "package:photos/ui/settings/debug/debug_settings_page.dart";
+import "package:photos/ui/settings/debug/ml_debug_settings_page.dart";
+import "package:photos/ui/settings/inherited_settings_state.dart";
+import "package:photos/ui/settings/memories_settings_screen.dart";
+import "package:photos/ui/settings/ml/machine_learning_settings_page.dart";
+import "package:photos/ui/settings/notification_settings_screen.dart";
+import "package:photos/ui/settings/security/security_settings_page.dart";
+import "package:photos/ui/settings/storage_card_widget.dart";
+import "package:photos/ui/settings/streaming/video_streaming_settings_page.dart";
+import "package:photos/ui/settings/support/help_support_page.dart";
+import "package:photos/ui/settings/widget_settings_screen.dart";
import "package:photos/ui/sharing/verify_identity_dialog.dart";
+import "package:photos/utils/dialog_util.dart";
+import "package:url_launcher/url_launcher_string.dart";
class SettingsPage extends StatelessWidget {
final ValueNotifier<String?> emailNotifier;
@@ -39,168 +49,530 @@ class SettingsPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
Bus.instance.fire(OpenedSettingsEvent());
- final enteColorScheme = getEnteColorScheme(context);
+
return Scaffold(
- body: Container(
- color: enteColorScheme.backdropMuted,
- child: SettingsStateContainer(
- child: _getBody(context, enteColorScheme),
- ),
+ body: SettingsStateContainer(
+ child: _SettingsBody(emailNotifier: emailNotifier),
),
);
}
+}
+
+class _SettingsBody extends StatelessWidget {
+ final ValueNotifier<String?> emailNotifier;
+
+ const _SettingsBody({required this.emailNotifier});
- Widget _getBody(BuildContext context, EnteColorScheme colorScheme) {
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
final hasLoggedIn = Configuration.instance.isLoggedIn();
- final enteTextTheme = getEnteTextTheme(context);
- final List<Widget> contents = [];
- const sectionSpacing = SizedBox(height: 8);
- contents.add(
- GestureDetector(
- onDoubleTap: () {
- _showVerifyIdentityDialog(context);
- },
- onLongPress: () {
- _showVerifyIdentityDialog(context);
- },
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8),
- child: Align(
- alignment: Alignment.centerLeft,
- child: AnimatedBuilder(
- // [AnimatedBuilder] accepts any [Listenable] subtype.
- animation: emailNotifier,
- builder: (BuildContext context, Widget? child) {
- return Row(
- children: [
- Expanded(
- child: Text(
- emailNotifier.value!,
- style: enteTextTheme.body.copyWith(
- color: colorScheme.textMuted,
- overflow: TextOverflow.ellipsis,
- ),
- ),
- ),
- if (localSettings.enableDatabaseLogging)
- GestureDetector(
- onTap: () {
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => const LogViewerPage(),
- ),
- );
- },
- child: Container(
- padding: const EdgeInsets.all(8),
- child: Icon(
- Icons.bug_report,
- size: 20,
- color: colorScheme.textMuted,
- ),
- ),
- ),
- ],
- );
- },
+
+ final pageBackgroundColor =
+ isDarkMode ? const Color(0xFF161616) : const Color(0xFFFAFAFA);
+
+ return Container(
+ color: pageBackgroundColor,
+ child: SafeArea(
+ bottom: false,
+ child: SingleChildScrollView(
+ physics: const BouncingScrollPhysics(),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ _buildTitleBar(context, colorScheme),
+ const SizedBox(height: 16),
+ _buildEmailHeader(context, colorScheme, textTheme),
+ const SizedBox(height: 16),
+ if (hasLoggedIn) ...[
+ const StorageCardWidget(),
+ const SizedBox(height: 16),
+ _buildAccountCard(context, colorScheme),
+ const SizedBox(height: 8),
+ _buildBackupCard(context, colorScheme),
+ const SizedBox(height: 8),
+ ],
+ _buildSecurityCard(context, colorScheme),
+ const SizedBox(height: 8),
+ _buildAppearanceCard(context, colorScheme),
+ const SizedBox(height: 8),
+ if (hasLoggedIn) ...[
+ _buildPersonalFeaturesCard(context, colorScheme),
+ const SizedBox(height: 8),
+ _buildFeaturesAndPlansCard(context, colorScheme),
+ const SizedBox(height: 8),
+ _buildEngagementCard(context, colorScheme),
+ const SizedBox(height: 8),
+ ],
+ _buildHelpSupportCard(context, colorScheme),
+ const SizedBox(height: 8),
+ _buildAboutUsCard(context, colorScheme),
+ const SizedBox(height: 8),
+ if (hasLoggedIn) ...[
+ _buildLogoutCard(context, colorScheme),
+ const SizedBox(height: 16),
+ ],
+ const SocialIconsRow(),
+ const AppVersionWidget(),
+ if (hasLoggedIn &&
+ (flagService.flags.internalUser || kDebugMode)) ...[
+ _buildDebugCard(context, colorScheme),
+ const SizedBox(height: 8),
+ _buildMLDebugCard(context, colorScheme),
+ const SizedBox(height: 16),
+ ],
+ const SizedBox(height: 60),
+ ],
),
),
),
),
);
+ }
- contents.add(const SizedBox(height: 8));
- if (hasLoggedIn) {
- // show banner in debug mode and ente production
- final showStorageBonusBanner =
- storageBonusService.shouldShowStorageBonus() &&
- (kDebugMode || Configuration.instance.isEnteProduction());
- contents.addAll([
- const StorageCardWidget(),
- (showStorageBonusBanner)
- ? RepaintBoundary(
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 8.0),
- child: NotificationWidget(
- startIcon: Icons.auto_awesome,
- actionIcon: Icons.arrow_forward_outlined,
- text: AppLocalizations.of(context).doubleYourStorage,
- subText:
- AppLocalizations.of(context).referFriendsAnd2xYourPlan,
- type: NotificationType.goldenBanner,
- onTap: () async {
- storageBonusService.markStorageBonusAsDone();
- // ignore: unawaited_futures
- routeToPage(context, const ReferralScreen());
- },
- ),
- ).animate(onPlay: (controller) => controller.repeat()).shimmer(
- duration: 1000.ms,
- delay: 3200.ms,
- size: 0.6,
- ),
- )
- : const SizedBox(height: 12),
- const BackupSectionWidget(),
- sectionSpacing,
- const AccountSectionWidget(),
- sectionSpacing,
- ]);
- }
- contents.addAll([
- const SecuritySectionWidget(),
- sectionSpacing,
- const GeneralSectionWidget(),
- sectionSpacing,
- ]);
-
- if (Platform.isAndroid || kDebugMode) {
- contents.addAll([
- const ThemeSwitchWidget(),
- sectionSpacing,
- ]);
- }
-
- contents.addAll([
- const SupportSectionWidget(),
- sectionSpacing,
- const SocialSectionWidget(),
- sectionSpacing,
- const AboutSectionWidget(),
- ]);
-
- if (hasLoggedIn && (flagService.flags.internalUser || kDebugMode)) {
- contents.addAll([sectionSpacing, const DebugSectionWidget()]);
- contents.addAll([sectionSpacing, const MLDebugSectionWidget()]);
- }
- contents.add(const AppVersionWidget());
- contents.add(const DeveloperSettingsWidget());
- contents.add(
- const Padding(
- padding: EdgeInsets.only(bottom: 60),
- ),
+ Widget _buildTitleBar(BuildContext context, EnteColorScheme colorScheme) {
+ return Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ GestureDetector(
+ onTap: () => Navigator.of(context).pop(),
+ child: Container(
+ padding: const EdgeInsets.all(8),
+ child: Icon(
+ Icons.chevron_left,
+ size: 24,
+ color: colorScheme.textBase,
+ ),
+ ),
+ ),
+ if (localSettings.enableDatabaseLogging)
+ GestureDetector(
+ onTap: () {
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (context) => const LogViewerPage(),
+ ),
+ );
+ },
+ child: Container(
+ padding: const EdgeInsets.all(8),
+ child: Icon(
+ Icons.bug_report,
+ size: 20,
+ color: colorScheme.textMuted,
+ ),
+ ),
+ ),
+ ],
);
+ }
- return SafeArea(
- bottom: false,
- child: SingleChildScrollView(
- physics: const BouncingScrollPhysics(),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- const SettingsTitleBarWidget(),
- Padding(
- padding: const EdgeInsets.fromLTRB(16, 16, 16, 24),
- child: Column(
- children: contents,
+ Widget _buildEmailHeader(
+ BuildContext context,
+ EnteColorScheme colorScheme,
+ EnteTextTheme textTheme,
+ ) {
+ return GestureDetector(
+ onDoubleTap: () => _showVerifyIdentityDialog(context),
+ onLongPress: () => _showVerifyIdentityDialog(context),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: AnimatedBuilder(
+ animation: emailNotifier,
+ builder: (BuildContext context, Widget? child) {
+ return Text(
+ emailNotifier.value ?? "",
+ style: textTheme.body.copyWith(
+ color: colorScheme.textMuted,
+ overflow: TextOverflow.ellipsis,
),
- ),
- ],
+ );
+ },
),
),
);
}
+ Widget _buildIconWidget(
+ List<List<dynamic>> icon,
+ EnteColorScheme colorScheme, {
+ bool isDestructive = false,
+ }) {
+ return HugeIcon(
+ icon: icon,
+ color: isDestructive ? colorScheme.warning700 : colorScheme.strokeBase,
+ size: 20,
+ );
+ }
+
+ Widget _buildAccountCard(BuildContext context, EnteColorScheme colorScheme) {
+ return MenuItemWidgetNew(
+ title: AppLocalizations.of(context).account,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedUser,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const AccountSettingsPage());
+ },
+ );
+ }
+
+ Widget _buildBackupCard(BuildContext context, EnteColorScheme colorScheme) {
+ return MenuItemWidgetNew(
+ title: AppLocalizations.of(context).backup,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedCloudUpload,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const BackupSettingsPage());
+ },
+ );
+ }
+
+ Widget _buildSecurityCard(BuildContext context, EnteColorScheme colorScheme) {
+ return MenuItemWidgetNew(
+ title: AppLocalizations.of(context).security,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedSecurityCheck,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const SecuritySettingsPage());
+ },
+ );
+ }
+
+ Widget _buildAppearanceCard(
+ BuildContext context,
+ EnteColorScheme colorScheme,
+ ) {
+ return MenuItemWidgetNew(
+ title: AppLocalizations.of(context).appearance,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedPaintBoard,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const AppearanceSettingsPage());
+ },
+ );
+ }
+
+ Widget _buildPersonalFeaturesCard(
+ BuildContext context,
+ EnteColorScheme colorScheme,
+ ) {
+ return SettingsGroupedCard(
+ children: [
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).legacy,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedFavourite,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ showOnlyLoadingState: true,
+ onTap: () async {
+ final hasAuthenticated = kDebugMode ||
+ await LocalAuthenticationService.instance
+ .requestLocalAuthentication(
+ context,
+ AppLocalizations.of(context).authToManageLegacy,
+ );
+ if (hasAuthenticated) {
+ await Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return const EmergencyPage();
+ },
+ ),
+ );
+ }
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).memories,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedSparkles,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const MemoriesSettingsScreen());
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).notifications,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedNotification01,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const NotificationSettingsScreen());
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).widgets,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedAlignBoxBottomRight,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const WidgetSettingsScreen());
+ },
+ ),
+ ],
+ );
+ }
+
+ Widget _buildFeaturesAndPlansCard(
+ BuildContext context,
+ EnteColorScheme colorScheme,
+ ) {
+ return SettingsGroupedCard(
+ children: [
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).machineLearning,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedMagicWand01,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const MachineLearningSettingsPage());
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).videoStreaming,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedVideoCameraAi,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const VideoStreamingSettingsPage());
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).freeUpSpace,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedRocket01,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ showOnlyLoadingState: true,
+ onTap: () async {
+ await routeToPage(context, const FreeUpSpaceOptionsScreen());
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).referrals,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedTicketStar,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const ReferralScreen());
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).familyPlans,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedUserMultiple,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ showOnlyLoadingState: true,
+ onTap: () async {
+ final userDetails =
+ await UserService.instance.getUserDetailsV2(memoryCount: false);
+ await billingService.launchFamilyPortal(context, userDetails);
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).maps,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedMaping,
+ colorScheme,
+ ),
+ trailingWidget: ToggleSwitchWidget(
+ value: () => flagService.mapEnabled,
+ onChanged: () async {
+ final isEnabled = flagService.mapEnabled;
+ try {
+ await flagService.setMapEnabled(!isEnabled);
+ } catch (e) {
+ showShortToast(
+ context,
+ AppLocalizations.of(context).somethingWentWrong,
+ );
+ rethrow;
+ }
+ },
+ ),
+ ),
+ ],
+ );
+ }
+
+ Widget _buildEngagementCard(
+ BuildContext context,
+ EnteColorScheme colorScheme,
+ ) {
+ final result = updateService.getRateDetails();
+ final String rateUrl = result.item2;
+
+ return SettingsGroupedCard(
+ children: [
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).merchandise,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedTShirt,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await launchUrlString(
+ "https://shop.ente.io",
+ mode: LaunchMode.externalApplication,
+ );
+ },
+ ),
+ MenuItemWidgetNew(
+ title: AppLocalizations.of(context).rateUs,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedStar,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await launchUrlString(rateUrl);
+ },
+ ),
+ ],
+ );
+ }
+
+ Widget _buildHelpSupportCard(
+ BuildContext context,
+ EnteColorScheme colorScheme,
+ ) {
+ return MenuItemWidgetNew(
+ title: AppLocalizations.of(context).support,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedHelpCircle,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const HelpSupportPage());
+ },
+ );
+ }
+
+ Widget _buildAboutUsCard(BuildContext context, EnteColorScheme colorScheme) {
+ return MenuItemWidgetNew(
+ title: AppLocalizations.of(context).about,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedInformationCircle,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const AboutUsPage());
+ },
+ );
+ }
+
+ Widget _buildLogoutCard(BuildContext context, EnteColorScheme colorScheme) {
+ return MenuItemWidgetNew(
+ title: AppLocalizations.of(context).logout,
+ titleColor: colorScheme.warning700,
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedLogout05,
+ colorScheme,
+ isDestructive: true,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ _onLogoutTapped(context);
+ },
+ );
+ }
+
+ void _onLogoutTapped(BuildContext context) {
+ showChoiceActionSheet(
+ context,
+ title: AppLocalizations.of(context).areYouSureYouWantToLogout,
+ firstButtonLabel: AppLocalizations.of(context).yesLogout,
+ isCritical: true,
+ firstButtonOnTap: () async {
+ await UserService.instance.logout(context);
+ },
+ );
+ }
+
+ Widget _buildDebugCard(BuildContext context, EnteColorScheme colorScheme) {
+ return MenuItemWidgetNew(
+ title: "Debug",
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedBug02,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const DebugSettingsPage());
+ },
+ );
+ }
+
+ Widget _buildMLDebugCard(BuildContext context, EnteColorScheme colorScheme) {
+ return MenuItemWidgetNew(
+ title: "ML Debug",
+ leadingIconWidget: _buildIconWidget(
+ HugeIcons.strokeRoundedAiBrain01,
+ colorScheme,
+ ),
+ trailingIcon: Icons.chevron_right_outlined,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ await routeToPage(context, const MLDebugSettingsPage());
+ },
+ );
+ }
+
Future<void> _showVerifyIdentityDialog(BuildContext context) async {
await showDialog(
useRootNavigator: false,