Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] Restore delete confirmation helper

Priyanshu Dangareb02e374b2e22
diff --git a/mobile/apps/photos/lib/ui/actions/file/file_actions.dart b/mobile/apps/photos/lib/ui/actions/file/file_actions.dart
index ac8c4a8be7..9cb85a0b98 100644
--- a/mobile/apps/photos/lib/ui/actions/file/file_actions.dart
+++ b/mobile/apps/photos/lib/ui/actions/file/file_actions.dart
@@ -35,28 +35,25 @@ Future<void> showSingleFileDeleteSheet(
(await isAndroidSDKVersionLowerThan(android11SDKINT) ||
await PhotoManager.canManageMedia())) {
if (!context.mounted) return;
- await showBottomSheetComponent<bool>(
- context: context,
- useRootNavigator: Platform.isIOS,
- builder: (_) => DeleteConfirmationSheet(
- count: 1,
- isLocal: isLocal,
- isRemote: false,
- onDeleteFromLocal: () async {
- final deletedFiles = await deleteFilesOnDeviceOnly(context, [file]);
- final didDelete = deletedFiles.isNotEmpty;
- if (didDelete && ((isLocal && !isRemote) || isLocalOnlyContext)) {
- onFileRemoved?.call(file);
- }
- return didDelete;
- },
- onDeleteFromRemote: () async {
- throw AssertionError("delete from remote in local gallery mode");
- },
- onDeleteFromBoth: () async {
- throw AssertionError("delete from both in local gallery mode");
- },
- ),
+ await showDeleteConfirmationSheet(
+ context,
+ count: 1,
+ isLocal: isLocal,
+ isRemote: false,
+ onDeleteFromLocal: () async {
+ final deletedFiles = await deleteFilesOnDeviceOnly(context, [file]);
+ final didDelete = deletedFiles.isNotEmpty;
+ if (didDelete && ((isLocal && !isRemote) || isLocalOnlyContext)) {
+ onFileRemoved?.call(file);
+ }
+ return didDelete;
+ },
+ onDeleteFromRemote: () async {
+ throw AssertionError("delete from remote in local gallery mode");
+ },
+ onDeleteFromBoth: () async {
+ throw AssertionError("delete from both in local gallery mode");
+ },
);
} else {
if (!context.mounted) return;
@@ -71,39 +68,36 @@ Future<void> showSingleFileDeleteSheet(
if (!isLocal && !isRemote) {
throw AssertionError("Unexpected state");
}
- final didDelete = await showBottomSheetComponent<bool>(
- context: context,
- useRootNavigator: Platform.isIOS,
- builder: (_) => DeleteConfirmationSheet(
- isLocal: isLocal,
- isRemote: isRemote,
- count: 1,
- onDeleteFromLocal: () async {
- final deletedFiles = await deleteFilesOnDeviceOnly(context, [file]);
- final didDelete = deletedFiles.isNotEmpty;
- if (didDelete && ((isLocal && !isRemote) || isLocalOnlyContext)) {
- onFileRemoved?.call(file);
- }
- return didDelete;
- },
- onDeleteFromRemote: () async {
- await deleteFilesFromRemoteOnly(context, [file]);
- if (!context.mounted) return false;
- showShortToast(context, l10n.movedToTrash);
- if (((isRemote && !isLocal) || !isLocalOnlyContext)) {
- onFileRemoved?.call(file);
- }
- return true;
- },
- onDeleteFromBoth: () async {
- final deletedFiles = await deleteFilesFromEverywhere(context, [file]);
- final didDelete = deletedFiles.isNotEmpty;
- if (didDelete) {
- onFileRemoved?.call(file);
- }
- return didDelete;
- },
- ),
+ final didDelete = await showDeleteConfirmationSheet(
+ context,
+ isLocal: isLocal,
+ isRemote: isRemote,
+ count: 1,
+ onDeleteFromLocal: () async {
+ final deletedFiles = await deleteFilesOnDeviceOnly(context, [file]);
+ final didDelete = deletedFiles.isNotEmpty;
+ if (didDelete && ((isLocal && !isRemote) || isLocalOnlyContext)) {
+ onFileRemoved?.call(file);
+ }
+ return didDelete;
+ },
+ onDeleteFromRemote: () async {
+ await deleteFilesFromRemoteOnly(context, [file]);
+ if (!context.mounted) return false;
+ showShortToast(context, l10n.movedToTrash);
+ if (((isRemote && !isLocal) || !isLocalOnlyContext)) {
+ onFileRemoved?.call(file);
+ }
+ return true;
+ },
+ onDeleteFromBoth: () async {
+ final deletedFiles = await deleteFilesFromEverywhere(context, [file]);
+ final didDelete = deletedFiles.isNotEmpty;
+ if (didDelete) {
+ onFileRemoved?.call(file);
+ }
+ return didDelete;
+ },
);
if (didDelete == true && isLocal) {
if (!context.mounted) return;