Skip to content

Commit 8488162

Browse files
committed
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 70777ba commit 8488162

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
@@ -172,9 +172,10 @@ class ActionSheetCancelButton extends StatelessWidget {
172172
foregroundColor: designVariables.contextMenuCancelText,
173173
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)),
174174
splashFactory: NoSplash.splashFactory,
175-
).copyWith(backgroundColor: WidgetStateColor.resolveWith((states) =>
176-
designVariables.contextMenuCancelBg.withFadedAlpha(
177-
states.contains(WidgetState.pressed) ? 0.20 : 0.15))),
175+
).copyWith(backgroundColor: WidgetStateColor.fromMap({
176+
WidgetState.pressed: designVariables.contextMenuCancelPressedBg,
177+
~WidgetState.pressed: designVariables.contextMenuCancelBg,
178+
})),
178179
onPressed: () {
179180
Navigator.pop(context);
180181
},

lib/widgets/theme.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
133133
title: const Color(0xff1a1a1a),
134134
channelColorSwatches: ChannelColorSwatches.light,
135135
atMentionMarker: const HSLColor.fromAHSL(0.5, 0, 0, 0.2).toColor(),
136-
contextMenuCancelBg: const Color(0xff797986),
136+
contextMenuCancelBg: const Color(0xff797986).withValues(alpha: 0.15),
137+
contextMenuCancelPressedBg: const Color(0xff797986).withValues(alpha: 0.20),
137138
dmHeaderBg: const HSLColor.fromAHSL(1, 46, 0.35, 0.93).toColor(),
138139
errorBannerBackground: const HSLColor.fromAHSL(1, 4, 0.33, 0.90).toColor(),
139140
errorBannerBorder: const HSLColor.fromAHSL(0.4, 3, 0.57, 0.33).toColor(),
@@ -172,7 +173,8 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
172173
textInput: const Color(0xffffffff).withValues(alpha: 0.9),
173174
title: const Color(0xffffffff),
174175
channelColorSwatches: ChannelColorSwatches.dark,
175-
contextMenuCancelBg: const Color(0xff797986), // the same as the light mode in Figma
176+
contextMenuCancelBg: const Color(0xff797986).withValues(alpha: 0.15), // the same as the light mode in Figma
177+
contextMenuCancelPressedBg: const Color(0xff797986).withValues(alpha: 0.20), // the same as the light mode in Figma
176178
// TODO(design-dark) need proper dark-theme color (this is ad hoc)
177179
atMentionMarker: const HSLColor.fromAHSL(0.4, 0, 0, 1).toColor(),
178180
dmHeaderBg: const HSLColor.fromAHSL(1, 46, 0.15, 0.2).toColor(),
@@ -221,6 +223,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
221223
required this.channelColorSwatches,
222224
required this.atMentionMarker,
223225
required this.contextMenuCancelBg,
226+
required this.contextMenuCancelPressedBg,
224227
required this.dmHeaderBg,
225228
required this.errorBannerBackground,
226229
required this.errorBannerBorder,
@@ -273,6 +276,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
273276
// Not named variables in Figma; taken from older Figma drafts, or elsewhere.
274277
final Color atMentionMarker;
275278
final Color contextMenuCancelBg; // In Figma, but unnamed.
279+
final Color contextMenuCancelPressedBg; // In Figma, but unnamed.
276280
final Color dmHeaderBg;
277281
final Color errorBannerBackground;
278282
final Color errorBannerBorder;
@@ -312,6 +316,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
312316
ChannelColorSwatches? channelColorSwatches,
313317
Color? atMentionMarker,
314318
Color? contextMenuCancelBg,
319+
Color? contextMenuCancelPressedBg,
315320
Color? dmHeaderBg,
316321
Color? errorBannerBackground,
317322
Color? errorBannerBorder,
@@ -350,6 +355,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
350355
channelColorSwatches: channelColorSwatches ?? this.channelColorSwatches,
351356
atMentionMarker: atMentionMarker ?? this.atMentionMarker,
352357
contextMenuCancelBg: contextMenuCancelBg ?? this.contextMenuCancelBg,
358+
contextMenuCancelPressedBg: contextMenuCancelPressedBg ?? this.contextMenuCancelPressedBg,
353359
dmHeaderBg: dmHeaderBg ?? this.dmHeaderBg,
354360
errorBannerBackground: errorBannerBackground ?? this.errorBannerBackground,
355361
errorBannerBorder: errorBannerBorder ?? this.errorBannerBorder,
@@ -395,6 +401,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
395401
channelColorSwatches: ChannelColorSwatches.lerp(channelColorSwatches, other.channelColorSwatches, t),
396402
atMentionMarker: Color.lerp(atMentionMarker, other.atMentionMarker, t)!,
397403
contextMenuCancelBg: Color.lerp(contextMenuCancelBg, other.contextMenuCancelBg, t)!,
404+
contextMenuCancelPressedBg: Color.lerp(contextMenuCancelPressedBg, other.contextMenuCancelPressedBg, t)!,
398405
dmHeaderBg: Color.lerp(dmHeaderBg, other.dmHeaderBg, t)!,
399406
errorBannerBackground: Color.lerp(errorBannerBackground, other.errorBannerBackground, t)!,
400407
errorBannerBorder: Color.lerp(errorBannerBorder, other.errorBannerBorder, t)!,

0 commit comments

Comments
 (0)