added icon to dialogButton, reverted some design changes. The outline buttons now rely on theme data

This commit is contained in:
NicKoehler 2023-03-01 14:50:50 +01:00
parent 18339cf343
commit fd8829f08e
No known key found for this signature in database
GPG Key ID: BAE01394EB51AC58
5 changed files with 210 additions and 204 deletions

View File

@ -224,7 +224,20 @@ class MyTheme {
),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
borderRadius: BorderRadius.circular(8.0),
),
),
),
),
outlinedButtonTheme: OutlinedButtonThemeData(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
Color(0xFFEEEEEE),
),
foregroundColor: MaterialStateProperty.all(Colors.black87),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
),
@ -296,9 +309,6 @@ class MyTheme {
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
splashFactory: isDesktop ? NoSplash.splashFactory : null,
outlinedButtonTheme: OutlinedButtonThemeData(
style:
OutlinedButton.styleFrom(side: BorderSide(color: Colors.white38))),
textButtonTheme: isDesktop
? TextButtonThemeData(
style: ButtonStyle(
@ -318,7 +328,23 @@ class MyTheme {
),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
borderRadius: BorderRadius.circular(8.0),
),
),
),
),
outlinedButtonTheme: OutlinedButtonThemeData(
style: ButtonStyle(
backgroundColor: MaterialStatePropertyAll(
Color(0xFF24252B),
),
side: MaterialStatePropertyAll(
BorderSide(color: Colors.white12, width: 0.5),
),
foregroundColor: MaterialStateProperty.all(Colors.white70),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
),
@ -1824,28 +1850,43 @@ class ServerConfig {
Widget dialogButton(String text,
{required VoidCallback? onPressed,
bool isOutline = false,
Widget? icon,
TextStyle? style,
ButtonStyle? buttonStyle}) {
if (isDesktop) {
if (isOutline) {
return OutlinedButton(
onPressed: onPressed,
child: Text(translate(text), style: style),
);
return icon == null
? OutlinedButton(
onPressed: onPressed,
child: Text(translate(text), style: style),
)
: OutlinedButton.icon(
icon: icon,
onPressed: onPressed,
label: Text(translate(text), style: style),
);
} else {
return ElevatedButton(
style: ElevatedButton.styleFrom(elevation: 0).merge(buttonStyle),
onPressed: onPressed,
child: Text(translate(text), style: style),
);
return icon == null
? ElevatedButton(
style: ElevatedButton.styleFrom(elevation: 0).merge(buttonStyle),
onPressed: onPressed,
child: Text(translate(text), style: style),
)
: ElevatedButton.icon(
icon: icon,
style: ElevatedButton.styleFrom(elevation: 0).merge(buttonStyle),
onPressed: onPressed,
label: Text(translate(text), style: style),
);
}
} else {
return TextButton(
onPressed: onPressed,
child: Text(
translate(text),
style: style,
));
onPressed: onPressed,
child: Text(
translate(text),
style: style,
),
);
}
}

View File

@ -683,23 +683,21 @@ abstract class BasePeerCard extends StatelessWidget {
Obx(() => Offstage(
offstage: isInProgress.isFalse,
child: const LinearProgressIndicator())),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton.icon(
icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")),
onPressed: close,
),
ElevatedButton.icon(
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit,
),
],
).paddingOnly(top: 20)
],
),
actions: [
dialogButton(
"Cancel",
icon: Icon(Icons.close_rounded),
onPressed: close,
isOutline: true,
),
dialogButton(
"OK",
icon: Icon(Icons.done_rounded),
onPressed: submit,
),
],
onSubmit: submit,
onCancel: close,
);
@ -740,26 +738,20 @@ abstract class BasePeerCard extends StatelessWidget {
),
],
),
content: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton.icon(
icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")),
onPressed: close,
),
ElevatedButton.icon(
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit,
),
],
).paddingOnly(top: 20)
],
),
content: SizedBox.shrink(),
actions: [
dialogButton(
"Cancel",
icon: Icon(Icons.close_rounded),
onPressed: close,
isOutline: true,
),
dialogButton(
"OK",
icon: Icon(Icons.done_rounded),
onPressed: submit,
),
],
onSubmit: submit,
onCancel: close,
);

View File

@ -989,37 +989,30 @@ class _FileManagerPageState extends State<FileManagerPage>
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Column(
children: [
TextFormField(
decoration: InputDecoration(
labelText: translate(
"Please enter the folder name",
),
),
controller: name,
autofocus: true,
TextFormField(
decoration: InputDecoration(
labelText: translate(
"Please enter the folder name",
),
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)
],
),
controller: name,
autofocus: true,
),
],
),
actions: [
dialogButton(
"Cancel",
icon: Icon(Icons.close_rounded),
onPressed: cancel,
isOutline: true,
),
dialogButton(
"Ok",
icon: Icon(Icons.done_rounded),
onPressed: submit,
),
],
onSubmit: submit,
onCancel: cancel,
);

View File

@ -28,27 +28,21 @@ void showRestartRemoteDevice(
Icon(Icons.warning_rounded, color: Colors.redAccent, size: 28),
Text(translate("Restart Remote Device")).paddingOnly(left: 10),
]),
content: Column(
children: [
Text(
"${translate('Are you sure you want to restart')} \n${pi.username}@${pi.hostname}($id) ?"),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton.icon(
icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")),
onPressed: close,
),
ElevatedButton.icon(
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: () => close(true),
),
],
).paddingOnly(top: 20)
],
),
content: Text(
"${translate('Are you sure you want to restart')} \n${pi.username}@${pi.hostname}($id) ?"),
actions: [
dialogButton(
"Cancel",
icon: Icon(Icons.close_rounded),
onPressed: close,
isOutline: true,
),
dialogButton(
"OK",
icon: Icon(Icons.done_rounded),
onPressed: () => close(true),
),
],
onCancel: close,
onSubmit: () => close(true),
));
@ -82,76 +76,65 @@ void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
Text(translate('Set your own password')).paddingOnly(left: 10),
],
),
content: Column(
children: [
Form(
autovalidateMode: AutovalidateMode.onUserInteraction,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextFormField(
autofocus: true,
obscureText: true,
keyboardType: TextInputType.visiblePassword,
decoration: InputDecoration(
labelText: translate('Password'),
),
controller: p0,
validator: (v) {
if (v == null) return null;
final val = v.trim().length > 5;
if (validateLength != val) {
// use delay to make setState success
Future.delayed(Duration(microseconds: 1),
() => setState(() => validateLength = val));
}
return val
? null
: translate('Too short, at least 6 characters.');
},
),
TextFormField(
obscureText: true,
keyboardType: TextInputType.visiblePassword,
decoration: InputDecoration(
labelText: translate('Confirmation'),
),
controller: p1,
validator: (v) {
if (v == null) return null;
final val = p0.text == v;
if (validateSame != val) {
Future.delayed(Duration(microseconds: 1),
() => setState(() => validateSame = val));
}
return val
? null
: translate('The confirmation is not identical.');
},
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton.icon(
icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")),
onPressed: close,
),
ElevatedButton.icon(
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed:
(validateLength && validateSame) ? submit : null,
),
],
).paddingOnly(top: 20)
],
content: Form(
autovalidateMode: AutovalidateMode.onUserInteraction,
child: Column(mainAxisSize: MainAxisSize.min, children: [
TextFormField(
autofocus: true,
obscureText: true,
keyboardType: TextInputType.visiblePassword,
decoration: InputDecoration(
labelText: translate('Password'),
),
controller: p0,
validator: (v) {
if (v == null) return null;
final val = v.trim().length > 5;
if (validateLength != val) {
// use delay to make setState success
Future.delayed(Duration(microseconds: 1),
() => setState(() => validateLength = val));
}
return val
? null
: translate('Too short, at least 6 characters.');
},
),
),
],
),
TextFormField(
obscureText: true,
keyboardType: TextInputType.visiblePassword,
decoration: InputDecoration(
labelText: translate('Confirmation'),
),
controller: p1,
validator: (v) {
if (v == null) return null;
final val = p0.text == v;
if (validateSame != val) {
Future.delayed(Duration(microseconds: 1),
() => setState(() => validateSame = val));
}
return val
? null
: translate('The confirmation is not identical.');
},
),
])),
onCancel: close,
onSubmit: (validateLength && validateSame) ? submit : null,
actions: [
dialogButton(
'Cancel',
icon: Icon(Icons.close_rounded),
onPressed: close,
isOutline: true,
),
dialogButton(
'OK',
icon: Icon(Icons.done_rounded),
onPressed: (validateLength && validateSame) ? submit : null,
),
],
);
});
}
@ -233,22 +216,20 @@ void enterPasswordDialog(String id, OverlayDialogManager dialogManager) async {
}
},
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton.icon(
icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")),
onPressed: close,
),
ElevatedButton.icon(
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit,
),
],
).paddingOnly(top: 20)
]),
actions: [
dialogButton(
'Cancel',
icon: Icon(Icons.close_rounded),
onPressed: cancel,
isOutline: true,
),
dialogButton(
'OK',
icon: Icon(Icons.done_rounded),
onPressed: submit,
),
],
onSubmit: submit,
onCancel: cancel,
);

View File

@ -595,9 +595,10 @@ class FileModel extends ChangeNotifier {
final count = entries.length > 1 ? "${i + 1}/${entries.length}" : "";
content = "$dirShow\n\n${entries[i].path}".trim();
final confirm = await showRemoveDialog(
count.isEmpty ? title : "$title ($count)",
content,
item.isDirectory);
count.isEmpty ? title : "$title ($count)",
content,
item.isDirectory,
);
try {
if (confirm == true) {
sendRemoveFile(entries[i].path, i, items.isLocal!);
@ -647,7 +648,7 @@ class FileModel extends ChangeNotifier {
],
),
contentBoxConstraints:
BoxConstraints(minHeight: 80, minWidth: 400, maxWidth: 400),
BoxConstraints(minHeight: 100, minWidth: 400, maxWidth: 400),
content: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -673,24 +674,22 @@ class FileModel extends ChangeNotifier {
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)
: const SizedBox.shrink()
],
),
actions: [
dialogButton(
"Cancel",
icon: Icon(Icons.close_rounded),
onPressed: cancel,
isOutline: true,
),
dialogButton(
"OK",
icon: Icon(Icons.done_rounded),
onPressed: submit,
),
],
onSubmit: submit,
onCancel: cancel,
);