From 55831948f8361742eb0473adfd0c9b1d805437f0 Mon Sep 17 00:00:00 2001 From: NicKoehler Date: Wed, 1 Mar 2023 16:35:51 +0100 Subject: [PATCH] prefere MaterialStatePropertyAll to MaterialStateProperty.all and other fixes --- flutter/lib/common.dart | 22 ++--- .../lib/desktop/widgets/remote_menubar.dart | 93 ++++++++++--------- flutter/lib/mobile/pages/server_page.dart | 2 +- flutter/lib/models/file_model.dart | 27 ++++-- 4 files changed, 82 insertions(+), 62 deletions(-) diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 47850fdb1..eeae0972b 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -209,7 +209,7 @@ class MyTheme { ? TextButtonThemeData( style: ButtonStyle( splashFactory: NoSplash.splashFactory, - shape: MaterialStateProperty.all( + shape: MaterialStatePropertyAll( RoundedRectangleBorder( borderRadius: BorderRadius.circular(18.0), ), @@ -219,10 +219,10 @@ class MyTheme { : null, elevatedButtonTheme: ElevatedButtonThemeData( style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: MaterialStatePropertyAll( MyTheme.accent, ), - shape: MaterialStateProperty.all( + shape: MaterialStatePropertyAll( RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0), ), @@ -231,11 +231,11 @@ class MyTheme { ), outlinedButtonTheme: OutlinedButtonThemeData( style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: MaterialStatePropertyAll( Color(0xFFEEEEEE), ), - foregroundColor: MaterialStateProperty.all(Colors.black87), - shape: MaterialStateProperty.all( + foregroundColor: MaterialStatePropertyAll(Colors.black87), + shape: MaterialStatePropertyAll( RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0), ), @@ -313,7 +313,7 @@ class MyTheme { ? TextButtonThemeData( style: ButtonStyle( splashFactory: NoSplash.splashFactory, - shape: MaterialStateProperty.all( + shape: MaterialStatePropertyAll( RoundedRectangleBorder( borderRadius: BorderRadius.circular(18.0), ), @@ -323,10 +323,10 @@ class MyTheme { : null, elevatedButtonTheme: ElevatedButtonThemeData( style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: MaterialStatePropertyAll( MyTheme.accent, ), - shape: MaterialStateProperty.all( + shape: MaterialStatePropertyAll( RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0), ), @@ -341,8 +341,8 @@ class MyTheme { side: MaterialStatePropertyAll( BorderSide(color: Colors.white12, width: 0.5), ), - foregroundColor: MaterialStateProperty.all(Colors.white70), - shape: MaterialStateProperty.all( + foregroundColor: MaterialStatePropertyAll(Colors.white70), + shape: MaterialStatePropertyAll( RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0), ), diff --git a/flutter/lib/desktop/widgets/remote_menubar.dart b/flutter/lib/desktop/widgets/remote_menubar.dart index 90b48160b..49c56466c 100644 --- a/flutter/lib/desktop/widgets/remote_menubar.dart +++ b/flutter/lib/desktop/widgets/remote_menubar.dart @@ -411,17 +411,18 @@ class _RemoteMenubarState extends State { borderRadius: BorderRadius.all(Radius.circular(10)), ), child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Theme( - data: themeData(), - child: MenuBar( - children: [ - SizedBox(width: _MenubarTheme.buttonHMargin), - ...menubarItems, - SizedBox(width: _MenubarTheme.buttonHMargin) - ], - ), - )), + scrollDirection: Axis.horizontal, + child: Theme( + data: themeData(), + child: MenuBar( + children: [ + SizedBox(width: _MenubarTheme.buttonHMargin), + ...menubarItems, + SizedBox(width: _MenubarTheme.buttonHMargin) + ], + ), + ), + ), ), _buildDraggableShowHide(context), ], @@ -431,10 +432,13 @@ class _RemoteMenubarState extends State { ThemeData themeData() { return Theme.of(context).copyWith( menuButtonTheme: MenuButtonThemeData( - style: ButtonStyle( - minimumSize: MaterialStatePropertyAll(Size(64, 36)), - textStyle: MaterialStatePropertyAll( - TextStyle(fontWeight: FontWeight.normal)))), + style: ButtonStyle( + minimumSize: MaterialStatePropertyAll(Size(64, 36)), + textStyle: MaterialStatePropertyAll( + TextStyle(fontWeight: FontWeight.normal), + ), + ), + ), dividerTheme: DividerThemeData(space: 4), ); } @@ -662,37 +666,38 @@ class _ControlMenu extends StatelessWidget { Text(translate('OS Password')).paddingOnly(left: 10), ], ), - content: Column(mainAxisSize: MainAxisSize.min, children: [ - PasswordWidget(controller: controller), - CheckboxListTile( - contentPadding: const EdgeInsets.all(0), - dense: true, - controlAffinity: ListTileControlAffinity.leading, - title: Text( - translate('Auto Login'), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + PasswordWidget(controller: controller), + CheckboxListTile( + contentPadding: const EdgeInsets.all(0), + dense: true, + controlAffinity: ListTileControlAffinity.leading, + title: Text( + translate('Auto Login'), + ), + value: autoLogin, + onChanged: (v) { + if (v == null) return; + setState(() => autoLogin = v); + }, ), - value: autoLogin, - onChanged: (v) { - if (v == null) return; - setState(() => autoLogin = v); - }, + ], + ), + actions: [ + dialogButton( + "Cancel", + icon: Icon(Icons.close_rounded), + onPressed: close, + isOutline: true, ), - 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) - ]), + dialogButton( + "OK", + icon: Icon(Icons.done_rounded), + onPressed: submit, + ), + ], onSubmit: submit, onCancel: close, ); diff --git a/flutter/lib/mobile/pages/server_page.dart b/flutter/lib/mobile/pages/server_page.dart index abccdf683..1a77b8983 100644 --- a/flutter/lib/mobile/pages/server_page.dart +++ b/flutter/lib/mobile/pages/server_page.dart @@ -427,7 +427,7 @@ class ConnectionManager extends StatelessWidget { ? ElevatedButton.icon( style: ButtonStyle( backgroundColor: - MaterialStateProperty.all(Colors.red)), + MaterialStatePropertyAll(Colors.red)), icon: const Icon(Icons.close), onPressed: () { bind.cmCloseConnection(connId: client.id); diff --git a/flutter/lib/models/file_model.dart b/flutter/lib/models/file_model.dart index a899f4106..56c9339f3 100644 --- a/flutter/lib/models/file_model.dart +++ b/flutter/lib/models/file_model.dart @@ -708,9 +708,10 @@ class FileModel extends ChangeNotifier { return CustomAlertDialog( title: Row( children: [ - const Icon(Icons.warning, color: Colors.red), - const SizedBox(width: 20), - Text(title) + const Icon(Icons.warning_rounded, color: Colors.red), + Text(title).paddingOnly( + left: 10, + ), ], ), contentBoxConstraints: @@ -740,9 +741,23 @@ class FileModel extends ChangeNotifier { : const SizedBox.shrink() ]), actions: [ - dialogButton("Cancel", onPressed: cancel, isOutline: true), - dialogButton("Skip", onPressed: () => close(null), isOutline: true), - dialogButton("OK", onPressed: submit), + dialogButton( + "Cancel", + icon: Icon(Icons.close_rounded), + onPressed: cancel, + isOutline: true, + ), + dialogButton( + "Skip", + icon: Icon(Icons.navigate_next_rounded), + onPressed: () => close(null), + isOutline: true, + ), + dialogButton( + "OK", + icon: Icon(Icons.done_rounded), + onPressed: submit, + ), ], onSubmit: submit, onCancel: cancel,