Skip to content

Commit 594d66a

Browse files
committed
theme [nfc]: Extract starColor to DesignVariables.
Signed-off-by: Zixuan James Li <[email protected]>
1 parent 03a0b86 commit 594d66a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/widgets/message_list.dart

+2-4
Original file line numberDiff line numberDiff line change
@@ -896,12 +896,10 @@ class MessageWithPossibleSender extends StatelessWidget {
896896

897897
final MessageListMessageItem item;
898898

899-
// TODO(#95) unchanged in dark theme?
900-
static final _starColor = const HSLColor.fromAHSL(0.5, 47, 1, 0.41).toColor();
901-
902899
@override
903900
Widget build(BuildContext context) {
904901
final store = PerAccountStoreWidget.of(context);
902+
final theme = DesignVariables.of(context);
905903

906904
final message = item.message;
907905
final sender = store.users[message.senderId];
@@ -980,7 +978,7 @@ class MessageWithPossibleSender extends StatelessWidget {
980978
// Design from Figma at:
981979
// https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=813%3A28817&mode=dev .
982980
? Padding(padding: const EdgeInsets.only(top: 4),
983-
child: Icon(ZulipIcons.star_filled, size: 16, color: _starColor))
981+
child: Icon(ZulipIcons.star_filled, size: 16, color: theme.starColor))
984982
: null),
985983
]),
986984
])));

lib/widgets/theme.dart

+9-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
8181
borderBar = const Color(0x33000000),
8282
icon = const Color(0xff666699),
8383
title = const Color(0xff1a1a1a),
84-
streamColorSwatches = StreamColorSwatches.light;
84+
streamColorSwatches = StreamColorSwatches.light,
85+
starColor = const HSLColor.fromAHSL(0.5, 47, 1, 0.41).toColor();
8586

8687
DesignVariables._({
8788
required this.bgMain,
@@ -90,6 +91,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
9091
required this.icon,
9192
required this.title,
9293
required this.streamColorSwatches,
94+
required this.starColor,
9395
});
9496

9597
/// The [DesignVariables] from the context's active theme.
@@ -111,6 +113,9 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
111113
// Not exactly from the Figma design, but from Vlad anyway.
112114
final StreamColorSwatches streamColorSwatches;
113115

116+
// Not named variables in Figma; taken from older Figma drafts, or elsewhere.
117+
final Color starColor;
118+
114119
@override
115120
DesignVariables copyWith({
116121
Color? bgMain,
@@ -119,6 +124,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
119124
Color? icon,
120125
Color? title,
121126
StreamColorSwatches? streamColorSwatches,
127+
Color? starColor,
122128
}) {
123129
return DesignVariables._(
124130
bgMain: bgMain ?? this.bgMain,
@@ -127,6 +133,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
127133
icon: icon ?? this.icon,
128134
title: title ?? this.title,
129135
streamColorSwatches: streamColorSwatches ?? this.streamColorSwatches,
136+
starColor: starColor ?? this.starColor,
130137
);
131138
}
132139

@@ -142,6 +149,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
142149
icon: Color.lerp(icon, other.icon, t)!,
143150
title: Color.lerp(title, other.title, t)!,
144151
streamColorSwatches: StreamColorSwatches.lerp(streamColorSwatches, other.streamColorSwatches, t),
152+
starColor: Color.lerp(starColor, other.starColor, t)!,
145153
);
146154
}
147155
}

0 commit comments

Comments
 (0)