Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Migrate backup settings UI

AmanRajSinghMouryafc5cb011a8e6
diff --git a/mobile/apps/photos/lib/ui/settings/backup/backup_folder_selection_page.dart b/mobile/apps/photos/lib/ui/settings/backup/backup_folder_selection_page.dart
index f2d591ab0f..488eb4fee9 100644
--- a/mobile/apps/photos/lib/ui/settings/backup/backup_folder_selection_page.dart
+++ b/mobile/apps/photos/lib/ui/settings/backup/backup_folder_selection_page.dart
@@ -1,5 +1,6 @@
import 'dart:math';
+import 'package:ente_components/ente_components.dart';
import 'package:ente_pure_utils/ente_pure_utils.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@@ -11,11 +12,7 @@ import 'package:photos/generated/l10n.dart';
import 'package:photos/models/device_collection.dart';
import 'package:photos/service_locator.dart';
import 'package:photos/services/sync/remote_sync_service.dart';
-import 'package:photos/theme/ente_theme.dart';
import 'package:photos/ui/common/loading_widget.dart';
-import 'package:photos/ui/components/buttons/button_widget.dart';
-import 'package:photos/ui/components/buttons/button_widget_v2.dart';
-import 'package:photos/ui/components/models/button_type.dart';
import 'package:photos/ui/settings/backup/backup_settings_screen.dart';
import 'package:photos/ui/viewer/file/thumbnail_widget.dart';
import 'package:photos/utils/dialog_util.dart';
@@ -54,19 +51,17 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
static const _gridCrossSpacing = 8.0;
static const _gridMainSpacing = 8.0;
static const _thumbnailRadius = 12.0;
- static const _titleFadeDistance = 72.0;
-
- double _titleFadeProgress = 0;
@override
void initState() {
- _treatAsOnboarding = widget.isOnboarding ||
+ _treatAsOnboarding =
+ widget.isOnboarding ||
backupPreferenceService.hasSkippedOnboardingPermission;
- FilesDB.instance
- .getDeviceCollections(includeCoverThumbnail: true)
- .then((files) async {
- _pathIDToItemCount =
- await FilesDB.instance.getDevicePathIDToImportedFileCount();
+ FilesDB.instance.getDeviceCollections(includeCoverThumbnail: true).then((
+ files,
+ ) async {
+ _pathIDToItemCount = await FilesDB.instance
+ .getDevicePathIDToImportedFileCount();
if (!mounted) {
return;
}
@@ -84,8 +79,9 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
if (_treatAsOnboarding) {
_selectedDevicePathIDs.addAll(_allDevicePathIDs);
}
- _selectedDevicePathIDs
- .removeWhere((folder) => !_allDevicePathIDs.contains(folder));
+ _selectedDevicePathIDs.removeWhere(
+ (folder) => !_allDevicePathIDs.contains(folder),
+ );
});
});
super.initState();
@@ -93,16 +89,10 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
return Scaffold(
- backgroundColor: colorScheme.backgroundColour,
- body: _treatAsOnboarding
- ? SafeArea(
- top: true,
- bottom: false,
- child: _buildScrollableBody(),
- )
- : _buildScrollableBody(),
+ backgroundColor: colors.backgroundBase,
+ body: _buildScrollableBody(),
bottomNavigationBar: _buildBottomNavigationBar(),
);
}
@@ -133,8 +123,9 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
// toggle to avoid recursive navigation back to backup settings.
final onlyNewSinceEpoch = backupPreferenceService.onlyNewSinceEpoch;
if (onlyNewSinceEpoch != null && !widget.fromOnlyNewPhotosToggle) {
- final shouldContinue =
- await _showOnlyNewBackupWarning(onlyNewSinceEpoch);
+ final shouldContinue = await _showOnlyNewBackupWarning(
+ onlyNewSinceEpoch,
+ );
if (!shouldContinue) return;
}
@@ -155,32 +146,50 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
final locale = Localizations.localeOf(context).languageCode;
final formattedDate = DateFormat.yMMMd(locale).format(date);
- final result = await showChoiceDialog(
- context,
- title: l10n.warning,
- body: l10n.backupOnlyNewPhotosWarningBody(formattedDate: formattedDate),
- firstButtonLabel: l10n.updateSettings,
- firstButtonOnTap: () async {
- await routeToPage(
- context,
- const BackupSettingsScreen(),
- );
- },
- firstButtonType: ButtonType.neutral,
- secondButtonLabel: l10n.ok,
- secondButtonAction: ButtonAction.second,
+ final result = await showBottomSheetComponent<_OnlyNewWarningAction>(
+ context: context,
+ builder: (sheetContext) => BottomSheetComponent(
+ title: l10n.warning,
+ message: l10n.backupOnlyNewPhotosWarningBody(
+ formattedDate: formattedDate,
+ ),
+ illustration: Image.asset("assets/warning-green.png"),
+ actions: [
+ ButtonComponent(
+ label: l10n.updateSettings,
+ variant: ButtonComponentVariant.neutral,
+ shouldSurfaceExecutionStates: false,
+ onTap: () async {
+ Navigator.of(sheetContext).pop(
+ _OnlyNewWarningAction.updateSettings,
+ );
+ },
+ ),
+ ],
+ ),
);
- return result?.action == ButtonAction.second;
+ if (!context.mounted) {
+ return false;
+ }
+ if (result == _OnlyNewWarningAction.updateSettings) {
+ await routeToPage(
+ context,
+ const BackupSettingsScreen(),
+ );
+ return false;
+ }
+
+ return false;
}
Widget _buildBottomNavigationBar() {
final l10n = AppLocalizations.of(context);
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
final canSubmit = !(_treatAsOnboarding && _selectedDevicePathIDs.isEmpty);
return Container(
- color: colorScheme.backgroundColour,
+ color: colors.backgroundBase,
child: SafeArea(
top: false,
child: Padding(
@@ -188,10 +197,8 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.primary,
- labelText:
- widget.isFirstBackup ? l10n.startBackup : l10n.backup,
+ ButtonComponent(
+ label: widget.isFirstBackup ? l10n.startBackup : l10n.backup,
isDisabled: !canSubmit,
onTap: canSubmit
? () async {
@@ -201,10 +208,10 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
),
if (_treatAsOnboarding) ...[
const SizedBox(height: 16),
- ButtonWidgetV2(
+ ButtonComponent(
key: const ValueKey("skipBackupButton"),
- buttonType: ButtonTypeV2.link,
- labelText: l10n.skip,
+ label: l10n.skip,
+ variant: ButtonComponentVariant.link,
onTap: () async {
Navigator.of(context).pop(false);
},
@@ -219,133 +226,43 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
Widget _buildScrollableBody() {
final l10n = AppLocalizations.of(context);
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
- return NotificationListener<ScrollNotification>(
- onNotification: _handleScrollNotification,
- child: CustomScrollView(
- primary: true,
- slivers: [
- if (_treatAsOnboarding) ...[
- const SliverToBoxAdapter(child: SizedBox(height: 12)),
- SliverToBoxAdapter(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Text(
- l10n.backupToEnte,
- style: textTheme.h3Bold,
- ),
- ),
- ),
- const SliverToBoxAdapter(child: SizedBox(height: 4)),
- SliverToBoxAdapter(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Text(
- l10n.selectAlbumsToBackUpToEnte,
- style: textTheme.smallMuted,
- ),
- ),
- ),
- const SliverToBoxAdapter(child: SizedBox(height: 20)),
- ] else ...[
- SliverAppBar(
- backgroundColor: colorScheme.backgroundColour,
- elevation: 0,
- scrolledUnderElevation: 0,
- pinned: true,
- automaticallyImplyLeading: false,
- centerTitle: false,
- leading: IconButton(
- icon: const Icon(Icons.arrow_back),
- onPressed: () {
- Navigator.of(context).maybePop();
- },
- ),
- titleSpacing: 0,
- title: Opacity(
- opacity: _titleFadeProgress,
- child: Text(
- l10n.backupToEnte,
- style: textTheme.h3Bold,
- ),
- ),
- ),
- SliverToBoxAdapter(
- child: Opacity(
- opacity: 1 - _titleFadeProgress,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Text(
- l10n.backupToEnte,
- style: textTheme.h3Bold,
- ),
- ),
- const SizedBox(height: 4),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Text(
- l10n.selectAlbumsToBackUpToEnte,
- style: textTheme.smallMuted,
- ),
- ),
- const SizedBox(height: 20),
- ],
- ),
- ),
- ),
- ],
- if (_deviceCollections != null)
- SliverToBoxAdapter(
- child: GestureDetector(
- behavior: HitTestBehavior.translucent,
- onTap: _toggleSelectAll,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Text(
- _selectedDevicePathIDs.length ==
- _allDevicePathIDs.length
- ? l10n.unselectAll
- : l10n.selectAll,
- style: textTheme.small.copyWith(
- decoration: TextDecoration.underline,
- ),
+ return AppBarComponent(
+ title: l10n.backupToEnte,
+ subtitle: l10n.selectAlbumsToBackUpToEnte,
+ showExpandedBackButton: !_treatAsOnboarding,
+ slivers: [
+ if (_deviceCollections != null)
+ SliverToBoxAdapter(
+ child: GestureDetector(
+ behavior: HitTestBehavior.translucent,
+ onTap: _toggleSelectAll,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Text(
+ _selectedDevicePathIDs.length == _allDevicePathIDs.length
+ ? l10n.unselectAll
+ : l10n.selectAll,
+ style: TextStyles.body.copyWith(
+ color: colors.textBase,
+ decoration: TextDecoration.underline,
),
),
- const SizedBox(height: 12),
- ],
- ),
+ ),
+ const SizedBox(height: 12),
+ ],
),
),
- _buildFoldersSliver(),
- ],
- ),
+ ),
+ _buildFoldersSliver(),
+ ],
);
}
- bool _handleScrollNotification(ScrollNotification notification) {
- if (_treatAsOnboarding ||
- notification.depth != 0 ||
- notification.metrics.axis != Axis.vertical) {
- return false;
- }
- final progress =
- (notification.metrics.pixels / _titleFadeDistance).clamp(0.0, 1.0);
- if ((progress - _titleFadeProgress).abs() > 0.01 && mounted) {
- setState(() {
- _titleFadeProgress = progress;
- });
- }
- return false;
- }
-
Widget _buildFoldersSliver() {
if (_deviceCollections == null) {
return const SliverFillRemaining(
@@ -360,7 +277,7 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
final totalCrossAxisSpacing = (crossAxisCount - 1) * _gridCrossSpacing;
final sideOfThumbnail =
(screenWidth - totalCrossAxisSpacing - _gridHorizontalPadding) /
- crossAxisCount;
+ crossAxisCount;
return SliverPadding(
padding: const EdgeInsets.symmetric(
@@ -390,8 +307,7 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
DeviceCollection deviceCollection,
double sideOfThumbnail,
) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
final isSelected = _selectedDevicePathIDs.contains(deviceCollection.id);
final importedCount = _pathIDToItemCount?[deviceCollection.id];
final formattedCount = NumberFormat().format(deviceCollection.count);
@@ -415,7 +331,7 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
ClipRRect(
borderRadius: BorderRadius.circular(_thumbnailRadius + 1),
child: Container(
- color: colorScheme.strokeFaint,
+ color: colors.strokeFaint,
width: sideOfThumbnail,
height: sideOfThumbnail,
),
@@ -439,7 +355,7 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
),
)
else
- ColoredBox(color: colorScheme.fillDark),
+ ColoredBox(color: colors.fillDark),
if (isSelected)
ColoredBox(
color: Colors.black.withValues(alpha: 0.4),
@@ -456,12 +372,12 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
child: Container(
padding: const EdgeInsets.all(0.75),
decoration: BoxDecoration(
- color: colorScheme.backgroundColour,
+ color: colors.backgroundBase,
shape: BoxShape.circle,
),
child: Icon(
Icons.check_circle_rounded,
- color: colorScheme.greenBase,
+ color: colors.green,
size: 22,
),
),
@@ -476,7 +392,7 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
deviceCollection.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
- style: textTheme.small,
+ style: TextStyles.body.copyWith(color: colors.textBase),
),
),
const SizedBox(height: 2),
@@ -486,7 +402,7 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
countText,
maxLines: 1,
overflow: TextOverflow.ellipsis,
- style: textTheme.miniMuted,
+ style: TextStyles.mini.copyWith(color: colors.textLight),
),
),
],
@@ -533,3 +449,7 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
});
}
}
+
+enum _OnlyNewWarningAction {
+ updateSettings,
+}
diff --git a/mobile/apps/photos/lib/ui/settings/backup/backup_item_card.dart b/mobile/apps/photos/lib/ui/settings/backup/backup_item_card.dart
index e53640ee2c..97662817ab 100644
--- a/mobile/apps/photos/lib/ui/settings/backup/backup_item_card.dart
+++ b/mobile/apps/photos/lib/ui/settings/backup/backup_item_card.dart
@@ -1,5 +1,6 @@
import "dart:async";
+import "package:ente_components/ente_components.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import 'package:flutter/material.dart';
import "package:logging/logging.dart";
@@ -7,9 +8,6 @@ import "package:photos/generated/l10n.dart";
import "package:photos/models/backup/backup_item.dart";
import "package:photos/models/backup/backup_item_status.dart";
import 'package:photos/theme/ente_theme.dart';
-import "package:photos/ui/components/buttons/button_widget.dart";
-import "package:photos/ui/components/dialog_widget.dart";
-import "package:photos/ui/components/models/button_type.dart";
import "package:photos/ui/viewer/file/detail_page.dart";
import "package:photos/ui/viewer/file/thumbnail_widget.dart";
import "package:photos/utils/email_util.dart";
@@ -143,40 +141,42 @@ class _BackupItemCardState extends State<BackupItemCard> {
color: getEnteColorScheme(context).fillBase,
),
onPressed: () {
- showDialogWidget(
+ showBottomSheetComponent<void>(
context: context,
- body: AppLocalizations.of(context).sorryBackupFailedDesc,
- title: AppLocalizations.of(context).backupFailed,
- icon: Icons.error_outline_outlined,
isDismissible: true,
- buttons: [
- ButtonWidget(
- buttonType: ButtonType.primary,
- labelText:
- AppLocalizations.of(context).contactSupport,
- buttonAction: ButtonAction.second,
- onTap: () async {
- _logger.warning(
- "Backup failed for ${widget.item.file.displayName}",
- widget.item.error,
- );
- await sendLogs(
- context,
- AppLocalizations.of(context).contactSupport,
- postShare: () {},
- );
- },
- ),
- ButtonWidget(
- buttonType: ButtonType.secondary,
- labelText: AppLocalizations.of(context).ok,
- buttonAction: ButtonAction.first,
- onTap: () async {
- Navigator.of(context).pop();
- },
- ),
- ],
+ builder: (_) => BottomSheetComponent(
+ title: AppLocalizations.of(context).backupFailed,
+ message:
+ AppLocalizations.of(context).sorryBackupFailedDesc,
+ illustration: Image.asset("assets/warning-grey.png"),
+ actions: [
+ ButtonComponent(
+ label: AppLocalizations.of(context).contactSupport,
+ onTap: () async {
+ _logger.warning(
+ "Backup failed for ${widget.item.file.displayName}",
+ widget.item.error,
+ );
+ await sendLogs(
+ context,
+ AppLocalizations.of(context).contactSupport,
+ postShare: () {},
+ );
+ if (context.mounted) {
+ Navigator.of(context).pop();
+ }
+ },
+ ),
+ ButtonComponent(
+ label: AppLocalizations.of(context).ok,
+ variant: ButtonComponentVariant.secondary,
+ onTap: () async {
+ Navigator.of(context).pop();
+ },
+ ),
+ ],
+ ),
);
},
),
diff --git a/mobile/apps/photos/lib/ui/settings/backup/backup_section_widget.dart b/mobile/apps/photos/lib/ui/settings/backup/backup_section_widget.dart
deleted file mode 100644
index 1c1dc7cd32..0000000000
--- a/mobile/apps/photos/lib/ui/settings/backup/backup_section_widget.dart
+++ /dev/null
@@ -1,102 +0,0 @@
-import 'package:ente_pure_utils/ente_pure_utils.dart';
-import 'package:flutter/material.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/captioned_text_widget.dart";
-import 'package:photos/ui/components/expandable_menu_item_widget.dart';
-import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
-import "package:photos/ui/settings/backup/backup_settings_screen.dart";
-import "package:photos/ui/settings/backup/backup_status_screen.dart";
-import "package:photos/ui/settings/backup/free_space_options.dart";
-import 'package:photos/ui/settings/common_settings.dart';
-
-class BackupSectionWidget extends StatefulWidget {
- const BackupSectionWidget({super.key});
-
- @override
- BackupSectionWidgetState createState() => BackupSectionWidgetState();
-}
-
-class BackupSectionWidgetState extends State<BackupSectionWidget> {
- @override
- Widget build(BuildContext context) {
- return ExpandableMenuItemWidget(
- title: AppLocalizations.of(context).backup,
- selectionOptionsWidget: _getSectionOptions(context),
- leadingIcon: Icons.backup_outlined,
- );
- }
-
- Widget _getSectionOptions(BuildContext context) {
- final List<Widget> sectionOptions = [
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).backedUpFolders,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- await handleFolderSelectionBackupFlow(context);
- },
- ),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).backupStatus,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- await routeToPage(
- context,
- const BackupStatusScreen(),
- );
- },
- ),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).backupSettings,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- await routeToPage(
- context,
- const BackupSettingsScreen(),
- );
- },
- ),
- sectionOptionSpacing,
- ];
-
- sectionOptions.addAll(
- [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).freeUpSpace,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- showOnlyLoadingState: true,
- onTap: () async {
- await routeToPage(
- context,
- const FreeUpSpaceOptionsScreen(),
- );
- },
- ),
- sectionOptionSpacing,
- ],
- );
- return Column(
- children: sectionOptions,
- );
- }
-}
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
index 0c26068e26..4a8412be54 100644
--- a/mobile/apps/photos/lib/ui/settings/backup/backup_settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings/backup/backup_settings_page.dart
@@ -2,112 +2,49 @@ 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";
+import "package:photos/ui/settings/components/settings_item.dart";
+import "package:photos/ui/settings/components/settings_page_scaffold.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 l10n = AppLocalizations.of(context);
- 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(),
- );
- },
- ),
- ],
- ),
- ),
- ),
- ],
- ),
+ return SettingsPageScaffold(
+ title: l10n.backup,
+ children: [
+ SettingsItem(
+ title: l10n.backedUpFolders,
+ icon: HugeIcons.strokeRoundedFolder01,
+ showOnlyLoadingState: true,
+ onTap: () async {
+ await handleFolderSelectionBackupFlow(context);
+ },
),
- ),
- );
- }
-
- Widget _buildIconWidget(BuildContext context, List<List<dynamic>> icon) {
- final colorScheme = getEnteColorScheme(context);
- return HugeIcon(
- icon: icon,
- color: colorScheme.menuItemIconStroke,
- size: 20,
+ const SizedBox(height: 8),
+ SettingsItem(
+ title: l10n.backupStatus,
+ icon: HugeIcons.strokeRoundedCloudSavingDone01,
+ showOnlyLoadingState: true,
+ onTap: () async {
+ await routeToPage(context, const BackupStatusScreen());
+ },
+ ),
+ const SizedBox(height: 8),
+ SettingsItem(
+ title: l10n.backupSettings,
+ icon: HugeIcons.strokeRoundedSettings01,
+ showOnlyLoadingState: true,
+ onTap: () async {
+ await routeToPage(context, const BackupSettingsScreen());
+ },
+ ),
+ ],
);
}
}
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 a3354b9aa0..98c1dd44fd 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,5 +1,6 @@
import "dart:io";
+import "package:ente_components/ente_components.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:flutter/material.dart";
import "package:photo_manager/photo_manager.dart";
@@ -10,13 +11,8 @@ 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/ui/settings/components/settings_page_scaffold.dart";
import "package:photos/utils/dialog_util.dart";
class BackupSettingsScreen extends StatelessWidget {
@@ -29,150 +25,113 @@ 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 l10n = AppLocalizations.of(context);
- 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).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 (endpointConfig.isProduction) ...[
- const SizedBox(height: 8),
- MenuItemWidgetNew(
- title: AppLocalizations.of(context).fasterUploads,
- trailingWidget: ToggleSwitchWidget(
- value: () =>
- localSettings.cfUploadProxyEnabled ??
- flagService.cloudflareUploadWorker,
- onChanged: () async {
- final newValue =
- !(localSettings.cfUploadProxyEnabled ??
- flagService.cloudflareUploadWorker);
- await localSettings
- .setCFUploadProxyEnabled(newValue);
- },
- ),
- ),
- ],
- if (Platform.isIOS) ...[
- const SizedBox(height: 24),
- 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),
- ),
- ),
- ],
- ],
- ),
- ),
- ),
- ],
+ return SettingsPageScaffold(
+ title: l10n.backupSettings,
+ children: [
+ _toggleItem(
+ context,
+ title: l10n.backupOverMobileData,
+ value: () => Configuration.instance.shouldBackupOverMobileData(),
+ onChanged: () async {
+ await Configuration.instance.setBackupOverMobileData(
+ !Configuration.instance.shouldBackupOverMobileData(),
+ );
+ },
+ ),
+ const SizedBox(height: 8),
+ _toggleItem(
+ context,
+ title: l10n.backupVideos,
+ value: () => Configuration.instance.shouldBackupVideos(),
+ onChanged: () => Configuration.instance.setShouldBackupVideos(
+ !Configuration.instance.shouldBackupVideos(),
),
),
- ),
+ if (flagService.enableOnlyBackupFuturePhotos) ...[
+ const SizedBox(height: 8),
+ _BackupOnlyNewPhotosToggle(
+ debouncer: _onlyNewToggleDebouncer,
+ ),
+ ],
+ if (flagService.enableMobMultiPart) ...[
+ const SizedBox(height: 8),
+ _toggleItem(
+ context,
+ title: l10n.resumableUploads,
+ value: () => localSettings.userEnabledMultiplePart,
+ onChanged: () async {
+ await localSettings.setUserEnabledMultiplePart(
+ !localSettings.userEnabledMultiplePart,
+ );
+ },
+ ),
+ ],
+ if (endpointConfig.isProduction) ...[
+ const SizedBox(height: 8),
+ _toggleItem(
+ context,
+ title: l10n.fasterUploads,
+ value: () =>
+ localSettings.cfUploadProxyEnabled ??
+ flagService.cloudflareUploadWorker,
+ onChanged: () async {
+ final newValue =
+ !(localSettings.cfUploadProxyEnabled ??
+ flagService.cloudflareUploadWorker);
+ await localSettings.setCFUploadProxyEnabled(newValue);
+ },
+ ),
+ ],
+ if (Platform.isIOS) ...[
+ const SizedBox(height: 24),
+ _toggleItem(
+ context,
+ title: l10n.disableAutoLock,
+ value: () =>
+ EnteWakeLockService.instance.shouldKeepAppAwakeAcrossSessions,
+ onChanged: () async {
+ EnteWakeLockService.instance.updateWakeLock(
+ enable: !EnteWakeLockService
+ .instance
+ .shouldKeepAppAwakeAcrossSessions,
+ wakeLockFor: WakeLockFor.fasterBackupsOniOSByKeepingScreenAwake,
+ );
+ },
+ ),
+ Padding(
+ padding: const EdgeInsets.only(
+ left: Spacing.lg,
+ right: Spacing.lg,
+ top: Spacing.sm,
+ bottom: Spacing.lg,
+ ),
+ child: Text(
+ l10n.deviceLockExplanation,
+ style: TextStyles.mini.copyWith(
+ color: context.componentColors.textLight,
+ ),
+ ),
+ ),
+ ],
+ ],
);
}
- bool _shouldShowOnlyNewToggle() {
- return flagService.enableOnlyBackupFuturePhotos;
+ MenuComponent _toggleItem(
+ BuildContext context, {
+ required String title,
+ required bool Function() value,
+ required Future<void> Function() onChanged,
+ }) {
+ return MenuComponent(
+ title: title,
+ trailing: ToggleSwitchComponent.async(
+ value: value,
+ onChanged: onChanged,
+ ),
+ );
}
}
@@ -183,9 +142,9 @@ class _BackupOnlyNewPhotosToggle extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return MenuItemWidgetNew(
+ return MenuComponent(
title: context.l10n.backupOnlyNewPhotos,
- trailingWidget: ToggleSwitchWidget(
+ trailing: ToggleSwitchComponent.async(
value: () => backupPreferenceService.isOnlyNewBackupEnabled,
onChanged: () async {
final hasPermission = await _ensurePhotoPermissions(context);
@@ -246,8 +205,8 @@ class _BackupOnlyNewPhotosToggle extends StatelessWidget {
}) async {
final needsFolderPrompt =
!backupPreferenceService.hasManualFolderSelection &&
- (backupPreferenceService.hasSelectedAllFoldersForBackup ||
- !backupPreferenceService.hasSelectedAnyBackupFolder);
+ (backupPreferenceService.hasSelectedAllFoldersForBackup ||
+ !backupPreferenceService.hasSelectedAnyBackupFolder);
if (!needsFolderPrompt) {
return true;
}
@@ -258,50 +217,19 @@ class _BackupOnlyNewPhotosToggle extends StatelessWidget {
// Hide "Continue anyway" if user skipped permission and first import not done
final allowContinueAnyway =
!backupPreferenceService.hasSkippedOnboardingPermission ||
- LocalSyncService.instance.hasCompletedFirstImport();
+ LocalSyncService.instance.hasCompletedFirstImport();
- final result = await showActionSheet(
+ final result = await _showOnlyNewBackupFolderPrompt(
context: context,
- buttons: [
- ButtonWidget(
- labelText: context.l10n.selectFolders,
- buttonType: ButtonType.primary,
- buttonAction: ButtonAction.first,
- shouldSurfaceExecutionStates: false,
- shouldStickToDarkTheme: true,
- isInAlert: true,
- ),
- if (allowContinueAnyway)
- ButtonWidget(
- labelText: context.l10n.continueLabel,
- buttonType: ButtonType.neutral,
- buttonAction: ButtonAction.second,
- shouldSurfaceExecutionStates: false,
- shouldStickToDarkTheme: true,
- isInAlert: true,
- ),
- ButtonWidget(
- labelText: context.l10n.cancel,
- buttonType: ButtonType.secondary,
- buttonAction: ButtonAction.cancel,
- shouldSurfaceExecutionStates: false,
- shouldStickToDarkTheme: true,
- isInAlert: true,
- ),
- ],
- title: context.l10n.backupOnlyNewPhotos,
- body: hasAllFoldersSelected
- ? context.l10n.backupOnlyNewPhotosAllFoldersSelected
- : allowContinueAnyway
- ? context.l10n.backupOnlyNewPhotosNoFoldersSelectedContinue
- : context.l10n.backupOnlyNewPhotosNoFoldersSelectedRequire,
+ hasAllFoldersSelected: hasAllFoldersSelected,
+ allowContinueAnyway: allowContinueAnyway,
);
- if (result?.action == null || result!.action == ButtonAction.cancel) {
+ if (result == null) {
return false;
}
- if (result.action == ButtonAction.first) {
+ if (result == _FolderPromptAction.selectFolders) {
final bool? selected = await handleFolderSelectionBackupFlow(
context,
fromOnlyNewPhotosToggle: true,
@@ -309,10 +237,62 @@ class _BackupOnlyNewPhotosToggle extends StatelessWidget {
if (selected != true) {
return false;
}
- } else if (result.action == ButtonAction.second) {
+ } else if (result == _FolderPromptAction.continueAnyway) {
await backupPreferenceService.setHasManualFolderSelection(true);
}
return true;
}
}
+
+Future<_FolderPromptAction?> _showOnlyNewBackupFolderPrompt({
+ required BuildContext context,
+ required bool hasAllFoldersSelected,
+ required bool allowContinueAnyway,
+}) async {
+ final l10n = context.l10n;
+ final message = hasAllFoldersSelected
+ ? l10n.backupOnlyNewPhotosAllFoldersSelected
+ : allowContinueAnyway
+ ? l10n.backupOnlyNewPhotosNoFoldersSelectedContinue
+ : l10n.backupOnlyNewPhotosNoFoldersSelectedRequire;
+ return showBottomSheetComponent<_FolderPromptAction>(
+ context: context,
+ useRootNavigator: Platform.isIOS,
+ builder: (sheetContext) => BottomSheetComponent(
+ title: l10n.backupOnlyNewPhotos,
+ closeTooltip: l10n.close,
+ content: Text(
+ message,
+ style: TextStyles.body.copyWith(
+ color: sheetContext.componentColors.textLight,
+ ),
+ ),
+ actions: [
+ ButtonComponent(
+ label: l10n.selectFolders,
+ shouldSurfaceExecutionStates: false,
+ onTap: () async {
+ Navigator.of(sheetContext).pop(_FolderPromptAction.selectFolders);
+ },
+ ),
+ if (allowContinueAnyway)
+ ButtonComponent(
+ label: l10n.continueLabel,
+ variant: ButtonComponentVariant.neutral,
+ shouldSurfaceExecutionStates: false,
+ onTap: () async {
+ Navigator.of(
+ sheetContext,
+ ).pop(_FolderPromptAction.continueAnyway);
+ },
+ ),
+ ],
+ ),
+ );
+}
+
+enum _FolderPromptAction {
+ selectFolders,
+ continueAnyway,
+}
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 e9a963edd9..b18d062995 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
@@ -1,9 +1,11 @@
import "dart:async";
import "dart:io";
+import "package:ente_components/ente_components.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:flutter/foundation.dart" show kDebugMode;
-import 'package:flutter/material.dart';
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/models/duplicate_files.dart";
import "package:photos/models/freeable_space_info.dart";
@@ -11,10 +13,6 @@ import "package:photos/service_locator.dart";
import "package:photos/services/collections_service.dart";
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/dialog_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/notification/toast.dart";
import "package:photos/ui/tools/debug/app_storage_viewer.dart";
@@ -41,15 +39,10 @@ class _FreeUpSpaceOptionsScreenState extends State<FreeUpSpaceOptionsScreen> {
@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 colors = context.componentColors;
return Scaffold(
- backgroundColor: pageBackgroundColor,
+ backgroundColor: colors.backgroundBase,
body: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
@@ -61,14 +54,14 @@ class _FreeUpSpaceOptionsScreenState extends State<FreeUpSpaceOptionsScreen> {
onTap: () => Navigator.of(context).pop(),
child: Icon(
Icons.arrow_back,
- color: colorScheme.strokeBase,
+ color: colors.iconColor,
size: 24,
),
),
const SizedBox(height: 24),
Text(
AppLocalizations.of(context).freeUpSpace,
- style: textTheme.h3Bold,
+ style: TextStyles.h1Bold.copyWith(color: colors.textBase),
),
const SizedBox(height: 24),
Expanded(
@@ -76,55 +69,29 @@ class _FreeUpSpaceOptionsScreenState extends State<FreeUpSpaceOptionsScreen> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- MenuItemWidgetNew(
+ _buildFreeSpaceOption(
+ context,
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 +
- (Platform.isIOS
- ? " ${AppLocalizations.of(context).freeUpDeviceSpaceDescICloud}"
- : ""),
- style: textTheme.mini
- .copyWith(color: colorScheme.textMuted),
- ),
+ _description(
+ AppLocalizations.of(context).freeUpDeviceSpaceDesc +
+ (Platform.isIOS
+ ? " ${AppLocalizations.of(context).freeUpDeviceSpaceDescICloud}"
+ : ""),
),
- MenuItemWidgetNew(
+ _buildFreeSpaceOption(
+ context,
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),
- ),
+ _description(
+ AppLocalizations.of(context).removeDuplicatesDesc,
),
if (flagService.enableVectorDb) ...[
- MenuItemWidgetNew(
+ _buildFreeSpaceOption(
+ context,
title: AppLocalizations.of(context).similarImages,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- showOnlyLoadingState: true,
onTap: () async {
await routeToPage(
context,
@@ -134,26 +101,13 @@ class _FreeUpSpaceOptionsScreenState extends State<FreeUpSpaceOptionsScreen> {
);
},
),
- 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),
- ),
+ _description(
+ AppLocalizations.of(context).useMLToFindSimilarImages,
),
],
- MenuItemWidgetNew(
+ _buildFreeSpaceOption(
+ context,
title: AppLocalizations.of(context).viewLargeFiles,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- showOnlyLoadingState: true,
onTap: () async {
await routeToPage(
context,
@@ -161,43 +115,20 @@ class _FreeUpSpaceOptionsScreenState extends State<FreeUpSpaceOptionsScreen> {
);
},
),
- 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),
- ),
+ _description(
+ AppLocalizations.of(context).viewLargeFilesDesc,
),
- MenuItemWidgetNew(
+ _buildFreeSpaceOption(
+ context,
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),
- ),
+ _description(
+ AppLocalizations.of(context).deleteSuggestionsDesc,
),
- MenuItemWidgetNew(
+ _buildFreeSpaceOption(
+ context,
title: AppLocalizations.of(context).manageDeviceStorage,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
onTap: () async {
await routeToPage(
context,
@@ -205,18 +136,8 @@ class _FreeUpSpaceOptionsScreenState extends State<FreeUpSpaceOptionsScreen> {
);
},
),
- 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),
- ),
+ _description(
+ AppLocalizations.of(context).manageDeviceStorageDesc,
),
],
),
@@ -229,6 +150,42 @@ class _FreeUpSpaceOptionsScreenState extends State<FreeUpSpaceOptionsScreen> {
);
}
+ Widget _description(String text) {
+ return Padding(
+ padding: const EdgeInsets.only(
+ left: Spacing.lg,
+ right: Spacing.lg,
+ top: Spacing.sm,
+ bottom: Spacing.lg,
+ ),
+ child: Text(
+ text,
+ style: TextStyles.mini.copyWith(
+ color: context.componentColors.textLight,
+ ),
+ ),
+ );
+ }
+
+ MenuComponent _buildFreeSpaceOption(
+ BuildContext context, {
+ required String title,
+ required Future<void> Function() onTap,
+ }) {
+ final colors = context.componentColors;
+ return MenuComponent(
+ title: title,
+ trailing: HugeIcon(
+ icon: HugeIcons.strokeRoundedArrowRight02,
+ color: colors.textLight,
+ size: 18,
+ strokeWidth: 1.6,
+ ),
+ showOnlyLoadingState: true,
+ onTap: onTap,
+ );
+ }
+
Future<void> _onFreeUpDeviceSpaceTapped() async {
FreeableSpaceInfo status;
try {
@@ -346,28 +303,35 @@ class _FreeUpSpaceOptionsScreenState extends State<FreeUpSpaceOptionsScreen> {
},
);
} else {
- showDialogWidget(
+ showBottomSheetComponent<void>(
context: context,
- title: AppLocalizations.of(context).success,
- body: AppLocalizations.of(context)
- .youHaveSuccessfullyFreedUp(storageSaved: formatBytes(status.size)),
- icon: Icons.download_done_rounded,
isDismissible: true,
- buttons: [
- ButtonWidget(
- buttonType: ButtonType.neutral,
- labelText: AppLocalizations.of(context).ok,
- isInAlert: true,
- onTap: () async {
- if (Platform.isIOS) {
- showToast(
- context,
- AppLocalizations.of(context).remindToEmptyDeviceTrash,
- );
- }
- },
+ builder: (_) => BottomSheetComponent(
+ title: AppLocalizations.of(context).success,
+ message: AppLocalizations.of(context).youHaveSuccessfullyFreedUp(
+ storageSaved: formatBytes(status.size),
+ ),
+ illustration: Icon(
+ Icons.download_done_rounded,
+ size: 64,
+ color: context.componentColors.primary,
),
- ],
+ actions: [
+ ButtonComponent(
+ label: AppLocalizations.of(context).ok,
+ variant: ButtonComponentVariant.neutral,
+ onTap: () async {
+ if (Platform.isIOS) {
+ showToast(
+ context,
+ AppLocalizations.of(context).remindToEmptyDeviceTrash,
+ );
+ }
+ Navigator.of(context).pop();
+ },
+ ),
+ ],
+ ),
);
}
}
diff --git a/mobile/packages/ente_components/lib/components/app_bar_component.dart b/mobile/packages/ente_components/lib/components/app_bar_component.dart
index 11f323ff6a..e7f9f44521 100644
--- a/mobile/packages/ente_components/lib/components/app_bar_component.dart
+++ b/mobile/packages/ente_components/lib/components/app_bar_component.dart
@@ -24,7 +24,7 @@ class AppBarComponent extends StatefulWidget {
this.backButton,
this.onBack,
this.actions = const [],
- this.expandedHeight = 116,
+ this.expandedHeight,
this.collapsedHeight = 56,
this.horizontalPadding = Spacing.lg,
this.backgroundColor,
@@ -39,7 +39,7 @@ class AppBarComponent extends StatefulWidget {
final Widget? backButton;
final VoidCallback? onBack;
final List<Widget> actions;
- final double expandedHeight;
+ final double? expandedHeight;
final double collapsedHeight;
final double horizontalPadding;
final Color? backgroundColor;
@@ -249,7 +249,7 @@ class SliverAppBarComponent extends StatelessWidget {
this.backButton,
this.onBack,
this.actions = const [],
- this.expandedHeight = 116,
+ this.expandedHeight,
this.collapsedHeight = 56,
this.horizontalPadding = Spacing.lg,
this.backgroundColor,
@@ -262,7 +262,7 @@ class SliverAppBarComponent extends StatelessWidget {
final Widget? backButton;
final VoidCallback? onBack;
final List<Widget> actions;
- final double expandedHeight;
+ final double? expandedHeight;
final double collapsedHeight;
final double horizontalPadding;
final Color? backgroundColor;
@@ -609,7 +609,10 @@ class _HeaderAppBarBackButton extends StatelessWidget {
const _headerControlSize = 38.0;
const _headerControlGap = Spacing.sm;
const _defaultBackIconSize = IconSizes.medium;
+const _titleOnlyExpandedHeight = 92.0;
+const _subtitleExpandedHeight = 110.0;
const _expandedContentTop = 48.0;
+const _expandedContentBottomGap = Spacing.lg;
const _subtitleGap = 2.0;
const _headerSnapTolerance = 1.0;
const _headerSnapDuration = Duration(milliseconds: 160);
@@ -635,7 +638,7 @@ class _HeaderAppBarMetrics {
_HeaderAppBarMetrics _resolveHeaderAppBarMetrics(
BuildContext context, {
required String? subtitle,
- required double expandedHeight,
+ required double? expandedHeight,
required double collapsedHeight,
}) {
final textScaler = MediaQuery.textScalerOf(context);
@@ -645,6 +648,9 @@ _HeaderAppBarMetrics _resolveHeaderAppBarMetrics(
);
final collapsedTitleLineHeight = _scaledLineHeight(textScaler, TextStyles.h2);
final subtitleLineHeight = _scaledLineHeight(textScaler, TextStyles.mini);
+ final defaultExpandedHeight = subtitle == null
+ ? _titleOnlyExpandedHeight
+ : _subtitleExpandedHeight;
final effectiveCollapsedHeight = _maxDouble(
collapsedHeight,
_maxDouble(_headerControlSize, collapsedTitleLineHeight),
@@ -653,9 +659,10 @@ _HeaderAppBarMetrics _resolveHeaderAppBarMetrics(
expandedTitleLineHeight +
(subtitle == null ? 0 : _subtitleGap + subtitleLineHeight);
final effectiveExpandedHeight = _maxDouble(
- expandedHeight,
+ expandedHeight ?? defaultExpandedHeight,
_expandedContentTop +
- _maxDouble(expandedTextBlockHeight, _headerControlSize),
+ _maxDouble(expandedTextBlockHeight, _headerControlSize) +
+ _expandedContentBottomGap,
);
return _HeaderAppBarMetrics(
diff --git a/mobile/packages/ente_components/test/components/app_surface_widgets_test.dart b/mobile/packages/ente_components/test/components/app_surface_widgets_test.dart
index edde8aea85..f8dfb3b150 100644
--- a/mobile/packages/ente_components/test/components/app_surface_widgets_test.dart
+++ b/mobile/packages/ente_components/test/components/app_surface_widgets_test.dart
@@ -577,13 +577,13 @@ void main() {
height: 600,
);
- scrollController.jumpTo(54);
+ scrollController.jumpTo(48);
await tester.pump();
final title = tester.widget<Text>(find.text('Menu items'));
expect(title.style?.fontSize, greaterThan(18));
- scrollController.jumpTo(60);
+ scrollController.jumpTo(54);
await tester.pump();
final collapsedTitle = tester.widget<Text>(find.text('Menu items'));
@@ -618,14 +618,14 @@ void main() {
await tester.drag(find.byType(CustomScrollView), const Offset(0, -40));
await tester.pumpAndSettle();
- expect(scrollController.offset, closeTo(60, 1));
+ expect(scrollController.offset, closeTo(54, 1));
final collapsedTitle = tester.widget<Text>(find.text('Appearance'));
expect(collapsedTitle.style?.fontSize, closeTo(18, 0.01));
expect(tester.getTopLeft(find.text('System theme')).dy, closeTo(56, 1));
await tester.drag(find.byType(CustomScrollView), const Offset(0, 32));
await tester.pumpAndSettle();
- expect(scrollController.offset, closeTo(60, 1));
+ expect(scrollController.offset, closeTo(54, 1));
await tester.drag(find.byType(CustomScrollView), const Offset(0, 120));
await tester.pumpAndSettle();