From e21502e6a54faecf036a4f8e0be2b9abefc67f15 Mon Sep 17 00:00:00 2001 From: dignow Date: Sun, 9 Jul 2023 03:53:07 +0800 Subject: [PATCH 1/4] refact, remote toolbar, menu Signed-off-by: dignow --- flutter/lib/common.dart | 4 +++ .../lib/desktop/widgets/remote_toolbar.dart | 27 +++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index ca4969522..b46b7a439 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -176,6 +176,10 @@ class MyTheme { static const Color dark = Colors.black87; static const Color button = Color(0xFF2C8CFF); static const Color hoverBorder = Color(0xFF999999); + static const Color bordDark = Colors.white24; + static const Color bordLight = Colors.black26; + static const Color dividerDark = Colors.white38; + static const Color dividerLight = Colors.black38; // ListTile static const ListTileThemeData listTileTheme = ListTileThemeData( diff --git a/flutter/lib/desktop/widgets/remote_toolbar.dart b/flutter/lib/desktop/widgets/remote_toolbar.dart index f332f31dd..b25118c40 100644 --- a/flutter/lib/desktop/widgets/remote_toolbar.dart +++ b/flutter/lib/desktop/widgets/remote_toolbar.dart @@ -1,5 +1,7 @@ import 'dart:convert'; import 'dart:ui' as ui; +import 'dart:async'; +import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -111,6 +113,13 @@ class _ToolbarTheme { static const double buttonVMargin = 6; static const double iconRadius = 8; static const double elevation = 3; + + static const Color bordDark = MyTheme.bordDark; + static const Color bordLight = MyTheme.bordLight; + + static const Color dividerDark = MyTheme.dividerDark; + static const Color dividerLight = MyTheme.dividerLight; + static const double dividerSpaceToAction = 8; } typedef DismissFunc = void Function(); @@ -477,7 +486,12 @@ class _RemoteToolbarState extends State { ), ), ), - dividerTheme: DividerThemeData(space: 4), + dividerTheme: DividerThemeData( + space: _ToolbarTheme.dividerSpaceToAction, + color: MyTheme.currentThemeMode() == ThemeMode.light + ? _ToolbarTheme.dividerLight + : _ToolbarTheme.dividerDark, + ), menuBarTheme: MenuBarThemeData( style: MenuStyle( padding: MaterialStatePropertyAll(EdgeInsets.zero), @@ -1635,7 +1649,16 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> { width: _ToolbarTheme.buttonSize, height: _ToolbarTheme.buttonSize, child: SubmenuButton( - menuStyle: widget.menuStyle, + menuStyle: widget.menuStyle ?? + MenuStyle( + side: MaterialStateProperty.all(BorderSide( + width: 1, + color: MyTheme.currentThemeMode() == ThemeMode.light + ? _ToolbarTheme.bordLight + : _ToolbarTheme.bordDark, + )), + visualDensity: VisualDensity.comfortable, + ), style: ButtonStyle( backgroundColor: MaterialStatePropertyAll(Colors.transparent), padding: MaterialStatePropertyAll(EdgeInsets.zero), From 3148ab214a6730e628f1c60955e0a29c33ba8289 Mon Sep 17 00:00:00 2001 From: dignow Date: Sun, 9 Jul 2023 12:48:28 +0800 Subject: [PATCH 2/4] refact, remote toolbar menu, windows Signed-off-by: dignow --- .../lib/desktop/widgets/remote_toolbar.dart | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/flutter/lib/desktop/widgets/remote_toolbar.dart b/flutter/lib/desktop/widgets/remote_toolbar.dart index b25118c40..badf04445 100644 --- a/flutter/lib/desktop/widgets/remote_toolbar.dart +++ b/flutter/lib/desktop/widgets/remote_toolbar.dart @@ -120,6 +120,10 @@ class _ToolbarTheme { static const Color dividerDark = MyTheme.dividerDark; static const Color dividerLight = MyTheme.dividerLight; static const double dividerSpaceToAction = 8; + + static const double menuBorderRadius = 5.0; + static EdgeInsets menuPadding = Platform.isWindows ? EdgeInsets.fromLTRB(4, 12, 4, 12) : EdgeInsets.fromLTRB(6, 18, 6, 18); + static const double menuButtonBorderRadius = 3.0; } typedef DismissFunc = void Function(); @@ -484,6 +488,8 @@ class _RemoteToolbarState extends State { textStyle: MaterialStatePropertyAll( TextStyle(fontWeight: FontWeight.normal), ), + shape: MaterialStatePropertyAll(RoundedRectangleBorder( + borderRadius: BorderRadius.circular(_ToolbarTheme.menuButtonBorderRadius))), ), ), dividerTheme: DividerThemeData( @@ -1651,14 +1657,15 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> { child: SubmenuButton( menuStyle: widget.menuStyle ?? MenuStyle( - side: MaterialStateProperty.all(BorderSide( - width: 1, - color: MyTheme.currentThemeMode() == ThemeMode.light - ? _ToolbarTheme.bordLight - : _ToolbarTheme.bordDark, - )), - visualDensity: VisualDensity.comfortable, - ), + side: MaterialStateProperty.all(BorderSide( + width: 1, + color: MyTheme.currentThemeMode() == ThemeMode.light + ? _ToolbarTheme.bordLight + : _ToolbarTheme.bordDark, + )), + shape: MaterialStatePropertyAll(RoundedRectangleBorder( + borderRadius: BorderRadius.circular(_ToolbarTheme.menuBorderRadius))), + padding: MaterialStateProperty.all(_ToolbarTheme.menuPadding)), style: ButtonStyle( backgroundColor: MaterialStatePropertyAll(Colors.transparent), padding: MaterialStatePropertyAll(EdgeInsets.zero), From 317bc21a1bd0d50c40393727ab4ab41bd522805b Mon Sep 17 00:00:00 2001 From: dignow Date: Sun, 9 Jul 2023 14:06:19 +0800 Subject: [PATCH 3/4] refact, remote toolbar menu, macos Signed-off-by: dignow --- flutter/lib/desktop/widgets/remote_toolbar.dart | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/flutter/lib/desktop/widgets/remote_toolbar.dart b/flutter/lib/desktop/widgets/remote_toolbar.dart index badf04445..60d5a66c6 100644 --- a/flutter/lib/desktop/widgets/remote_toolbar.dart +++ b/flutter/lib/desktop/widgets/remote_toolbar.dart @@ -119,10 +119,12 @@ class _ToolbarTheme { static const Color dividerDark = MyTheme.dividerDark; static const Color dividerLight = MyTheme.dividerLight; - static const double dividerSpaceToAction = 8; + static double dividerSpaceToAction = Platform.isWindows ? 8 : 14; - static const double menuBorderRadius = 5.0; - static EdgeInsets menuPadding = Platform.isWindows ? EdgeInsets.fromLTRB(4, 12, 4, 12) : EdgeInsets.fromLTRB(6, 18, 6, 18); + static double menuBorderRadius = Platform.isWindows ? 5.0 : 7.0; + static EdgeInsets menuPadding = Platform.isWindows + ? EdgeInsets.fromLTRB(4, 12, 4, 12) + : EdgeInsets.fromLTRB(6, 14, 6, 14); static const double menuButtonBorderRadius = 3.0; } @@ -489,7 +491,8 @@ class _RemoteToolbarState extends State { TextStyle(fontWeight: FontWeight.normal), ), shape: MaterialStatePropertyAll(RoundedRectangleBorder( - borderRadius: BorderRadius.circular(_ToolbarTheme.menuButtonBorderRadius))), + borderRadius: + BorderRadius.circular(_ToolbarTheme.menuButtonBorderRadius))), ), ), dividerTheme: DividerThemeData( @@ -1664,8 +1667,10 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> { : _ToolbarTheme.bordDark, )), shape: MaterialStatePropertyAll(RoundedRectangleBorder( - borderRadius: BorderRadius.circular(_ToolbarTheme.menuBorderRadius))), - padding: MaterialStateProperty.all(_ToolbarTheme.menuPadding)), + borderRadius: BorderRadius.circular( + _ToolbarTheme.menuBorderRadius))), + padding: + MaterialStateProperty.all(_ToolbarTheme.menuPadding)), style: ButtonStyle( backgroundColor: MaterialStatePropertyAll(Colors.transparent), padding: MaterialStatePropertyAll(EdgeInsets.zero), From 02c9d3fe2c3b68f63c433b38f38f3ae101f1d6f3 Mon Sep 17 00:00:00 2001 From: dignow Date: Sun, 9 Jul 2023 14:16:52 +0800 Subject: [PATCH 4/4] refact, remote toolbar menu, sub menu Signed-off-by: dignow --- .../lib/desktop/widgets/remote_toolbar.dart | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/flutter/lib/desktop/widgets/remote_toolbar.dart b/flutter/lib/desktop/widgets/remote_toolbar.dart index 60d5a66c6..df5530bfc 100644 --- a/flutter/lib/desktop/widgets/remote_toolbar.dart +++ b/flutter/lib/desktop/widgets/remote_toolbar.dart @@ -126,6 +126,23 @@ class _ToolbarTheme { ? EdgeInsets.fromLTRB(4, 12, 4, 12) : EdgeInsets.fromLTRB(6, 14, 6, 14); static const double menuButtonBorderRadius = 3.0; + + static final defaultMenuStyle = MenuStyle( + side: MaterialStateProperty.all(BorderSide( + width: 1, + color: MyTheme.currentThemeMode() == ThemeMode.light + ? _ToolbarTheme.bordLight + : _ToolbarTheme.bordDark, + )), + shape: MaterialStatePropertyAll(RoundedRectangleBorder( + borderRadius: BorderRadius.circular(_ToolbarTheme.menuBorderRadius))), + padding: MaterialStateProperty.all(_ToolbarTheme.menuPadding), + ); + static final defaultMenuButtonStyle = ButtonStyle( + backgroundColor: MaterialStatePropertyAll(Colors.transparent), + padding: MaterialStatePropertyAll(EdgeInsets.zero), + overlayColor: MaterialStatePropertyAll(Colors.transparent), + ); } typedef DismissFunc = void Function(); @@ -1658,23 +1675,8 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> { width: _ToolbarTheme.buttonSize, height: _ToolbarTheme.buttonSize, child: SubmenuButton( - menuStyle: widget.menuStyle ?? - MenuStyle( - side: MaterialStateProperty.all(BorderSide( - width: 1, - color: MyTheme.currentThemeMode() == ThemeMode.light - ? _ToolbarTheme.bordLight - : _ToolbarTheme.bordDark, - )), - shape: MaterialStatePropertyAll(RoundedRectangleBorder( - borderRadius: BorderRadius.circular( - _ToolbarTheme.menuBorderRadius))), - padding: - MaterialStateProperty.all(_ToolbarTheme.menuPadding)), - style: ButtonStyle( - backgroundColor: MaterialStatePropertyAll(Colors.transparent), - padding: MaterialStatePropertyAll(EdgeInsets.zero), - overlayColor: MaterialStatePropertyAll(Colors.transparent)), + menuStyle: widget.menuStyle ?? _ToolbarTheme.defaultMenuStyle, + style: _ToolbarTheme.defaultMenuButtonStyle, onHover: (value) => setState(() { hover = value; }), @@ -1716,6 +1718,7 @@ class _SubmenuButton extends StatelessWidget { child: child, menuChildren: menuChildren.map((e) => _buildPointerTrackWidget(e, ffi)).toList(), + menuStyle: _ToolbarTheme.defaultMenuStyle, ); } }