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

View File

@ -1010,25 +1010,11 @@ class _FileManagerPageState extends State<FileManagerPage>
MainAxisAlignment.spaceBetween, MainAxisAlignment.spaceBetween,
children: [ children: [
ElevatedButton.icon( ElevatedButton.icon(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(
MyTheme.accent,
),
shape: buttonShape,
),
icon: Icon(Icons.close_rounded), icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")), label: Text(translate("Cancel")),
onPressed: cancel, onPressed: cancel,
), ),
ElevatedButton.icon( ElevatedButton.icon(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(
MyTheme.accent,
),
shape: buttonShape,
),
icon: Icon(Icons.done_rounded), icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")), label: Text(translate("Ok")),
onPressed: submit, 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" ? "${translate("Are you sure you want to delete the file of this directory?")}\n"
: ""; : "";
final count = entries.length > 1 ? "${i + 1}/${entries.length}" : ""; final count = entries.length > 1 ? "${i + 1}/${entries.length}" : "";
content = "$dirShow$count \n${entries[i].path}"; content = "$dirShow\n\n${entries[i].path}".trim();
final confirm = final confirm = await showRemoveDialog(
await showRemoveDialog(title, content, item.isDirectory); count.isEmpty ? title : "$title ($count)",
content,
item.isDirectory);
try { try {
if (confirm == true) { if (confirm == true) {
sendRemoveFile(entries[i].path, i, items.isLocal!); sendRemoveFile(entries[i].path, i, items.isLocal!);
@ -636,22 +638,27 @@ class FileModel extends ChangeNotifier {
submit() => close(true); submit() => close(true);
return CustomAlertDialog( return CustomAlertDialog(
title: Row( title: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
const Icon(Icons.warning, color: Colors.red), const Icon(Icons.warning_rounded, color: Colors.red),
const SizedBox(width: 20), Text(title).paddingOnly(
Text(title) left: 10,
),
], ],
), ),
contentBoxConstraints: contentBoxConstraints:
BoxConstraints(minHeight: 100, minWidth: 400, maxWidth: 400), BoxConstraints(minHeight: 80, minWidth: 400, maxWidth: 400),
content: Column( content: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [ children: [
Text(content), Text(content),
const SizedBox(height: 5), Text(
Text(translate("This is irreversible!"), translate("This is irreversible!"),
style: const TextStyle(fontWeight: FontWeight.bold)), style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.red,
),
).paddingOnly(top: 20),
showCheckbox showCheckbox
? CheckboxListTile( ? CheckboxListTile(
contentPadding: const EdgeInsets.all(0), contentPadding: const EdgeInsets.all(0),
@ -666,12 +673,24 @@ class FileModel extends ChangeNotifier {
setState(() => removeCheckboxRemember = v); setState(() => removeCheckboxRemember = v);
}, },
) )
: const SizedBox.shrink() : const SizedBox.shrink(),
]), Row(
actions: [ mainAxisAlignment: MainAxisAlignment.spaceBetween,
dialogButton("Cancel", onPressed: cancel, isOutline: true), children: [
dialogButton("OK", onPressed: submit), 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, onSubmit: submit,
onCancel: cancel, onCancel: cancel,
); );