Skip to content

armgit / ente

Public Imported from GitHub
0

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

Polish single delete confirmation sheet

ashilkn3162ca861e85
diff --git a/mobile/apps/photos/lib/utils/delete_file_util.dart b/mobile/apps/photos/lib/utils/delete_file_util.dart
index def016eab8..e308d4dfa9 100644
--- a/mobile/apps/photos/lib/utils/delete_file_util.dart
+++ b/mobile/apps/photos/lib/utils/delete_file_util.dart
@@ -814,6 +814,7 @@ Future<void> showDeleteSheet(
final bool isBothLocalAndRemote = containsUploadedFile && containsLocalFile;
final bool isLocalOnly = !containsUploadedFile;
final bool isRemoteOnly = !containsLocalFile;
+ final bool hasSingleDeleteAction = isLocalOnly || isRemoteOnly;
final String? bodyHighlight = isBothLocalAndRemote
? AppLocalizations.of(context).theyWillBeDeletedFromAllAlbums
: null;
@@ -836,7 +837,9 @@ Future<void> showDeleteSheet(
labelText: isBothLocalAndRemote
? AppLocalizations.of(context).deleteFromEnte
: AppLocalizations.of(context).yesDelete,
- buttonType: ButtonType.neutral,
+ buttonType: hasSingleDeleteAction
+ ? ButtonType.critical
+ : ButtonType.neutral,
buttonSize: ButtonSize.large,
shouldStickToDarkTheme: true,
buttonAction: ButtonAction.first,
@@ -864,7 +867,9 @@ Future<void> showDeleteSheet(
labelText: isBothLocalAndRemote
? AppLocalizations.of(context).deleteFromDevice
: AppLocalizations.of(context).yesDelete,
- buttonType: ButtonType.neutral,
+ buttonType: hasSingleDeleteAction
+ ? ButtonType.critical
+ : ButtonType.neutral,
buttonSize: ButtonSize.large,
shouldStickToDarkTheme: true,
buttonAction: ButtonAction.second,
@@ -907,6 +912,9 @@ Future<void> showDeleteSheet(
context: context,
buttons: buttons,
actionSheetType: ActionSheetType.defaultActionSheet,
+ title: hasSingleDeleteAction
+ ? AppLocalizations.of(context).areYouSure
+ : null,
body: body,
bodyHighlight: bodyHighlight,
);
diff --git a/mobile/apps/photos/test/utils/delete_file_util_test.dart b/mobile/apps/photos/test/utils/delete_file_util_test.dart
index 37bd20c8f5..d0af95accf 100644
--- a/mobile/apps/photos/test/utils/delete_file_util_test.dart
+++ b/mobile/apps/photos/test/utils/delete_file_util_test.dart
@@ -73,7 +73,7 @@ void main() {
},
);
- testWidgets('matches the legacy remote-only delete action sheet', (
+ testWidgets('remote-only delete sheet uses title and critical action', (
tester,
) async {
final file = _file(generatedID: 2, uploadedID: 12);
@@ -95,8 +95,13 @@ void main() {
),
findsOneWidget,
);
+ expect(find.text('Are you sure?'), findsOneWidget);
expect(find.text('They will be deleted from all albums.'), findsNothing);
expect(find.byType(ButtonComponent), findsOneWidget);
+ final deleteButton = tester.widget<ButtonComponent>(
+ find.byType(ButtonComponent),
+ );
+ expect(deleteButton.variant, ButtonComponentVariant.critical);
expect(find.text('Delete from Ente'), findsNothing);
expect(find.text('Delete from device'), findsNothing);
expect(find.text('Delete from both'), findsNothing);
@@ -105,7 +110,7 @@ void main() {
_expectVisibleButtonsInOrder(tester, ['Yes, delete']);
});
- testWidgets('matches the legacy local-only delete action sheet', (
+ testWidgets('local-only delete sheet uses title and critical action', (
tester,
) async {
final file = _file(generatedID: 3, localID: 'local-3');
@@ -125,8 +130,13 @@ void main() {
find.text('These items will be deleted from your device.'),
findsOneWidget,
);
+ expect(find.text('Are you sure?'), findsOneWidget);
expect(find.text('They will be deleted from all albums.'), findsNothing);
expect(find.byType(ButtonComponent), findsOneWidget);
+ final deleteButton = tester.widget<ButtonComponent>(
+ find.byType(ButtonComponent),
+ );
+ expect(deleteButton.variant, ButtonComponentVariant.critical);
expect(find.text('Delete from Ente'), findsNothing);
expect(find.text('Delete from device'), findsNothing);
expect(find.text('Delete from both'), findsNothing);