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,19 +1850,33 @@ class ServerConfig {
Widget dialogButton(String text,
{required VoidCallback? onPressed,
bool isOutline = false,
Widget? icon,
TextStyle? style,
ButtonStyle? buttonStyle}) {
if (isDesktop) {
if (isOutline) {
return OutlinedButton(
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(
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 {
@ -1845,7 +1885,8 @@ Widget dialogButton(String text,
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(
actions: [
dialogButton(
"Cancel",
icon: Icon(Icons.close_rounded),
onPressed: close,
isOutline: true,
),
dialogButton(
"OK",
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit,
),
],
).paddingOnly(top: 20)
],
),
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(
content: SizedBox.shrink(),
actions: [
dialogButton(
"Cancel",
icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")),
onPressed: close,
isOutline: true,
),
ElevatedButton.icon(
dialogButton(
"OK",
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit,
),
],
).paddingOnly(top: 20)
],
),
onSubmit: submit,
onCancel: close,
);

View File

@ -988,8 +988,6 @@ class _FileManagerPageState extends State<FileManagerPage>
),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Column(
children: [
TextFormField(
decoration: InputDecoration(
@ -1000,26 +998,21 @@ class _FileManagerPageState extends State<FileManagerPage>
controller: name,
autofocus: true,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
ElevatedButton.icon(
icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")),
onPressed: cancel,
],
),
ElevatedButton.icon(
actions: [
dialogButton(
"Cancel",
icon: Icon(Icons.close_rounded),
onPressed: cancel,
isOutline: true,
),
dialogButton(
"Ok",
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit,
),
],
).paddingOnly(top: 20)
],
),
],
),
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(
content: Text(
"${translate('Are you sure you want to restart')} \n${pi.username}@${pi.hostname}($id) ?"),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton.icon(
actions: [
dialogButton(
"Cancel",
icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")),
onPressed: close,
isOutline: true,
),
ElevatedButton.icon(
dialogButton(
"OK",
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: () => close(true),
),
],
).paddingOnly(top: 20)
],
),
onCancel: close,
onSubmit: () => close(true),
));
@ -82,13 +76,9 @@ void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
Text(translate('Set your own password')).paddingOnly(left: 10),
],
),
content: Column(
children: [
Form(
content: Form(
autovalidateMode: AutovalidateMode.onUserInteraction,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
child: Column(mainAxisSize: MainAxisSize.min, children: [
TextFormField(
autofocus: true,
obscureText: true,
@ -129,29 +119,22 @@ void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
: 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)
],
),
),
],
),
])),
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(
]),
actions: [
dialogButton(
'Cancel',
icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")),
onPressed: close,
onPressed: cancel,
isOutline: true,
),
ElevatedButton.icon(
dialogButton(
'OK',
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit,
),
],
).paddingOnly(top: 20)
]),
onSubmit: submit,
onCancel: cancel,
);

View File

@ -597,7 +597,8 @@ class FileModel extends ChangeNotifier {
final confirm = await showRemoveDialog(
count.isEmpty ? title : "$title ($count)",
content,
item.isDirectory);
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,
: const SizedBox.shrink()
],
),
ElevatedButton.icon(
actions: [
dialogButton(
"Cancel",
icon: Icon(Icons.close_rounded),
onPressed: cancel,
isOutline: true,
),
dialogButton(
"OK",
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit,
),
],
).paddingOnly(top: 20)
],
),
onSubmit: submit,
onCancel: cancel,
);