modern file manager delete dialog

This commit is contained in:
NicKoehler 2023-02-27 20:56:45 +01:00
parent c18c6d72bd
commit 828c201fe0
No known key found for this signature in database
GPG Key ID: BAE01394EB51AC58
3 changed files with 125 additions and 53 deletions

View File

@ -202,9 +202,43 @@ class MyTheme {
splashFactory: isDesktop ? NoSplash.splashFactory : null,
textButtonTheme: isDesktop
? TextButtonThemeData(
style: ButtonStyle(splashFactory: NoSplash.splashFactory),
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
),
),
)
: null,
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
MyTheme.accent,
),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
),
),
),
checkboxTheme: const CheckboxThemeData(
splashRadius: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(5),
),
),
),
listTileTheme: ListTileThemeData(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(5),
),
),
),
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.blue,
).copyWith(
@ -257,11 +291,44 @@ class MyTheme {
OutlinedButton.styleFrom(side: BorderSide(color: Colors.white38))),
textButtonTheme: isDesktop
? TextButtonThemeData(
style: ButtonStyle(splashFactory: NoSplash.splashFactory),
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
),
),
)
: null,
checkboxTheme:
const CheckboxThemeData(checkColor: MaterialStatePropertyAll(dark)),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
MyTheme.accent,
),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
),
),
),
checkboxTheme: const CheckboxThemeData(
checkColor: MaterialStatePropertyAll(dark),
splashRadius: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(5),
),
),
),
listTileTheme: ListTileThemeData(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(5),
),
),
),
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.blue,
).copyWith(
@ -684,7 +751,7 @@ class CustomAlertDialog extends StatelessWidget {
Future.delayed(Duration.zero, () {
if (!scopeNode.hasFocus) scopeNode.requestFocus();
});
const double padding = 16;
const double padding = 30;
bool tabTapped = false;
return FocusScope(
node: scopeNode,

View File

@ -1010,25 +1010,11 @@ class _FileManagerPageState extends State<FileManagerPage>
MainAxisAlignment.spaceBetween,
children: [
ElevatedButton.icon(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(
MyTheme.accent,
),
shape: buttonShape,
),
icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")),
onPressed: cancel,
),
ElevatedButton.icon(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(
MyTheme.accent,
),
shape: buttonShape,
),
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit,

View File

@ -593,9 +593,11 @@ class FileModel extends ChangeNotifier {
? "${translate("Are you sure you want to delete the file of this directory?")}\n"
: "";
final count = entries.length > 1 ? "${i + 1}/${entries.length}" : "";
content = "$dirShow$count \n${entries[i].path}";
final confirm =
await showRemoveDialog(title, content, item.isDirectory);
content = "$dirShow\n\n${entries[i].path}".trim();
final confirm = await showRemoveDialog(
count.isEmpty ? title : "$title ($count)",
content,
item.isDirectory);
try {
if (confirm == true) {
sendRemoveFile(entries[i].path, i, items.isLocal!);
@ -636,42 +638,59 @@ class FileModel extends ChangeNotifier {
submit() => close(true);
return CustomAlertDialog(
title: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.warning, color: Colors.red),
const SizedBox(width: 20),
Text(title)
const Icon(Icons.warning_rounded, color: Colors.red),
Text(title).paddingOnly(
left: 10,
),
],
),
contentBoxConstraints:
BoxConstraints(minHeight: 100, minWidth: 400, maxWidth: 400),
BoxConstraints(minHeight: 80, minWidth: 400, maxWidth: 400),
content: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(content),
const SizedBox(height: 5),
Text(translate("This is irreversible!"),
style: const TextStyle(fontWeight: FontWeight.bold)),
showCheckbox
? CheckboxListTile(
contentPadding: const EdgeInsets.all(0),
dense: true,
controlAffinity: ListTileControlAffinity.leading,
title: Text(
translate("Do this for all conflicts"),
),
value: removeCheckboxRemember,
onChanged: (v) {
if (v == null) return;
setState(() => removeCheckboxRemember = v);
},
)
: const SizedBox.shrink()
]),
actions: [
dialogButton("Cancel", onPressed: cancel, isOutline: true),
dialogButton("OK", onPressed: submit),
],
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(content),
Text(
translate("This is irreversible!"),
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.red,
),
).paddingOnly(top: 20),
showCheckbox
? CheckboxListTile(
contentPadding: const EdgeInsets.all(0),
dense: true,
controlAffinity: ListTileControlAffinity.leading,
title: Text(
translate("Do this for all conflicts"),
),
value: removeCheckboxRemember,
onChanged: (v) {
if (v == null) return;
setState(() => removeCheckboxRemember = v);
},
)
: const SizedBox.shrink(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton.icon(
icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")),
onPressed: cancel,
),
ElevatedButton.icon(
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit,
),
],
).paddingOnly(top: 20)
],
),
onSubmit: submit,
onCancel: cancel,
);