π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update permanent delete bottom sheet
ashilknae922d096df5
diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arbindex cd8a6eed7b..5e027319ee 100644--- a/mobile/apps/photos/lib/l10n/intl_en.arb+++ b/mobile/apps/photos/lib/l10n/intl_en.arb@@ -1457,6 +1457,7 @@"filesDeleted": "Files deleted","selectedFilesAreNotOnEnte": "Selected files are not on Ente","thisActionCannotBeUndone": "This action cannot be undone",+ "selectedItemsWillBePermanentlyDeletedAndCannotBeRecovered": "Selected items will be permanently deleted and cannot be recovered.","emptyTrash": "Empty trash?","permDeleteWarning": "All items in trash will be permanently deleted\n\nThis action cannot be undone","empty": "Empty",diff --git a/mobile/apps/photos/lib/utils/delete_file_util.dart b/mobile/apps/photos/lib/utils/delete_file_util.dartindex 8af6f64359..90dca3c180 100644--- a/mobile/apps/photos/lib/utils/delete_file_util.dart+++ b/mobile/apps/photos/lib/utils/delete_file_util.dart@@ -267,35 +267,51 @@ Future<List<EnteFile>> deleteFilesOnDeviceOnly(Future<bool> deleteFromTrash(BuildContext context, List<EnteFile> files) async {bool didDeletionStart = false;- final actionResult = await showChoiceActionSheet(- context,- title: AppLocalizations.of(context).permanentlyDelete,- body: AppLocalizations.of(context).thisActionCannotBeUndone,- firstButtonLabel: AppLocalizations.of(context).delete,- isCritical: true,- firstButtonOnTap: () async {- try {- didDeletionStart = true;- await trashSyncService.deleteFromTrash(files);- Bus.instance.fire(- FilesUpdatedEvent(- files,- type: EventType.deletedFromEverywhere,- source: "deleteFromTrash",+ final l10n = AppLocalizations.of(context);+ final actionResult = await showBottomSheetComponent<ButtonResult>(+ context: context,+ useRootNavigator: Platform.isIOS,+ builder: (sheetContext) => BottomSheetComponent(+ title: l10n.areYouSure,+ message: l10n.selectedItemsWillBePermanentlyDeletedAndCannotBeRecovered,+ illustration: Image.asset("assets/warning-grey.png"),+ closeTooltip: l10n.close,+ closeResult: ButtonResult(ButtonAction.fourth),+ actions: [+ ButtonComponent(+ label: l10n.yesDelete,+ variant: ButtonComponentVariant.critical,+ onTap: () => _runDeleteAction(+ sheetContext,+ ButtonAction.first,+ () async {+ try {+ didDeletionStart = true;+ await trashSyncService.deleteFromTrash(files);+ Bus.instance.fire(+ FilesUpdatedEvent(+ files,+ type: EventType.deletedFromEverywhere,+ source: "deleteFromTrash",+ ),+ );+ //the FilesUpdateEvent is not reloading trash on premanently removing+ //files, so need to fire ForceReloadTrashPageEvent+ Bus.instance.fire(ForceReloadTrashPageEvent());+ } catch (e, s) {+ _logger.info("failed to delete from trash", e, s);+ rethrow;+ }+ },),- );- //the FilesUpdateEvent is not reloading trash on premanently removing- //files, so need to fire ForceReloadTrashPageEvent- Bus.instance.fire(ForceReloadTrashPageEvent());- } catch (e, s) {- _logger.info("failed to delete from trash", e, s);- rethrow;- }- },+ ),+ ],+ ),);if (actionResult?.action == null ||- actionResult!.action == ButtonAction.cancel) {+ actionResult!.action == ButtonAction.cancel ||+ actionResult.action == ButtonAction.fourth) {return didDeletionStart ? true : false;} else if (actionResult.action == ButtonAction.error) {await showGenericErrorDialog(diff --git a/mobile/apps/photos/test/utils/delete_file_util_test.dart b/mobile/apps/photos/test/utils/delete_file_util_test.dartindex 406a15b3ac..e36a41fcd1 100644--- a/mobile/apps/photos/test/utils/delete_file_util_test.dart+++ b/mobile/apps/photos/test/utils/delete_file_util_test.dart@@ -36,6 +36,42 @@ void main() {await localSettings.setAppMode(AppMode.enteGallery);});+ group('deleteFromTrash', () {+ testWidgets('uses the migrated warning delete sheet', (tester) async {+ final file = _file(generatedID: 21, uploadedID: 31);+ bool? result;++ await tester.pumpWidget(+ _TestApp(+ onOpen: (context) async {+ result = await deleteFromTrash(context, [file]);+ },+ ),+ );++ await tester.tap(find.text('Open delete sheet'));+ await tester.pumpAndSettle();++ expect(find.byType(BottomSheetComponent), findsOneWidget);+ _expectDeleteWarningIllustration();+ expect(find.text('Are you sure?'), findsOneWidget);+ expect(+ find.text(+ 'Selected items will be permanently deleted and cannot be recovered.',+ ),+ findsOneWidget,+ );+ expect(find.byTooltip('Close'), findsOneWidget);+ expect(find.text('Cancel'), findsNothing);+ _expectVisibleButtonsInOrder(tester, ['Yes, delete']);++ await tester.tap(find.byTooltip('Close'));+ await tester.pumpAndSettle();++ expect(result, false);+ });+ });+group('showDeleteSheet', () {testWidgets('mixed local and remote delete sheet shows mixed component actions',