opt: reset file confirm & clean code

This commit is contained in:
Kingtous 2022-05-18 15:47:07 +08:00
parent 42f2ebc8e6
commit 925ca66c42
2 changed files with 51 additions and 48 deletions

View File

@ -37,8 +37,8 @@ class MyTheme {
} }
final ButtonStyle flatButtonStyle = TextButton.styleFrom( final ButtonStyle flatButtonStyle = TextButton.styleFrom(
minimumSize: Size(88, 36), minimumSize: Size(0, 36),
padding: EdgeInsets.symmetric(horizontal: 16.0), padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 10.0),
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(2.0)), borderRadius: BorderRadius.all(Radius.circular(2.0)),
), ),

View File

@ -144,7 +144,7 @@ class FileModel extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
overrideFileConfirm(Map<String,dynamic> evt) async { overrideFileConfirm(Map<String, dynamic> evt) async {
final resp = await showFileConfirmDialog( final resp = await showFileConfirmDialog(
translate("Overwrite"), "${evt['read_path']}", true); translate("Overwrite"), "${evt['read_path']}", true);
if (false == resp) { if (false == resp) {
@ -418,53 +418,56 @@ class FileModel extends ChangeNotifier {
Future<bool?> showFileConfirmDialog( Future<bool?> showFileConfirmDialog(
String title, String content, bool showCheckbox) async { String title, String content, bool showCheckbox) async {
fileConfirmCheckboxRemember = false;
return await DialogManager.show<bool?>( return await DialogManager.show<bool?>(
(setState, Function(bool? v) close) => CustomAlertDialog( (setState, Function(bool? v) close) => CustomAlertDialog(
title: Row( title: Row(
children: [ children: [
Icon(Icons.warning, color: Colors.red), Icon(Icons.warning, color: Colors.red),
SizedBox(width: 20), SizedBox(width: 20),
Text(title) Text(title)
], ],
), ),
content: Column( content: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text(translate("This file exists, skip or overwrite this file?"), Text(
style: TextStyle(fontWeight: FontWeight.bold)), translate(
SizedBox(height: 5), "This file exists, skip or overwrite this file?"),
Text(content), style: TextStyle(fontWeight: FontWeight.bold)),
showCheckbox SizedBox(height: 5),
? CheckboxListTile( Text(content),
contentPadding: const EdgeInsets.all(0), showCheckbox
dense: true, ? CheckboxListTile(
controlAffinity: ListTileControlAffinity.leading, contentPadding: const EdgeInsets.all(0),
title: Text( dense: true,
translate("Do this for all conflicts"), controlAffinity: ListTileControlAffinity.leading,
), title: Text(
value: fileConfirmCheckboxRemember, translate("Do this for all conflicts"),
onChanged: (v) { ),
if (v == null) return; value: fileConfirmCheckboxRemember,
setState(() => fileConfirmCheckboxRemember = v); onChanged: (v) {
}, if (v == null) return;
) setState(() => fileConfirmCheckboxRemember = v);
: SizedBox.shrink() },
)
: SizedBox.shrink()
]),
actions: [
TextButton(
style: flatButtonStyle,
onPressed: () => close(false),
child: Text(translate("Cancel"))),
TextButton(
style: flatButtonStyle,
onPressed: () => close(null),
child: Text(translate("Skip"))),
TextButton(
style: flatButtonStyle,
onPressed: () => close(true),
child: Text(translate("OK"))),
]), ]),
actions: [
TextButton(
style: flatButtonStyle,
onPressed: () => close(false),
child: Text(translate("Cancel"))),
TextButton(
style: flatButtonStyle,
onPressed: () => close(null),
child: Text(translate("Skip"))),
TextButton(
style: flatButtonStyle,
onPressed: () => close(true),
child: Text(translate("OK"))),
]),
useAnimation: false); useAnimation: false);
} }