Replaced the last old choice dialog
This commit is contained in:
parent
e38a2c29c6
commit
a9db657cb4
2 changed files with 10 additions and 84 deletions
|
@ -1,76 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:photos/ente_theme_data.dart';
|
||||
|
||||
enum DialogUserChoice { firstChoice, secondChoice }
|
||||
|
||||
enum ActionType {
|
||||
confirm,
|
||||
critical,
|
||||
}
|
||||
|
||||
// if dialog is dismissed by tapping outside, this will return null
|
||||
Future<DialogUserChoice?> showChoiceDialog<T>(
|
||||
BuildContext context,
|
||||
String title,
|
||||
String content, {
|
||||
String firstAction = 'Ok',
|
||||
Color? firstActionColor,
|
||||
String secondAction = 'Cancel',
|
||||
Color? secondActionColor,
|
||||
ActionType actionType = ActionType.confirm,
|
||||
}) {
|
||||
final AlertDialog alert = AlertDialog(
|
||||
title: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: actionType == ActionType.critical
|
||||
? Colors.red
|
||||
: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
content: Text(
|
||||
content,
|
||||
style: const TextStyle(
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
firstAction,
|
||||
style: TextStyle(
|
||||
color: firstActionColor ??
|
||||
(actionType == ActionType.critical
|
||||
? Colors.red
|
||||
: Theme.of(context).colorScheme.onSurface),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context, rootNavigator: true)
|
||||
.pop(DialogUserChoice.firstChoice);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text(
|
||||
secondAction,
|
||||
style: TextStyle(
|
||||
color: secondActionColor ??
|
||||
Theme.of(context).colorScheme.greenAlternative,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context, rootNavigator: true)
|
||||
.pop(DialogUserChoice.secondChoice);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return alert;
|
||||
},
|
||||
barrierColor: Colors.black87,
|
||||
);
|
||||
}
|
|
@ -20,7 +20,6 @@ import 'package:photos/models/trash_item_request.dart';
|
|||
import 'package:photos/services/remote_sync_service.dart';
|
||||
import 'package:photos/services/sync_service.dart';
|
||||
import 'package:photos/services/trash_sync_service.dart';
|
||||
import 'package:photos/ui/common/dialogs.dart';
|
||||
import 'package:photos/ui/common/linear_progress_dialog.dart';
|
||||
import 'package:photos/ui/components/action_sheet_widget.dart';
|
||||
import 'package:photos/ui/components/button_widget.dart';
|
||||
|
@ -464,15 +463,18 @@ Future<List<String>> _tryDeleteSharedMediaFiles(List<String> localIDs) {
|
|||
}
|
||||
|
||||
Future<bool> shouldProceedWithDeletion(BuildContext context) async {
|
||||
final choice = await showChoiceDialog(
|
||||
final choice = await showNewChoiceDialog(
|
||||
context,
|
||||
"Are you sure?",
|
||||
"Some of the files you are trying to delete are only available on your device and cannot be recovered if deleted",
|
||||
firstAction: "Cancel",
|
||||
secondAction: "Delete",
|
||||
secondActionColor: Colors.red,
|
||||
title: "Are you sure?",
|
||||
body:
|
||||
"Some of the files you are trying to delete are only available on your device and cannot be recovered if deleted",
|
||||
firstButtonLabel: "Delete",
|
||||
);
|
||||
return choice == DialogUserChoice.secondChoice;
|
||||
if (choice == null) {
|
||||
return false;
|
||||
} else {
|
||||
return choice == ButtonAction.first;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> showDeleteSheet(
|
||||
|
|
Loading…
Reference in a new issue