π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move free up space options into separate page
Neeraj Gupta943dceb993fd
diff --git a/mobile/lib/ui/settings/backup/backup_section_widget.dart b/mobile/lib/ui/settings/backup/backup_section_widget.dartindex b14cca2b8b..5ff3937993 100644--- a/mobile/lib/ui/settings/backup/backup_section_widget.dart+++ b/mobile/lib/ui/settings/backup/backup_section_widget.dart@@ -1,30 +1,14 @@-import "dart:async";-import 'dart:io';-import 'package:flutter/material.dart';import "package:photos/generated/l10n.dart";-import 'package:photos/models/backup_status.dart';-import 'package:photos/models/duplicate_files.dart';-import 'package:photos/services/deduplication_service.dart';-import 'package:photos/services/sync_service.dart';-import 'package:photos/services/update_service.dart';import 'package:photos/theme/ente_theme.dart';-import "package:photos/ui/components/buttons/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/expandable_menu_item_widget.dart';import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';-import "package:photos/ui/components/models/button_type.dart";import 'package:photos/ui/settings/backup/backup_folder_selection_page.dart';import 'package:photos/ui/settings/backup/backup_settings_screen.dart';+import "package:photos/ui/settings/backup/free_space_options.dart";import 'package:photos/ui/settings/common_settings.dart';-import 'package:photos/ui/tools/deduplicate_page.dart';-import "package:photos/ui/tools/free_space_page.dart";-import 'package:photos/utils/data_util.dart';-import 'package:photos/utils/dialog_util.dart';-import "package:photos/utils/local_settings.dart";import 'package:photos/utils/navigation_util.dart';-import 'package:photos/utils/toast_util.dart';class BackupSectionWidget extends StatefulWidget {const BackupSectionWidget({Key? key}) : super(key: key);@@ -84,71 +68,17 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {[MenuItemWidget(captionedTextWidget: CaptionedTextWidget(- title: S.of(context).freeUpDeviceSpace,+ title: S.of(context).freeUpSpace,),pressedColor: getEnteColorScheme(context).fillFaint,trailingIcon: Icons.chevron_right_outlined,trailingIconIsMuted: true,showOnlyLoadingState: true,onTap: () async {- BackupStatus status;- try {- status = await SyncService.instance.getBackupStatus();- } catch (e) {- await showGenericErrorDialog(context: context, error: e);- return;- }-- if (status.localIDs.isEmpty) {- // ignore: unawaited_futures- showErrorDialog(- context,- S.of(context).allClear,- S.of(context).noDeviceThatCanBeDeleted,- );- } else {- final bool? result =- await routeToPage(context, FreeSpacePage(status));- if (result == true) {- _showSpaceFreedDialog(status);- }- }- },- ),- sectionOptionSpacing,- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: S.of(context).removeDuplicates,- ),- pressedColor: getEnteColorScheme(context).fillFaint,- trailingIcon: Icons.chevron_right_outlined,- trailingIconIsMuted: true,- showOnlyLoadingState: true,- onTap: () 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,- S.of(context).noDuplicates,- S.of(context).youveNoDuplicateFilesThatCanBeCleared,- ),- );- } else {- final DeduplicationResult? result =- await routeToPage(context, DeduplicatePage(duplicates));- if (result != null) {- _showDuplicateFilesDeletedDialog(result);- }- }+ await routeToPage(+ context,+ const FreeUpSpaceOptionsScreen(),+ );},),sectionOptionSpacing,@@ -158,73 +88,4 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {children: sectionOptions,);}-- void _showSpaceFreedDialog(BackupStatus status) {- if (LocalSettings.instance.shouldPromptToRateUs()) {- LocalSettings.instance.setRateUsShownCount(- LocalSettings.instance.getRateUsShownCount() + 1,- );- showChoiceDialog(- context,- title: S.of(context).success,- body:- S.of(context).youHaveSuccessfullyFreedUp(formatBytes(status.size)),- firstButtonLabel: S.of(context).rateUs,- firstButtonOnTap: () async {- await UpdateService.instance.launchReviewUrl();- },- firstButtonType: ButtonType.primary,- secondButtonLabel: S.of(context).ok,- secondButtonOnTap: () async {- if (Platform.isIOS) {- showToast(context, S.of(context).remindToEmptyDeviceTrash);- }- },- );- } else {- showDialogWidget(- context: context,- title: S.of(context).success,- body:- S.of(context).youHaveSuccessfullyFreedUp(formatBytes(status.size)),- icon: Icons.download_done_rounded,- isDismissible: true,- buttons: [- ButtonWidget(- buttonType: ButtonType.neutral,- labelText: S.of(context).ok,- isInAlert: true,- onTap: () async {- if (Platform.isIOS) {- showToast(context, S.of(context).remindToEmptyDeviceTrash);- }- },- ),- ],- );- }- }-- void _showDuplicateFilesDeletedDialog(DeduplicationResult result) {- showChoiceDialog(- context,- title: S.of(context).sparkleSuccess,- body: S.of(context).duplicateFileCountWithStorageSaved(- result.count,- formatBytes(result.size),- ),- firstButtonLabel: S.of(context).rateUs,- firstButtonOnTap: () async {- await UpdateService.instance.launchReviewUrl();- },- firstButtonType: ButtonType.primary,- secondButtonLabel: S.of(context).ok,- secondButtonOnTap: () async {- showShortToast(- context,- S.of(context).remindToEmptyEnteTrash,- );- },- );- }}diff --git a/mobile/lib/ui/settings/backup/free_space_options.dart b/mobile/lib/ui/settings/backup/free_space_options.dartnew file mode 100644index 0000000000..3053dbbf5c--- /dev/null+++ b/mobile/lib/ui/settings/backup/free_space_options.dart@@ -0,0 +1,261 @@+import "dart:async";+import "dart:io";++import 'package:flutter/material.dart';+import "package:photos/generated/l10n.dart";+import "package:photos/models/backup_status.dart";+import "package:photos/models/duplicate_files.dart";+import "package:photos/services/deduplication_service.dart";+import "package:photos/services/sync_service.dart";+import "package:photos/services/update_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/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/tools/deduplicate_page.dart";+import "package:photos/ui/tools/free_space_page.dart";+import "package:photos/utils/data_util.dart";+import "package:photos/utils/dialog_util.dart";+import 'package:photos/utils/local_settings.dart';+import 'package:photos/utils/navigation_util.dart';+import "package:photos/utils/toast_util.dart";++class FreeUpSpaceOptionsScreen extends StatefulWidget {+ const FreeUpSpaceOptionsScreen({super.key});++ @override+ State<FreeUpSpaceOptionsScreen> createState() =>+ _FreeUpSpaceOptionsScreenState();+}++class _FreeUpSpaceOptionsScreenState extends State<FreeUpSpaceOptionsScreen> {+ @override+ void initState() {+ super.initState();+ }++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ return Scaffold(+ body: CustomScrollView(+ primary: false,+ slivers: <Widget>[+ TitleBarWidget(+ flexibleSpaceTitle: TitleBarTitleWidget(+ title: S.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,+ children: [+ Column(+ children: [+ Column(+ children: [+ MenuItemWidget(+ captionedTextWidget: CaptionedTextWidget(+ title: S.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 SyncService.instance+ .getBackupStatus();+ } catch (e) {+ await showGenericErrorDialog(+ context: context,+ error: e,+ );+ return;+ }++ if (status.localIDs.isEmpty) {+ // ignore: unawaited_futures+ showErrorDialog(+ context,+ S.of(context).allClear,+ S.of(context).noDeviceThatCanBeDeleted,+ );+ } else {+ final bool? result = await routeToPage(+ context,+ FreeSpacePage(status),+ );+ if (result == true) {+ _showSpaceFreedDialog(status);+ }+ }+ },+ ),+ const SizedBox(+ height: 24,+ ),+ ],+ ),+ MenuItemWidget(+ captionedTextWidget: CaptionedTextWidget(+ title: S.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;+ }++ if (duplicates.isEmpty) {+ unawaited(+ showErrorDialog(+ context,+ S.of(context).noDuplicates,+ S+ .of(context)+ .youveNoDuplicateFilesThatCanBeCleared,+ ),+ );+ } else {+ final DeduplicationResult? result =+ await routeToPage(+ context,+ DeduplicatePage(duplicates),+ );+ if (result != null) {+ _showDuplicateFilesDeletedDialog(result);+ }+ }+ },+ ),+ const SizedBox(+ height: 24,+ ),+ ],+ ),+ ],+ ),+ ),+ );+ },+ childCount: 1,+ ),+ ),+ ],+ ),+ );+ }++ void _showSpaceFreedDialog(BackupStatus status) {+ if (LocalSettings.instance.shouldPromptToRateUs()) {+ LocalSettings.instance.setRateUsShownCount(+ LocalSettings.instance.getRateUsShownCount() + 1,+ );+ showChoiceDialog(+ context,+ title: S.of(context).success,+ body:+ S.of(context).youHaveSuccessfullyFreedUp(formatBytes(status.size)),+ firstButtonLabel: S.of(context).rateUs,+ firstButtonOnTap: () async {+ await UpdateService.instance.launchReviewUrl();+ },+ firstButtonType: ButtonType.primary,+ secondButtonLabel: S.of(context).ok,+ secondButtonOnTap: () async {+ if (Platform.isIOS) {+ showToast(context, S.of(context).remindToEmptyDeviceTrash);+ }+ },+ );+ } else {+ showDialogWidget(+ context: context,+ title: S.of(context).success,+ body:+ S.of(context).youHaveSuccessfullyFreedUp(formatBytes(status.size)),+ icon: Icons.download_done_rounded,+ isDismissible: true,+ buttons: [+ ButtonWidget(+ buttonType: ButtonType.neutral,+ labelText: S.of(context).ok,+ isInAlert: true,+ onTap: () async {+ if (Platform.isIOS) {+ showToast(context, S.of(context).remindToEmptyDeviceTrash);+ }+ },+ ),+ ],+ );+ }+ }++ void _showDuplicateFilesDeletedDialog(DeduplicationResult result) {+ showChoiceDialog(+ context,+ title: S.of(context).sparkleSuccess,+ body: S.of(context).duplicateFileCountWithStorageSaved(+ result.count,+ formatBytes(result.size),+ ),+ firstButtonLabel: S.of(context).rateUs,+ firstButtonOnTap: () async {+ await UpdateService.instance.launchReviewUrl();+ },+ firstButtonType: ButtonType.primary,+ secondButtonLabel: S.of(context).ok,+ secondButtonOnTap: () async {+ showShortToast(+ context,+ S.of(context).remindToEmptyEnteTrash,+ );+ },+ );+ }+}