Skip to content

Commit

Permalink
action_sheet [nfc]: Centralize .withValues variants of contextMenuCan…
Browse files Browse the repository at this point in the history
…celBg

Also switched to .fromMap for better readability

Signed-off-by: Zixuan James Li <zixuan@zulip.com>
  • Loading branch information
PIG208 committed Dec 2, 2024
1 parent 70777ba commit 8488162
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/widgets/action_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ class ActionSheetCancelButton extends StatelessWidget {
foregroundColor: designVariables.contextMenuCancelText,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)),
splashFactory: NoSplash.splashFactory,
).copyWith(backgroundColor: WidgetStateColor.resolveWith((states) =>
designVariables.contextMenuCancelBg.withFadedAlpha(
states.contains(WidgetState.pressed) ? 0.20 : 0.15))),
).copyWith(backgroundColor: WidgetStateColor.fromMap({
WidgetState.pressed: designVariables.contextMenuCancelPressedBg,
~WidgetState.pressed: designVariables.contextMenuCancelBg,
})),
onPressed: () {
Navigator.pop(context);
},
Expand Down
11 changes: 9 additions & 2 deletions lib/widgets/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
title: const Color(0xff1a1a1a),
channelColorSwatches: ChannelColorSwatches.light,
atMentionMarker: const HSLColor.fromAHSL(0.5, 0, 0, 0.2).toColor(),
contextMenuCancelBg: const Color(0xff797986),
contextMenuCancelBg: const Color(0xff797986).withValues(alpha: 0.15),
contextMenuCancelPressedBg: const Color(0xff797986).withValues(alpha: 0.20),
dmHeaderBg: const HSLColor.fromAHSL(1, 46, 0.35, 0.93).toColor(),
errorBannerBackground: const HSLColor.fromAHSL(1, 4, 0.33, 0.90).toColor(),
errorBannerBorder: const HSLColor.fromAHSL(0.4, 3, 0.57, 0.33).toColor(),
Expand Down Expand Up @@ -172,7 +173,8 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
textInput: const Color(0xffffffff).withValues(alpha: 0.9),
title: const Color(0xffffffff),
channelColorSwatches: ChannelColorSwatches.dark,
contextMenuCancelBg: const Color(0xff797986), // the same as the light mode in Figma
contextMenuCancelBg: const Color(0xff797986).withValues(alpha: 0.15), // the same as the light mode in Figma
contextMenuCancelPressedBg: const Color(0xff797986).withValues(alpha: 0.20), // the same as the light mode in Figma
// TODO(design-dark) need proper dark-theme color (this is ad hoc)
atMentionMarker: const HSLColor.fromAHSL(0.4, 0, 0, 1).toColor(),
dmHeaderBg: const HSLColor.fromAHSL(1, 46, 0.15, 0.2).toColor(),
Expand Down Expand Up @@ -221,6 +223,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
required this.channelColorSwatches,
required this.atMentionMarker,
required this.contextMenuCancelBg,
required this.contextMenuCancelPressedBg,
required this.dmHeaderBg,
required this.errorBannerBackground,
required this.errorBannerBorder,
Expand Down Expand Up @@ -273,6 +276,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
// Not named variables in Figma; taken from older Figma drafts, or elsewhere.
final Color atMentionMarker;
final Color contextMenuCancelBg; // In Figma, but unnamed.
final Color contextMenuCancelPressedBg; // In Figma, but unnamed.
final Color dmHeaderBg;
final Color errorBannerBackground;
final Color errorBannerBorder;
Expand Down Expand Up @@ -312,6 +316,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
ChannelColorSwatches? channelColorSwatches,
Color? atMentionMarker,
Color? contextMenuCancelBg,
Color? contextMenuCancelPressedBg,
Color? dmHeaderBg,
Color? errorBannerBackground,
Color? errorBannerBorder,
Expand Down Expand Up @@ -350,6 +355,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
channelColorSwatches: channelColorSwatches ?? this.channelColorSwatches,
atMentionMarker: atMentionMarker ?? this.atMentionMarker,
contextMenuCancelBg: contextMenuCancelBg ?? this.contextMenuCancelBg,
contextMenuCancelPressedBg: contextMenuCancelPressedBg ?? this.contextMenuCancelPressedBg,
dmHeaderBg: dmHeaderBg ?? this.dmHeaderBg,
errorBannerBackground: errorBannerBackground ?? this.errorBannerBackground,
errorBannerBorder: errorBannerBorder ?? this.errorBannerBorder,
Expand Down Expand Up @@ -395,6 +401,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
channelColorSwatches: ChannelColorSwatches.lerp(channelColorSwatches, other.channelColorSwatches, t),
atMentionMarker: Color.lerp(atMentionMarker, other.atMentionMarker, t)!,
contextMenuCancelBg: Color.lerp(contextMenuCancelBg, other.contextMenuCancelBg, t)!,
contextMenuCancelPressedBg: Color.lerp(contextMenuCancelPressedBg, other.contextMenuCancelPressedBg, t)!,
dmHeaderBg: Color.lerp(dmHeaderBg, other.dmHeaderBg, t)!,
errorBannerBackground: Color.lerp(errorBannerBackground, other.errorBannerBackground, t)!,
errorBannerBorder: Color.lerp(errorBannerBorder, other.errorBannerBorder, t)!,
Expand Down

0 comments on commit 8488162

Please sign in to comment.