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
flutter/lib

@ -224,7 +224,20 @@ class MyTheme {
), ),
shape: MaterialStateProperty.all<RoundedRectangleBorder>( shape: MaterialStateProperty.all<RoundedRectangleBorder>(
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, splashColor: Colors.transparent,
highlightColor: Colors.transparent, highlightColor: Colors.transparent,
splashFactory: isDesktop ? NoSplash.splashFactory : null, splashFactory: isDesktop ? NoSplash.splashFactory : null,
outlinedButtonTheme: OutlinedButtonThemeData(
style:
OutlinedButton.styleFrom(side: BorderSide(color: Colors.white38))),
textButtonTheme: isDesktop textButtonTheme: isDesktop
? TextButtonThemeData( ? TextButtonThemeData(
style: ButtonStyle( style: ButtonStyle(
@ -318,7 +328,23 @@ class MyTheme {
), ),
shape: MaterialStateProperty.all<RoundedRectangleBorder>( shape: MaterialStateProperty.all<RoundedRectangleBorder>(
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, Widget dialogButton(String text,
{required VoidCallback? onPressed, {required VoidCallback? onPressed,
bool isOutline = false, bool isOutline = false,
Widget? icon,
TextStyle? style, TextStyle? style,
ButtonStyle? buttonStyle}) { ButtonStyle? buttonStyle}) {
if (isDesktop) { if (isDesktop) {
if (isOutline) { if (isOutline) {
return OutlinedButton( return icon == null
? OutlinedButton(
onPressed: onPressed, onPressed: onPressed,
child: Text(translate(text), style: style), child: Text(translate(text), style: style),
)
: OutlinedButton.icon(
icon: icon,
onPressed: onPressed,
label: Text(translate(text), style: style),
); );
} else { } else {
return ElevatedButton( return icon == null
? ElevatedButton(
style: ElevatedButton.styleFrom(elevation: 0).merge(buttonStyle), style: ElevatedButton.styleFrom(elevation: 0).merge(buttonStyle),
onPressed: onPressed, onPressed: onPressed,
child: Text(translate(text), style: style), 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 { } else {
@ -1845,7 +1885,8 @@ Widget dialogButton(String text,
child: Text( child: Text(
translate(text), translate(text),
style: style, style: style,
)); ),
);
} }
} }

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

@ -988,8 +988,6 @@ class _FileManagerPageState extends State<FileManagerPage>
), ),
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [
Column(
children: [ children: [
TextFormField( TextFormField(
decoration: InputDecoration( decoration: InputDecoration(
@ -1000,26 +998,21 @@ class _FileManagerPageState extends State<FileManagerPage>
controller: name, controller: name,
autofocus: true, 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), icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit, onPressed: submit,
), ),
], ],
).paddingOnly(top: 20)
],
),
],
),
onSubmit: submit, onSubmit: submit,
onCancel: cancel, onCancel: cancel,
); );

@ -28,27 +28,21 @@ void showRestartRemoteDevice(
Icon(Icons.warning_rounded, color: Colors.redAccent, size: 28), Icon(Icons.warning_rounded, color: Colors.redAccent, size: 28),
Text(translate("Restart Remote Device")).paddingOnly(left: 10), Text(translate("Restart Remote Device")).paddingOnly(left: 10),
]), ]),
content: Column( content: Text(
children: [
Text(
"${translate('Are you sure you want to restart')} \n${pi.username}@${pi.hostname}($id) ?"), "${translate('Are you sure you want to restart')} \n${pi.username}@${pi.hostname}($id) ?"),
Row( actions: [
mainAxisAlignment: MainAxisAlignment.spaceBetween, dialogButton(
children: [ "Cancel",
ElevatedButton.icon(
icon: Icon(Icons.close_rounded), icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")),
onPressed: close, onPressed: close,
isOutline: true,
), ),
ElevatedButton.icon( dialogButton(
"OK",
icon: Icon(Icons.done_rounded), icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: () => close(true), onPressed: () => close(true),
), ),
], ],
).paddingOnly(top: 20)
],
),
onCancel: close, onCancel: close,
onSubmit: () => close(true), onSubmit: () => close(true),
)); ));
@ -82,13 +76,9 @@ void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
Text(translate('Set your own password')).paddingOnly(left: 10), Text(translate('Set your own password')).paddingOnly(left: 10),
], ],
), ),
content: Column( content: Form(
children: [
Form(
autovalidateMode: AutovalidateMode.onUserInteraction, autovalidateMode: AutovalidateMode.onUserInteraction,
child: Column( child: Column(mainAxisSize: MainAxisSize.min, children: [
mainAxisSize: MainAxisSize.min,
children: [
TextFormField( TextFormField(
autofocus: true, autofocus: true,
obscureText: true, obscureText: true,
@ -129,29 +119,22 @@ void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
: translate('The confirmation is not identical.'); : 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, onCancel: close,
onSubmit: (validateLength && validateSame) ? submit : null, 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, actions: [
children: [ dialogButton(
ElevatedButton.icon( 'Cancel',
icon: Icon(Icons.close_rounded), icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")), onPressed: cancel,
onPressed: close, isOutline: true,
), ),
ElevatedButton.icon( dialogButton(
'OK',
icon: Icon(Icons.done_rounded), icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit, onPressed: submit,
), ),
], ],
).paddingOnly(top: 20)
]),
onSubmit: submit, onSubmit: submit,
onCancel: cancel, onCancel: cancel,
); );

@ -597,7 +597,8 @@ class FileModel extends ChangeNotifier {
final confirm = await showRemoveDialog( final confirm = await showRemoveDialog(
count.isEmpty ? title : "$title ($count)", count.isEmpty ? title : "$title ($count)",
content, content,
item.isDirectory); item.isDirectory,
);
try { try {
if (confirm == true) { if (confirm == true) {
sendRemoveFile(entries[i].path, i, items.isLocal!); sendRemoveFile(entries[i].path, i, items.isLocal!);
@ -647,7 +648,7 @@ class FileModel extends ChangeNotifier {
], ],
), ),
contentBoxConstraints: contentBoxConstraints:
BoxConstraints(minHeight: 80, minWidth: 400, maxWidth: 400), BoxConstraints(minHeight: 100, minWidth: 400, maxWidth: 400),
content: Column( content: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -673,24 +674,22 @@ class FileModel extends ChangeNotifier {
setState(() => removeCheckboxRemember = v); setState(() => removeCheckboxRemember = v);
}, },
) )
: const SizedBox.shrink(), : const SizedBox.shrink()
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), icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit, onPressed: submit,
), ),
], ],
).paddingOnly(top: 20)
],
),
onSubmit: submit, onSubmit: submit,
onCancel: cancel, onCancel: cancel,
); );