Merge pull request #3608 from 21pages/fix

fix remote menubar theme
This commit is contained in:
RustDesk 2023-03-11 20:15:58 +08:00 committed by GitHub
commit 13e18728d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 13 deletions

View File

@ -111,32 +111,39 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
required this.border, required this.border,
required this.border2, required this.border2,
required this.highlight, required this.highlight,
required this.drag_indicator,
}); });
final Color? border; final Color? border;
final Color? border2; final Color? border2;
final Color? highlight; final Color? highlight;
final Color? drag_indicator;
static const light = ColorThemeExtension( static final light = ColorThemeExtension(
border: Color(0xFFCCCCCC), border: Color(0xFFCCCCCC),
border2: Color(0xFFBBBBBB), border2: Color(0xFFBBBBBB),
highlight: Color(0xFFE5E5E5), highlight: Color(0xFFE5E5E5),
drag_indicator: Colors.grey[800],
); );
static const dark = ColorThemeExtension( static final dark = ColorThemeExtension(
border: Color(0xFF555555), border: Color(0xFF555555),
border2: Color(0xFFE5E5E5), border2: Color(0xFFE5E5E5),
highlight: Color(0xFF3F3F3F), highlight: Color(0xFF3F3F3F),
drag_indicator: Colors.grey,
); );
@override @override
ThemeExtension<ColorThemeExtension> copyWith( ThemeExtension<ColorThemeExtension> copyWith(
{Color? border, Color? border2, Color? highlight}) { {Color? border,
Color? border2,
Color? highlight,
Color? drag_indicator}) {
return ColorThemeExtension( return ColorThemeExtension(
border: border ?? this.border, border: border ?? this.border,
border2: border2 ?? this.border2, border2: border2 ?? this.border2,
highlight: highlight ?? this.highlight, highlight: highlight ?? this.highlight,
); drag_indicator: drag_indicator ?? this.drag_indicator);
} }
@override @override
@ -149,6 +156,7 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
border: Color.lerp(border, other.border, t), border: Color.lerp(border, other.border, t),
border2: Color.lerp(border2, other.border2, t), border2: Color.lerp(border2, other.border2, t),
highlight: Color.lerp(highlight, other.highlight, t), highlight: Color.lerp(highlight, other.highlight, t),
drag_indicator: Color.lerp(drag_indicator, other.drag_indicator, t),
); );
} }
} }
@ -252,6 +260,9 @@ class MyTheme {
), ),
), ),
), ),
menuBarTheme: MenuBarThemeData(
style:
MenuStyle(backgroundColor: MaterialStatePropertyAll(Colors.white))),
colorScheme: ColorScheme.light( colorScheme: ColorScheme.light(
primary: Colors.blue, secondary: accent, background: grayBg), primary: Colors.blue, secondary: accent, background: grayBg),
).copyWith( ).copyWith(
@ -352,6 +363,9 @@ class MyTheme {
), ),
), ),
), ),
menuBarTheme: MenuBarThemeData(
style: MenuStyle(
backgroundColor: MaterialStatePropertyAll(Color(0xFF121212)))),
colorScheme: ColorScheme.dark( colorScheme: ColorScheme.dark(
primary: Colors.blue, primary: Colors.blue,
secondary: accent, secondary: accent,

View File

@ -408,7 +408,12 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
children: [ children: [
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)), borderRadius: BorderRadius.all(Radius.circular(4.0)),
color: Theme.of(context)
.menuBarTheme
.style
?.backgroundColor
?.resolve(MaterialState.values.toSet()),
), ),
child: SingleChildScrollView( child: SingleChildScrollView(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
@ -416,9 +421,9 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
data: themeData(), data: themeData(),
child: Row( child: Row(
children: [ children: [
SizedBox(width: _MenubarTheme.buttonHMargin), SizedBox(width: _MenubarTheme.buttonHMargin * 2),
...menubarItems, ...menubarItems,
SizedBox(width: _MenubarTheme.buttonHMargin) SizedBox(width: _MenubarTheme.buttonHMargin * 2)
], ],
), ),
), ),
@ -441,7 +446,13 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
), ),
dividerTheme: DividerThemeData(space: 4), dividerTheme: DividerThemeData(space: 4),
menuBarTheme: MenuBarThemeData( menuBarTheme: MenuBarThemeData(
style: MenuStyle(padding: MaterialStatePropertyAll(EdgeInsets.zero))), style: MenuStyle(
padding: MaterialStatePropertyAll(EdgeInsets.zero),
elevation: MaterialStatePropertyAll(0),
shape: MaterialStatePropertyAll(BeveledRectangleBorder()),
).copyWith(
backgroundColor:
Theme.of(context).menuBarTheme.style?.backgroundColor)),
); );
} }
} }
@ -1869,6 +1880,7 @@ class _IconMenuButtonState extends State<_IconMenuButton> {
height: _MenubarTheme.buttonSize, height: _MenubarTheme.buttonSize,
child: MenuItemButton( child: MenuItemButton(
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStatePropertyAll(Colors.transparent),
padding: MaterialStatePropertyAll(EdgeInsets.zero), padding: MaterialStatePropertyAll(EdgeInsets.zero),
overlayColor: MaterialStatePropertyAll(Colors.transparent)), overlayColor: MaterialStatePropertyAll(Colors.transparent)),
onHover: (value) => setState(() { onHover: (value) => setState(() {
@ -1940,6 +1952,7 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> {
child: SubmenuButton( child: SubmenuButton(
menuStyle: widget.menuStyle, menuStyle: widget.menuStyle,
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStatePropertyAll(Colors.transparent),
padding: MaterialStatePropertyAll(EdgeInsets.zero), padding: MaterialStatePropertyAll(EdgeInsets.zero),
overlayColor: MaterialStatePropertyAll(Colors.transparent)), overlayColor: MaterialStatePropertyAll(Colors.transparent)),
onHover: (value) => setState(() { onHover: (value) => setState(() {
@ -2100,7 +2113,7 @@ class _DraggableShowHideState extends State<_DraggableShowHide> {
child: Icon( child: Icon(
Icons.drag_indicator, Icons.drag_indicator,
size: 20, size: 20,
color: Colors.grey[800], color: MyTheme.color(context).drag_indicator,
), ),
feedback: widget, feedback: widget,
onDragStarted: (() { onDragStarted: (() {
@ -2152,7 +2165,11 @@ class _DraggableShowHideState extends State<_DraggableShowHide> {
data: TextButtonThemeData(style: buttonStyle), data: TextButtonThemeData(style: buttonStyle),
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Theme.of(context)
.menuBarTheme
.style
?.backgroundColor
?.resolve(MaterialState.values.toSet()),
borderRadius: BorderRadius.vertical( borderRadius: BorderRadius.vertical(
bottom: Radius.circular(5), bottom: Radius.circular(5),
), ),