Skip to content

Commit 63146d3

Browse files
PIG208chrisbobbe
authored andcommitted
action_sheet [nfc]: Centralize .withValues variants of contextMenuCancelBg
Also switched to .fromMap for better readability Signed-off-by: Zixuan James Li <[email protected]>
1 parent 494d33f commit 63146d3

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/widgets/action_sheet.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@ class MessageActionSheetCancelButton extends StatelessWidget {
169169
foregroundColor: designVariables.contextMenuCancelText,
170170
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)),
171171
splashFactory: NoSplash.splashFactory,
172-
).copyWith(backgroundColor: WidgetStateColor.resolveWith((states) =>
173-
designVariables.contextMenuCancelBg.withFadedAlpha(
174-
states.contains(WidgetState.pressed) ? 0.20 : 0.15))),
172+
).copyWith(backgroundColor: WidgetStateColor.fromMap({
173+
WidgetState.pressed: designVariables.contextMenuCancelPressedBg,
174+
~WidgetState.pressed: designVariables.contextMenuCancelBg,
175+
})),
175176
onPressed: () {
176177
Navigator.pop(context);
177178
},

lib/widgets/theme.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
136136
title: const Color(0xff1a1a1a),
137137
channelColorSwatches: ChannelColorSwatches.light,
138138
atMentionMarker: const HSLColor.fromAHSL(0.5, 0, 0, 0.2).toColor(),
139-
contextMenuCancelBg: const Color(0xff797986),
139+
contextMenuCancelBg: const Color(0xff797986).withValues(alpha: 0.15),
140+
contextMenuCancelPressedBg: const Color(0xff797986).withValues(alpha: 0.20),
140141
dmHeaderBg: const HSLColor.fromAHSL(1, 46, 0.35, 0.93).toColor(),
141142
groupDmConversationIcon: Colors.black.withValues(alpha: 0.5),
142143
groupDmConversationIconBg: const Color(0x33808080),
@@ -175,7 +176,8 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
175176
textInput: const Color(0xffffffff).withValues(alpha: 0.9),
176177
title: const Color(0xffffffff),
177178
channelColorSwatches: ChannelColorSwatches.dark,
178-
contextMenuCancelBg: const Color(0xff797986), // the same as the light mode in Figma
179+
contextMenuCancelBg: const Color(0xff797986).withValues(alpha: 0.15), // the same as the light mode in Figma
180+
contextMenuCancelPressedBg: const Color(0xff797986).withValues(alpha: 0.20), // the same as the light mode in Figma
179181
// TODO(design-dark) need proper dark-theme color (this is ad hoc)
180182
atMentionMarker: const HSLColor.fromAHSL(0.4, 0, 0, 1).toColor(),
181183
dmHeaderBg: const HSLColor.fromAHSL(1, 46, 0.15, 0.2).toColor(),
@@ -224,6 +226,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
224226
required this.channelColorSwatches,
225227
required this.atMentionMarker,
226228
required this.contextMenuCancelBg,
229+
required this.contextMenuCancelPressedBg,
227230
required this.dmHeaderBg,
228231
required this.groupDmConversationIcon,
229232
required this.groupDmConversationIconBg,
@@ -276,6 +279,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
276279
// Not named variables in Figma; taken from older Figma drafts, or elsewhere.
277280
final Color atMentionMarker;
278281
final Color contextMenuCancelBg; // In Figma, but unnamed.
282+
final Color contextMenuCancelPressedBg; // In Figma, but unnamed.
279283
final Color dmHeaderBg;
280284
final Color groupDmConversationIcon;
281285
final Color groupDmConversationIconBg;
@@ -315,6 +319,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
315319
ChannelColorSwatches? channelColorSwatches,
316320
Color? atMentionMarker,
317321
Color? contextMenuCancelBg,
322+
Color? contextMenuCancelPressedBg,
318323
Color? dmHeaderBg,
319324
Color? groupDmConversationIcon,
320325
Color? groupDmConversationIconBg,
@@ -353,6 +358,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
353358
channelColorSwatches: channelColorSwatches ?? this.channelColorSwatches,
354359
atMentionMarker: atMentionMarker ?? this.atMentionMarker,
355360
contextMenuCancelBg: contextMenuCancelBg ?? this.contextMenuCancelBg,
361+
contextMenuCancelPressedBg: contextMenuCancelPressedBg ?? this.contextMenuCancelPressedBg,
356362
dmHeaderBg: dmHeaderBg ?? this.dmHeaderBg,
357363
groupDmConversationIcon: groupDmConversationIcon ?? this.groupDmConversationIcon,
358364
groupDmConversationIconBg: groupDmConversationIconBg ?? this.groupDmConversationIconBg,
@@ -398,6 +404,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
398404
channelColorSwatches: ChannelColorSwatches.lerp(channelColorSwatches, other.channelColorSwatches, t),
399405
atMentionMarker: Color.lerp(atMentionMarker, other.atMentionMarker, t)!,
400406
contextMenuCancelBg: Color.lerp(contextMenuCancelBg, other.contextMenuCancelBg, t)!,
407+
contextMenuCancelPressedBg: Color.lerp(contextMenuCancelPressedBg, other.contextMenuCancelPressedBg, t)!,
401408
dmHeaderBg: Color.lerp(dmHeaderBg, other.dmHeaderBg, t)!,
402409
groupDmConversationIcon: Color.lerp(groupDmConversationIcon, other.groupDmConversationIcon, t)!,
403410
groupDmConversationIconBg: Color.lerp(groupDmConversationIconBg, other.groupDmConversationIconBg, t)!,

0 commit comments

Comments
 (0)