add popupMenuTheme (#6617)

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2023-12-04 22:34:54 -05:00 committed by GitHub
parent d11a3b9683
commit 00fe3a76c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 29 deletions

View file

@ -112,11 +112,6 @@ class _ToolbarTheme {
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 double dividerSpaceToAction = Platform.isWindows ? 8 : 14;
static double menuBorderRadius = Platform.isWindows ? 5.0 : 7.0;
@ -125,29 +120,34 @@ class _ToolbarTheme {
: EdgeInsets.fromLTRB(6, 14, 6, 14);
static const double menuButtonBorderRadius = 3.0;
static get borderColor =>
MyTheme.currentThemeMode() == ThemeMode.light ? bordLight : bordDark;
static Color borderColor(BuildContext context) =>
MyTheme.color(context).border3 ?? MyTheme.border;
static final defaultMenuStyle = MenuStyle(
side: MaterialStateProperty.all(BorderSide(
width: 1,
color: borderColor,
)),
shape: MaterialStatePropertyAll(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(_ToolbarTheme.menuBorderRadius))),
padding: MaterialStateProperty.all(_ToolbarTheme.menuPadding),
);
static Color? dividerColor(BuildContext context) =>
MyTheme.color(context).divider;
static MenuStyle defaultMenuStyle(BuildContext context) => MenuStyle(
side: MaterialStateProperty.all(BorderSide(
width: 1,
color: borderColor(context),
)),
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),
);
static Widget borderWrapper(Widget child, BorderRadius borderRadius) {
static Widget borderWrapper(
BuildContext context, Widget child, BorderRadius borderRadius) {
return Container(
decoration: BoxDecoration(
border: Border.all(
color: borderColor,
color: borderColor(context),
width: 1,
),
borderRadius: borderRadius,
@ -512,6 +512,7 @@ class _RemoteToolbarState extends State<RemoteToolbar> {
child: Theme(
data: themeData(),
child: _ToolbarTheme.borderWrapper(
context,
Row(
children: [
SizedBox(width: _ToolbarTheme.buttonHMargin * 2),
@ -543,9 +544,7 @@ class _RemoteToolbarState extends State<RemoteToolbar> {
),
dividerTheme: DividerThemeData(
space: _ToolbarTheme.dividerSpaceToAction,
color: MyTheme.currentThemeMode() == ThemeMode.light
? _ToolbarTheme.dividerLight
: _ToolbarTheme.dividerDark,
color: _ToolbarTheme.dividerColor(context),
),
menuBarTheme: MenuBarThemeData(
style: MenuStyle(
@ -2029,7 +2028,8 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> {
width: widget.width ?? _ToolbarTheme.buttonSize,
height: _ToolbarTheme.buttonSize,
child: SubmenuButton(
menuStyle: widget.menuStyle ?? _ToolbarTheme.defaultMenuStyle,
menuStyle:
widget.menuStyle ?? _ToolbarTheme.defaultMenuStyle(context),
style: _ToolbarTheme.defaultMenuButtonStyle,
onHover: (value) => setState(() {
hover = value;
@ -2074,7 +2074,7 @@ class _SubmenuButton extends StatelessWidget {
child: child,
menuChildren:
menuChildren.map((e) => _buildPointerTrackWidget(e, ffi)).toList(),
menuStyle: _ToolbarTheme.defaultMenuStyle,
menuStyle: _ToolbarTheme.defaultMenuStyle(context),
);
}
}
@ -2323,7 +2323,7 @@ class _DraggableShowHideState extends State<_DraggableShowHide> {
?.backgroundColor
?.resolve(MaterialState.values.toSet()),
border: Border.all(
color: _ToolbarTheme.borderColor,
color: _ToolbarTheme.borderColor(context),
width: 1,
),
borderRadius: widget.borderRadius,