Merge pull request #4926 from dignow/refact/remote_toolbar_menu

Refact/remote toolbar menu
This commit is contained in:
RustDesk 2023-07-09 15:03:31 +08:00 committed by GitHub
commit be4cc32e2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 6 deletions

View File

@ -176,6 +176,10 @@ class MyTheme {
static const Color dark = Colors.black87; static const Color dark = Colors.black87;
static const Color button = Color(0xFF2C8CFF); static const Color button = Color(0xFF2C8CFF);
static const Color hoverBorder = Color(0xFF999999); 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 // ListTile
static const ListTileThemeData listTileTheme = ListTileThemeData( static const ListTileThemeData listTileTheme = ListTileThemeData(

View File

@ -1,5 +1,7 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -111,6 +113,36 @@ class _ToolbarTheme {
static const double buttonVMargin = 6; static const double buttonVMargin = 6;
static const double iconRadius = 8; static const double iconRadius = 8;
static const double elevation = 3; 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 double dividerSpaceToAction = Platform.isWindows ? 8 : 14;
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;
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(); typedef DismissFunc = void Function();
@ -475,9 +507,17 @@ class _RemoteToolbarState extends State<RemoteToolbar> {
textStyle: MaterialStatePropertyAll( textStyle: MaterialStatePropertyAll(
TextStyle(fontWeight: FontWeight.normal), TextStyle(fontWeight: FontWeight.normal),
), ),
shape: MaterialStatePropertyAll(RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(_ToolbarTheme.menuButtonBorderRadius))),
), ),
), ),
dividerTheme: DividerThemeData(space: 4), dividerTheme: DividerThemeData(
space: _ToolbarTheme.dividerSpaceToAction,
color: MyTheme.currentThemeMode() == ThemeMode.light
? _ToolbarTheme.dividerLight
: _ToolbarTheme.dividerDark,
),
menuBarTheme: MenuBarThemeData( menuBarTheme: MenuBarThemeData(
style: MenuStyle( style: MenuStyle(
padding: MaterialStatePropertyAll(EdgeInsets.zero), padding: MaterialStatePropertyAll(EdgeInsets.zero),
@ -1635,11 +1675,8 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> {
width: _ToolbarTheme.buttonSize, width: _ToolbarTheme.buttonSize,
height: _ToolbarTheme.buttonSize, height: _ToolbarTheme.buttonSize,
child: SubmenuButton( child: SubmenuButton(
menuStyle: widget.menuStyle, menuStyle: widget.menuStyle ?? _ToolbarTheme.defaultMenuStyle,
style: ButtonStyle( style: _ToolbarTheme.defaultMenuButtonStyle,
backgroundColor: MaterialStatePropertyAll(Colors.transparent),
padding: MaterialStatePropertyAll(EdgeInsets.zero),
overlayColor: MaterialStatePropertyAll(Colors.transparent)),
onHover: (value) => setState(() { onHover: (value) => setState(() {
hover = value; hover = value;
}), }),
@ -1681,6 +1718,7 @@ class _SubmenuButton extends StatelessWidget {
child: child, child: child,
menuChildren: menuChildren:
menuChildren.map((e) => _buildPointerTrackWidget(e, ffi)).toList(), menuChildren.map((e) => _buildPointerTrackWidget(e, ffi)).toList(),
menuStyle: _ToolbarTheme.defaultMenuStyle,
); );
} }
} }