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

@ -101,6 +101,7 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
const ColorThemeExtension({ const ColorThemeExtension({
required this.border, required this.border,
required this.border2, required this.border2,
required this.border3,
required this.highlight, required this.highlight,
required this.drag_indicator, required this.drag_indicator,
required this.shadow, required this.shadow,
@ -108,10 +109,12 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
required this.me, required this.me,
required this.toastBg, required this.toastBg,
required this.toastText, required this.toastText,
required this.divider,
}); });
final Color? border; final Color? border;
final Color? border2; final Color? border2;
final Color? border3;
final Color? highlight; final Color? highlight;
final Color? drag_indicator; final Color? drag_indicator;
final Color? shadow; final Color? shadow;
@ -119,10 +122,12 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
final Color? me; final Color? me;
final Color? toastBg; final Color? toastBg;
final Color? toastText; final Color? toastText;
final Color? divider;
static final light = ColorThemeExtension( static final light = ColorThemeExtension(
border: Color(0xFFCCCCCC), border: Color(0xFFCCCCCC),
border2: Color(0xFFBBBBBB), border2: Color(0xFFBBBBBB),
border3: Colors.black26,
highlight: Color(0xFFE5E5E5), highlight: Color(0xFFE5E5E5),
drag_indicator: Colors.grey[800], drag_indicator: Colors.grey[800],
shadow: Colors.black, shadow: Colors.black,
@ -130,11 +135,13 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
me: Colors.green, me: Colors.green,
toastBg: Colors.black.withOpacity(0.6), toastBg: Colors.black.withOpacity(0.6),
toastText: Colors.white, toastText: Colors.white,
divider: Colors.black38,
); );
static final dark = ColorThemeExtension( static final dark = ColorThemeExtension(
border: Color(0xFF555555), border: Color(0xFF555555),
border2: Color(0xFFE5E5E5), border2: Color(0xFFE5E5E5),
border3: Colors.white24,
highlight: Color(0xFF3F3F3F), highlight: Color(0xFF3F3F3F),
drag_indicator: Colors.grey, drag_indicator: Colors.grey,
shadow: Colors.grey, shadow: Colors.grey,
@ -142,12 +149,14 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
me: Colors.greenAccent, me: Colors.greenAccent,
toastBg: Colors.white.withOpacity(0.6), toastBg: Colors.white.withOpacity(0.6),
toastText: Colors.black, toastText: Colors.black,
divider: Colors.white38,
); );
@override @override
ThemeExtension<ColorThemeExtension> copyWith({ ThemeExtension<ColorThemeExtension> copyWith({
Color? border, Color? border,
Color? border2, Color? border2,
Color? border3,
Color? highlight, Color? highlight,
Color? drag_indicator, Color? drag_indicator,
Color? shadow, Color? shadow,
@ -155,10 +164,12 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
Color? me, Color? me,
Color? toastBg, Color? toastBg,
Color? toastText, Color? toastText,
Color? divider,
}) { }) {
return ColorThemeExtension( return ColorThemeExtension(
border: border ?? this.border, border: border ?? this.border,
border2: border2 ?? this.border2, border2: border2 ?? this.border2,
border3: border3 ?? this.border3,
highlight: highlight ?? this.highlight, highlight: highlight ?? this.highlight,
drag_indicator: drag_indicator ?? this.drag_indicator, drag_indicator: drag_indicator ?? this.drag_indicator,
shadow: shadow ?? this.shadow, shadow: shadow ?? this.shadow,
@ -166,6 +177,7 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
me: me ?? this.me, me: me ?? this.me,
toastBg: toastBg ?? this.toastBg, toastBg: toastBg ?? this.toastBg,
toastText: toastText ?? this.toastText, toastText: toastText ?? this.toastText,
divider: divider ?? this.divider,
); );
} }
@ -178,6 +190,7 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
return ColorThemeExtension( return 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),
border3: Color.lerp(border3, other.border3, 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), drag_indicator: Color.lerp(drag_indicator, other.drag_indicator, t),
shadow: Color.lerp(shadow, other.shadow, t), shadow: Color.lerp(shadow, other.shadow, t),
@ -185,6 +198,7 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
me: Color.lerp(shadow, other.me, t), me: Color.lerp(shadow, other.me, t),
toastBg: Color.lerp(shadow, other.toastBg, t), toastBg: Color.lerp(shadow, other.toastBg, t),
toastText: Color.lerp(shadow, other.toastText, t), toastText: Color.lerp(shadow, other.toastText, t),
divider: Color.lerp(shadow, other.divider, t),
); );
} }
} }
@ -204,10 +218,6 @@ 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(
@ -394,6 +404,13 @@ class MyTheme {
MenuStyle(backgroundColor: MaterialStatePropertyAll(Colors.white))), 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),
popupMenuTheme: PopupMenuThemeData(
color: Colors.white,
shape: RoundedRectangleBorder(
side: BorderSide(
color: isDesktop ? Color(0xFFECECEC) : Colors.transparent),
borderRadius: BorderRadius.all(Radius.circular(8.0)),
)),
).copyWith( ).copyWith(
extensions: <ThemeExtension<dynamic>>[ extensions: <ThemeExtension<dynamic>>[
ColorThemeExtension.light, ColorThemeExtension.light,
@ -492,6 +509,11 @@ class MyTheme {
secondary: accent, secondary: accent,
background: Color(0xFF24252B), background: Color(0xFF24252B),
), ),
popupMenuTheme: PopupMenuThemeData(
shape: RoundedRectangleBorder(
side: BorderSide(color: Colors.white24),
borderRadius: BorderRadius.all(Radius.circular(8.0)),
)),
).copyWith( ).copyWith(
extensions: <ThemeExtension<dynamic>>[ extensions: <ThemeExtension<dynamic>>[
ColorThemeExtension.dark, ColorThemeExtension.dark,
@ -2022,7 +2044,7 @@ List<String>? urlLinkToCmdArgs(Uri uri) {
id = id + uri.path; id = id + uri.path;
} }
} }
var key = uri.queryParameters["key"]; var key = uri.queryParameters["key"];
if (id != null) { if (id != null) {
if (key != null) { if (key != null) {

View File

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