Skip to content

Commit 5900d7a

Browse files
chrisbobbegnprice
authored andcommitted
button: Implement ZulipMenuItemButtonStyle.menuDestructive, from Figma
1 parent 2dcd55b commit 5900d7a

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

lib/widgets/button.dart

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ class ZulipMenuItemButton extends StatelessWidget {
350350
final Widget? toggle;
351351

352352
double get itemSpacingAndEndPadding => switch (style) {
353-
ZulipMenuItemButtonStyle.menu => 16,
353+
ZulipMenuItemButtonStyle.menu
354+
|| ZulipMenuItemButtonStyle.menuDestructive => 16,
354355
ZulipMenuItemButtonStyle.list => 12,
355356
};
356357

@@ -373,6 +374,11 @@ class ZulipMenuItemButton extends StatelessWidget {
373374
WidgetState.pressed: designVariables.contextMenuItemBg.withFadedAlpha(0.20),
374375
~WidgetState.pressed: designVariables.contextMenuItemBg.withFadedAlpha(0.12),
375376
});
377+
case ZulipMenuItemButtonStyle.menuDestructive:
378+
return WidgetStateColor.fromMap({
379+
WidgetState.pressed: designVariables.contextMenuItemBgDanger.withFadedAlpha(0.20),
380+
~WidgetState.pressed: designVariables.contextMenuItemBgDanger.withFadedAlpha(0.12),
381+
});
376382
case ZulipMenuItemButtonStyle.list:
377383
return WidgetStateColor.fromMap({
378384
WidgetState.pressed: designVariables.listMenuItemBg.withFadedAlpha(0.7),
@@ -384,20 +390,23 @@ class ZulipMenuItemButton extends StatelessWidget {
384390
Color _labelColor(DesignVariables designVariables) {
385391
return switch (style) {
386392
ZulipMenuItemButtonStyle.menu => designVariables.contextMenuItemText,
393+
ZulipMenuItemButtonStyle.menuDestructive => designVariables.contextMenuItemTextDanger,
387394
ZulipMenuItemButtonStyle.list => designVariables.listMenuItemText,
388395
};
389396
}
390397

391398
double _labelWght() {
392399
return switch (style) {
393-
ZulipMenuItemButtonStyle.menu => 600,
400+
ZulipMenuItemButtonStyle.menu
401+
|| ZulipMenuItemButtonStyle.menuDestructive => 600,
394402
ZulipMenuItemButtonStyle.list => 500,
395403
};
396404
}
397405

398406
Color _iconColor(DesignVariables designVariables) {
399407
return switch (style) {
400408
ZulipMenuItemButtonStyle.menu => designVariables.contextMenuItemIcon,
409+
ZulipMenuItemButtonStyle.menuDestructive => designVariables.contextMenuItemIconDanger,
401410
ZulipMenuItemButtonStyle.list => designVariables.listMenuItemIcon,
402411
};
403412
}
@@ -468,6 +477,12 @@ enum ZulipMenuItemButtonStyle {
468477
/// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3302-20443&m=dev
469478
menu,
470479

480+
/// The red, destructive variant of [menu].
481+
///
482+
/// See Figma:
483+
/// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=6329-127234&m=dev
484+
menuDestructive,
485+
471486
/// The gray "list button" component in Figma, with 12px end padding.
472487
///
473488
/// See Figma:

lib/widgets/theme.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
161161
composeBoxBg: const Color(0xffffffff),
162162
contextMenuCancelText: const Color(0xff222222),
163163
contextMenuItemBg: const Color(0xff6159e1),
164+
contextMenuItemBgDanger: const Color(0xffc0070a), // TODO(#831) red/550
164165
contextMenuItemIcon: const Color(0xff4f42c9),
166+
contextMenuItemIconDanger: const Color(0xffac0508), // TODO(#831) red/600
165167
contextMenuItemLabel: const Color(0xff242631),
166168
contextMenuItemMeta: const Color(0xff626573),
167169
contextMenuItemText: const Color(0xff381da7),
170+
contextMenuItemTextDanger: const Color(0xffac0508), // TODO(#831) red/600
168171
editorButtonPressedBg: Colors.black.withValues(alpha: 0.06),
169172
fabBg: const Color(0xff6e69f3),
170173
fabBgPressed: const Color(0xff6159e1),
@@ -252,10 +255,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
252255
composeBoxBg: const Color(0xff0f0f0f),
253256
contextMenuCancelText: const Color(0xffffffff).withValues(alpha: 0.75),
254257
contextMenuItemBg: const Color(0xff7977fe),
258+
contextMenuItemBgDanger: const Color(0xffe1392e), // TODO(#831) red/450
255259
contextMenuItemIcon: const Color(0xff9398fd),
260+
contextMenuItemIconDanger: const Color(0xfffd7465), // TODO(#831) red/300
256261
contextMenuItemLabel: const Color(0xffdfe1e8),
257262
contextMenuItemMeta: const Color(0xff9194a3),
258263
contextMenuItemText: const Color(0xff9398fd),
264+
contextMenuItemTextDanger: const Color(0xfffd7465), // TODO(#831) red/300
259265
editorButtonPressedBg: Colors.white.withValues(alpha: 0.06),
260266
fabBg: const Color(0xff4f42c9),
261267
fabBgPressed: const Color(0xff4331b8),
@@ -352,10 +358,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
352358
required this.composeBoxBg,
353359
required this.contextMenuCancelText,
354360
required this.contextMenuItemBg,
361+
required this.contextMenuItemBgDanger,
355362
required this.contextMenuItemIcon,
363+
required this.contextMenuItemIconDanger,
356364
required this.contextMenuItemLabel,
357365
required this.contextMenuItemMeta,
358366
required this.contextMenuItemText,
367+
required this.contextMenuItemTextDanger,
359368
required this.editorButtonPressedBg,
360369
required this.foreground,
361370
required this.fabBg,
@@ -443,10 +452,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
443452
final Color composeBoxBg;
444453
final Color contextMenuCancelText;
445454
final Color contextMenuItemBg;
455+
final Color contextMenuItemBgDanger;
446456
final Color contextMenuItemIcon;
457+
final Color contextMenuItemIconDanger;
447458
final Color contextMenuItemLabel;
448459
final Color contextMenuItemMeta;
449460
final Color contextMenuItemText;
461+
final Color contextMenuItemTextDanger;
450462
final Color editorButtonPressedBg;
451463
final Color fabBg;
452464
final Color fabBgPressed;
@@ -529,10 +541,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
529541
Color? composeBoxBg,
530542
Color? contextMenuCancelText,
531543
Color? contextMenuItemBg,
544+
Color? contextMenuItemBgDanger,
532545
Color? contextMenuItemIcon,
546+
Color? contextMenuItemIconDanger,
533547
Color? contextMenuItemLabel,
534548
Color? contextMenuItemMeta,
535549
Color? contextMenuItemText,
550+
Color? contextMenuItemTextDanger,
536551
Color? editorButtonPressedBg,
537552
Color? fabBg,
538553
Color? fabBgPressed,
@@ -610,10 +625,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
610625
composeBoxBg: composeBoxBg ?? this.composeBoxBg,
611626
contextMenuCancelText: contextMenuCancelText ?? this.contextMenuCancelText,
612627
contextMenuItemBg: contextMenuItemBg ?? this.contextMenuItemBg,
628+
contextMenuItemBgDanger: contextMenuItemBgDanger ?? this.contextMenuItemBgDanger,
613629
contextMenuItemIcon: contextMenuItemIcon ?? this.contextMenuItemIcon,
630+
contextMenuItemIconDanger: contextMenuItemIconDanger ?? this.contextMenuItemIconDanger,
614631
contextMenuItemLabel: contextMenuItemLabel ?? this.contextMenuItemLabel,
615632
contextMenuItemMeta: contextMenuItemMeta ?? this.contextMenuItemMeta,
616633
contextMenuItemText: contextMenuItemText ?? this.contextMenuItemText,
634+
contextMenuItemTextDanger: contextMenuItemTextDanger ?? this.contextMenuItemTextDanger,
617635
editorButtonPressedBg: editorButtonPressedBg ?? this.editorButtonPressedBg,
618636
foreground: foreground ?? this.foreground,
619637
fabBg: fabBg ?? this.fabBg,
@@ -698,10 +716,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
698716
composeBoxBg: Color.lerp(composeBoxBg, other.composeBoxBg, t)!,
699717
contextMenuCancelText: Color.lerp(contextMenuCancelText, other.contextMenuCancelText, t)!,
700718
contextMenuItemBg: Color.lerp(contextMenuItemBg, other.contextMenuItemBg, t)!,
719+
contextMenuItemBgDanger: Color.lerp(contextMenuItemBgDanger, other.contextMenuItemBgDanger, t)!,
701720
contextMenuItemIcon: Color.lerp(contextMenuItemIcon, other.contextMenuItemIcon, t)!,
721+
contextMenuItemIconDanger: Color.lerp(contextMenuItemIconDanger, other.contextMenuItemIconDanger, t)!,
702722
contextMenuItemLabel: Color.lerp(contextMenuItemLabel, other.contextMenuItemLabel, t)!,
703723
contextMenuItemMeta: Color.lerp(contextMenuItemMeta, other.contextMenuItemMeta, t)!,
704724
contextMenuItemText: Color.lerp(contextMenuItemText, other.contextMenuItemText, t)!,
725+
contextMenuItemTextDanger: Color.lerp(contextMenuItemTextDanger, other.contextMenuItemTextDanger, t)!,
705726
editorButtonPressedBg: Color.lerp(editorButtonPressedBg, other.editorButtonPressedBg, t)!,
706727
foreground: Color.lerp(foreground, other.foreground, t)!,
707728
fabBg: Color.lerp(fabBg, other.fabBg, t)!,

0 commit comments

Comments
 (0)