π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
refactor: Replace deleteConfirmationDialog with deleteConfirmationSheet for consistency
AmanRajSinghMourya2b0520d4e21b
diff --git a/mobile/apps/locker/lib/ui/components/delete_confirmation_dialog.dart b/mobile/apps/locker/lib/ui/components/delete_confirmation_dialog.dartdeleted file mode 100644index 6f10df9923..0000000000--- a/mobile/apps/locker/lib/ui/components/delete_confirmation_dialog.dart+++ /dev/null@@ -1,184 +0,0 @@-import "package:ente_ui/components/buttons/button_widget.dart";-import "package:ente_ui/components/buttons/models/button_result.dart";-import "package:ente_ui/components/close_icon_button.dart";-import "package:ente_ui/theme/ente_theme.dart";-import "package:flutter/material.dart";-import "package:locker/l10n/l10n.dart";-import "package:locker/ui/components/gradient_button.dart";--class DeleteConfirmationResult {- final ButtonResult buttonResult;- final bool deleteFromAllCollections;-- DeleteConfirmationResult({- required this.buttonResult,- required this.deleteFromAllCollections,- });-}--Future<DeleteConfirmationResult?> showDeleteConfirmationDialog(- BuildContext context, {- required String title,- required String body,- required String deleteButtonLabel,- required String assetPath,- bool showDeleteFromAllCollectionsOption = false,-}) {- return showModalBottomSheet<DeleteConfirmationResult>(- context: context,- isScrollControlled: true,- isDismissible: true,- builder: (context) {- return _DeleteConfirmationBottomSheet(- title: title,- body: body,- deleteButtonLabel: deleteButtonLabel,- assetPath: assetPath,- showDeleteFromAllCollectionsOption: showDeleteFromAllCollectionsOption,- );- },- );-}--class _DeleteConfirmationBottomSheet extends StatefulWidget {- final String title;- final String body;- final String deleteButtonLabel;- final String assetPath;- final bool showDeleteFromAllCollectionsOption;-- const _DeleteConfirmationBottomSheet({- required this.title,- required this.body,- required this.deleteButtonLabel,- required this.assetPath,- required this.showDeleteFromAllCollectionsOption,- });-- @override- State<_DeleteConfirmationBottomSheet> createState() =>- _DeleteConfirmationBottomSheetState();-}--class _DeleteConfirmationBottomSheetState- extends State<_DeleteConfirmationBottomSheet> {- bool _deleteFromAllCollections = false;-- @override- Widget build(BuildContext context) {- final textTheme = getEnteTextTheme(context);- final colorScheme = getEnteColorScheme(context);-- return Container(- decoration: BoxDecoration(- color: colorScheme.backdropBase,- border: Border(top: BorderSide(color: colorScheme.strokeFaint)),- borderRadius: const BorderRadius.only(- topLeft: Radius.circular(24),- topRight: Radius.circular(24),- ),- ),- child: SafeArea(- child: Padding(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Column(- mainAxisSize: MainAxisSize.min,- crossAxisAlignment: CrossAxisAlignment.center,- children: [- const SizedBox(height: 8),- const Row(- mainAxisAlignment: MainAxisAlignment.end,- children: [- CloseIconButton(),- ],- ),- const SizedBox(height: 8),- Center(child: Image.asset(widget.assetPath)),- const SizedBox(height: 24),- Text(- widget.title,- style: textTheme.h3Bold,- textAlign: TextAlign.center,- ),- const SizedBox(height: 12),- Text(- widget.body,- style: textTheme.body.copyWith(- color: colorScheme.textMuted,- ),- textAlign: TextAlign.center,- ),- const SizedBox(height: 20),- if (widget.showDeleteFromAllCollectionsOption) ...[- GestureDetector(- onTap: () {- setState(() {- _deleteFromAllCollections = !_deleteFromAllCollections;- });- },- child: SizedBox(- width: double.infinity,- child: Wrap(- alignment: WrapAlignment.center,- crossAxisAlignment: WrapCrossAlignment.center,- spacing: 12,- runSpacing: 8,- children: [- Container(- width: 18,- height: 18,- decoration: BoxDecoration(- border: Border.all(- color: _deleteFromAllCollections- ? colorScheme.primary700- : colorScheme.strokeMuted,- width: 2,- ),- borderRadius: BorderRadius.circular(6),- color: _deleteFromAllCollections- ? colorScheme.primary700- : Colors.transparent,- ),- alignment: Alignment.center,- child: _deleteFromAllCollections- ? const Icon(- Icons.check,- size: 12,- color: Colors.white,- )- : null,- ),- Text(- context.l10n.deleteCollectionFromEverywhere,- style: textTheme.small,- textAlign: TextAlign.center,- ),- ],- ),- ),- ),- const SizedBox(height: 20),- ],- const SizedBox(height: 12),- SizedBox(- width: double.infinity,- child: GradientButton(- onTap: () {- Navigator.of(context).pop(- DeleteConfirmationResult(- buttonResult: ButtonResult(ButtonAction.first),- deleteFromAllCollections: _deleteFromAllCollections,- ),- );- },- text: widget.deleteButtonLabel,- backgroundColor: colorScheme.warning400,- ),- ),- ],- ),- ),- ),- );- }-}diff --git a/mobile/apps/locker/lib/ui/components/delete_confirmation_sheet.dart b/mobile/apps/locker/lib/ui/components/delete_confirmation_sheet.dartnew file mode 100644index 0000000000..6db65b748f--- /dev/null+++ b/mobile/apps/locker/lib/ui/components/delete_confirmation_sheet.dart@@ -0,0 +1,151 @@+import "package:ente_ui/components/base_bottom_sheet.dart";+import "package:ente_ui/components/buttons/button_widget.dart";+import "package:ente_ui/components/buttons/models/button_result.dart";+import "package:ente_ui/theme/ente_theme.dart";+import "package:flutter/material.dart";+import "package:locker/l10n/l10n.dart";+import "package:locker/ui/components/gradient_button.dart";++class DeleteConfirmationResult {+ final ButtonResult buttonResult;+ final bool deleteFromAllCollections;++ DeleteConfirmationResult({+ required this.buttonResult,+ required this.deleteFromAllCollections,+ });+}++Future<DeleteConfirmationResult?> showDeleteConfirmationSheet(+ BuildContext context, {+ required String title,+ required String body,+ required String deleteButtonLabel,+ required String assetPath,+ bool showDeleteFromAllCollectionsOption = false,+}) {+ return showBaseBottomSheet<DeleteConfirmationResult>(+ context,+ title: title,+ headerSpacing: 20,+ crossAxisAlignment: CrossAxisAlignment.center,+ child: DeleteConfirmationSheet(+ body: body,+ deleteButtonLabel: deleteButtonLabel,+ assetPath: assetPath,+ showDeleteFromAllCollectionsOption: showDeleteFromAllCollectionsOption,+ ),+ );+}++class DeleteConfirmationSheet extends StatefulWidget {+ final String body;+ final String deleteButtonLabel;+ final String assetPath;+ final bool showDeleteFromAllCollectionsOption;++ const DeleteConfirmationSheet({+ super.key,+ required this.body,+ required this.deleteButtonLabel,+ required this.assetPath,+ required this.showDeleteFromAllCollectionsOption,+ });++ @override+ State<DeleteConfirmationSheet> createState() =>+ _DeleteConfirmationSheetState();+}++class _DeleteConfirmationSheetState extends State<DeleteConfirmationSheet> {+ bool _deleteFromAllCollections = false;++ @override+ Widget build(BuildContext context) {+ final textTheme = getEnteTextTheme(context);+ final colorScheme = getEnteColorScheme(context);++ return Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.center,+ children: [+ Center(child: Image.asset(widget.assetPath)),+ const SizedBox(height: 16),+ Text(+ widget.body,+ style: textTheme.body.copyWith(+ color: colorScheme.textMuted,+ ),+ textAlign: TextAlign.center,+ ),+ const SizedBox(height: 20),+ if (widget.showDeleteFromAllCollectionsOption) ...[+ GestureDetector(+ onTap: () {+ setState(() {+ _deleteFromAllCollections = !_deleteFromAllCollections;+ });+ },+ child: SizedBox(+ width: double.infinity,+ child: Wrap(+ alignment: WrapAlignment.center,+ crossAxisAlignment: WrapCrossAlignment.center,+ spacing: 12,+ runSpacing: 8,+ children: [+ Container(+ width: 18,+ height: 18,+ decoration: BoxDecoration(+ border: Border.all(+ color: _deleteFromAllCollections+ ? colorScheme.primary700+ : colorScheme.strokeMuted,+ width: 2,+ ),+ borderRadius: BorderRadius.circular(6),+ color: _deleteFromAllCollections+ ? colorScheme.primary700+ : Colors.transparent,+ ),+ alignment: Alignment.center,+ child: _deleteFromAllCollections+ ? const Icon(+ Icons.check,+ size: 12,+ color: Colors.white,+ )+ : null,+ ),+ Text(+ context.l10n.deleteCollectionFromEverywhere,+ style: textTheme.small,+ textAlign: TextAlign.center,+ ),+ ],+ ),+ ),+ ),+ const SizedBox(height: 20),+ ],+ const SizedBox(height: 12),+ SizedBox(+ width: double.infinity,+ child: GradientButton(+ onTap: () {+ Navigator.of(context).pop(+ DeleteConfirmationResult(+ buttonResult: ButtonResult(ButtonAction.first),+ deleteFromAllCollections: _deleteFromAllCollections,+ ),+ );+ },+ text: widget.deleteButtonLabel,+ backgroundColor: colorScheme.warning400,+ ),+ ),+ ],+ );+ }+}diff --git a/mobile/apps/locker/lib/ui/pages/trash_page.dart b/mobile/apps/locker/lib/ui/pages/trash_page.dartindex 2c1257bba4..f017c9f7b6 100644--- a/mobile/apps/locker/lib/ui/pages/trash_page.dart+++ b/mobile/apps/locker/lib/ui/pages/trash_page.dart@@ -13,7 +13,7 @@ import 'package:locker/services/collections/models/collection.dart';import 'package:locker/services/files/sync/models/file.dart';import 'package:locker/services/trash/models/trash_file.dart';import 'package:locker/services/trash/trash_service.dart';-import "package:locker/ui/components/delete_confirmation_dialog.dart";+import "package:locker/ui/components/delete_confirmation_sheet.dart";import "package:locker/ui/components/empty_state_widget.dart";import 'package:locker/ui/components/file_restore_dialog.dart';import 'package:locker/ui/components/item_list_view.dart';@@ -160,7 +160,7 @@ class _TrashPageState extends State<TrashPage> {}Future<void> _emptyTrash() async {- final result = await showDeleteConfirmationDialog(+ final result = await showDeleteConfirmationSheet(context,title: context.l10n.emptyTrash,body: context.l10n.emptyTrashConfirmation,diff --git a/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart b/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dartindex 5cbc862874..0b62cdd74d 100644--- a/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart+++ b/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart@@ -13,7 +13,7 @@ import "package:locker/services/collections/models/collection.dart";import "package:locker/services/favorites_service.dart";import "package:locker/services/files/sync/models/file.dart";import "package:locker/ui/components/add_to_collection_dialog.dart";-import "package:locker/ui/components/delete_confirmation_dialog.dart";+import "package:locker/ui/components/delete_confirmation_sheet.dart";import "package:locker/ui/components/selection_action_button_widget.dart";import "package:locker/utils/collection_list_util.dart";import "package:locker/utils/file_actions.dart";@@ -572,7 +572,7 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {return;}- final confirmation = await showDeleteConfirmationDialog(+ final confirmation = await showDeleteConfirmationSheet(context,title: context.l10n.areYouSure,body: context.l10n.deleteMultipleFilesDialogBody(files.length),diff --git a/mobile/apps/locker/lib/utils/collection_actions.dart b/mobile/apps/locker/lib/utils/collection_actions.dartindex 1415b6b9ce..7ee898c59e 100644--- a/mobile/apps/locker/lib/utils/collection_actions.dart+++ b/mobile/apps/locker/lib/utils/collection_actions.dart@@ -19,7 +19,7 @@ import 'package:locker/services/collections/collections_service.dart';import 'package:locker/services/collections/models/collection.dart';import "package:locker/services/configuration.dart";import "package:locker/services/trash/trash_service.dart";-import "package:locker/ui/components/delete_confirmation_dialog.dart";+import "package:locker/ui/components/delete_confirmation_sheet.dart";import "package:locker/ui/components/gradient_button.dart";import "package:locker/ui/components/input_dialog_sheet.dart";import "package:locker/ui/components/subscription_required_dialog.dart";@@ -123,7 +123,7 @@ class CollectionActions {}) async {if (collections.isEmpty) return;- final dialogChoice = await showDeleteConfirmationDialog(+ final dialogChoice = await showDeleteConfirmationSheet(context,title: context.l10n.areYouSure,body:@@ -277,7 +277,7 @@ class CollectionActions {final collectionName = collection.name ?? 'this collection';- final result = await showDeleteConfirmationDialog(+ final result = await showDeleteConfirmationSheet(context,title: l10n.areYouSure,body: l10n.deleteCollectionDialogBody(collectionName),diff --git a/mobile/apps/locker/lib/utils/file_actions.dart b/mobile/apps/locker/lib/utils/file_actions.dartindex 9294ee320b..1479cce132 100644--- a/mobile/apps/locker/lib/utils/file_actions.dart+++ b/mobile/apps/locker/lib/utils/file_actions.dart@@ -13,7 +13,7 @@ import "package:locker/services/files/sync/metadata_updater_service.dart";import "package:locker/services/files/sync/models/file.dart";import "package:locker/services/info_file_service.dart";import "package:locker/services/trash/trash_service.dart";-import "package:locker/ui/components/delete_confirmation_dialog.dart";+import "package:locker/ui/components/delete_confirmation_sheet.dart";import "package:locker/ui/components/file_edit_dialog.dart";import "package:locker/ui/components/share_link_dialog.dart";import "package:locker/ui/components/subscription_required_dialog.dart";@@ -287,7 +287,7 @@ class FileActions {EnteFile file, {VoidCallback? onSuccess,}) async {- final confirmation = await showDeleteConfirmationDialog(+ final confirmation = await showDeleteConfirmationSheet(context,title: context.l10n.areYouSure,body: context.l10n.deleteMultipleFilesDialogBody(1),@@ -346,7 +346,7 @@ class FileActions {return;}- final confirmation = await showDeleteConfirmationDialog(+ final confirmation = await showDeleteConfirmationSheet(context,title: context.l10n.areYouSure,body: context.l10n.deleteMultipleFilesDialogBody(files.length),