Skip to content

armgit / ente

Public Imported from GitHub
0

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

Update delete dialog

AmanRajSinghMourya3e630257b379
diff --git a/mobile/apps/locker/assets/2.0x/delete_icon.png b/mobile/apps/locker/assets/2.0x/delete_icon.png
new file mode 100644
index 0000000000..6163bfad4a
Binary files /dev/null and b/mobile/apps/locker/assets/2.0x/delete_icon.png differ
diff --git a/mobile/apps/locker/assets/3.0x/delete_icon.png b/mobile/apps/locker/assets/3.0x/delete_icon.png
new file mode 100644
index 0000000000..41c6c52c91
Binary files /dev/null and b/mobile/apps/locker/assets/3.0x/delete_icon.png differ
diff --git a/mobile/apps/locker/assets/delete_icon.png b/mobile/apps/locker/assets/delete_icon.png
new file mode 100644
index 0000000000..3dc70133b7
Binary files /dev/null and b/mobile/apps/locker/assets/delete_icon.png differ
diff --git a/mobile/apps/locker/lib/ui/components/delete_confirmation_dialog.dart b/mobile/apps/locker/lib/ui/components/delete_confirmation_dialog.dart
new file mode 100644
index 0000000000..934d7a0924
--- /dev/null
+++ b/mobile/apps/locker/lib/ui/components/delete_confirmation_dialog.dart
@@ -0,0 +1,139 @@
+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:hugeicons/hugeicons.dart";
+
+Future<ButtonResult?> showDeleteConfirmationDialog(
+ BuildContext context, {
+ required String title,
+ required String body,
+ required String deleteButtonLabel,
+ required int fileCount,
+}) {
+ return showModalBottomSheet<ButtonResult>(
+ context: context,
+ backgroundColor: Colors.transparent,
+ isScrollControlled: true,
+ isDismissible: true,
+ builder: (context) {
+ return _DeleteConfirmationBottomSheet(
+ title: title,
+ body: body,
+ deleteButtonLabel: deleteButtonLabel,
+ fileCount: fileCount,
+ );
+ },
+ );
+}
+
+class _DeleteConfirmationBottomSheet extends StatelessWidget {
+ final String title;
+ final String body;
+ final String deleteButtonLabel;
+ final int fileCount;
+
+ const _DeleteConfirmationBottomSheet({
+ required this.title,
+ required this.body,
+ required this.deleteButtonLabel,
+ required this.fileCount,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final textTheme = getEnteTextTheme(context);
+ final colorScheme = getEnteColorScheme(context);
+
+ return Container(
+ decoration: BoxDecoration(
+ color: colorScheme.backgroundBase,
+ borderRadius: const BorderRadius.only(
+ topLeft: Radius.circular(24),
+ topRight: Radius.circular(24),
+ ),
+ ),
+ child: SafeArea(
+ child: Padding(
+ padding: const EdgeInsets.only(
+ left: 16,
+ right: 16,
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const SizedBox(height: 8),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.end,
+ children: [
+ GestureDetector(
+ onTap: () => Navigator.of(context).pop(),
+ child: Container(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(50),
+ color: colorScheme.backdropBase,
+ ),
+ padding: const EdgeInsets.all(8),
+ child: Icon(
+ Icons.close,
+ size: 24,
+ color: colorScheme.iconColor,
+ ),
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(height: 8),
+ Image.asset('assets/delete_icon.png'),
+ const SizedBox(height: 24),
+ Text(
+ "Are you sure?",
+ style: textTheme.h3Bold,
+ textAlign: TextAlign.center,
+ ),
+ const SizedBox(height: 12),
+ Text(
+ "This action is immediate and cannot be undone.\n$fileCount files will be deleted permanently.",
+ style: textTheme.body.copyWith(
+ color: colorScheme.textMuted,
+ ),
+ textAlign: TextAlign.center,
+ ),
+ const SizedBox(height: 32),
+ SizedBox(
+ width: double.infinity,
+ height: 56,
+ child: ElevatedButton.icon(
+ onPressed: () {
+ Navigator.of(context).pop(
+ ButtonResult(ButtonAction.first),
+ );
+ },
+ style: ElevatedButton.styleFrom(
+ backgroundColor: colorScheme.warning400,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(12),
+ ),
+ elevation: 0,
+ ),
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedFileUpload,
+ color: colorScheme.backdropBase,
+ size: 20,
+ strokeWidth: 1.9,
+ ),
+ label: Text(
+ "Yes, delete files",
+ style: textTheme.bodyBold.copyWith(
+ color: colorScheme.backdropBase,
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/mobile/apps/locker/lib/ui/components/file_popup_menu_widget.dart b/mobile/apps/locker/lib/ui/components/file_popup_menu_widget.dart
index f65490d941..1f800cbae7 100644
--- a/mobile/apps/locker/lib/ui/components/file_popup_menu_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/file_popup_menu_widget.dart
@@ -1,5 +1,4 @@
import "package:ente_ui/components/buttons/button_widget.dart";
-import "package:ente_ui/components/buttons/models/button_type.dart";
import "package:ente_ui/theme/ente_theme.dart";
import "package:ente_ui/utils/dialog_util.dart";
import "package:flutter/material.dart";
@@ -10,6 +9,7 @@ import "package:locker/services/collections/models/collection.dart";
import "package:locker/services/files/links/links_service.dart";
import "package:locker/services/files/sync/metadata_updater_service.dart";
import "package:locker/services/files/sync/models/file.dart";
+import "package:locker/ui/components/delete_confirmation_dialog.dart";
import "package:locker/ui/components/file_edit_dialog.dart";
import "package:locker/ui/components/item_list_view.dart";
import "package:locker/ui/components/menu_item_widget.dart";
@@ -184,14 +184,12 @@ class FilePopupMenuWidget extends StatelessWidget {
}
Future<void> _showDeleteConfirmationDialog(BuildContext context) async {
- final result = await showChoiceDialog(
+ final result = await showDeleteConfirmationDialog(
context,
title: context.l10n.deleteFile,
body: context.l10n.deleteFileConfirmation(file.displayName),
- firstButtonLabel: context.l10n.delete,
- secondButtonLabel: context.l10n.cancel,
- firstButtonType: ButtonType.critical,
- isCritical: true,
+ deleteButtonLabel: context.l10n.delete,
+ fileCount: 1,
);
if (result?.action == ButtonAction.first && context.mounted) {