Skip to content

Commit 395d722

Browse files
committed
theme [nfc]: Extract starColor to DesignVariables.
Signed-off-by: Zixuan James Li <[email protected]>
1 parent 676fe10 commit 395d722

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/widgets/message_list.dart

Lines changed: 2 additions & 4 deletions
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 designVariables = 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: designVariables.star))
984982
: null),
985983
]),
986984
])));

lib/widgets/theme.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
123123
mainBackground: const Color(0xfff0f0f0),
124124
title: const Color(0xff1a1a1a),
125125
streamColorSwatches: StreamColorSwatches.light,
126+
star: const HSLColor.fromAHSL(0.5, 47, 1, 0.41).toColor(),
126127
);
127128

128129
DesignVariables.dark() :
@@ -133,6 +134,8 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
133134
mainBackground: const Color(0xff1d1d1d),
134135
title: const Color(0xffffffff),
135136
streamColorSwatches: StreamColorSwatches.dark,
137+
// TODO(#95) unchanged in dark theme?
138+
star: const HSLColor.fromAHSL(0.5, 47, 1, 0.41).toColor(),
136139
);
137140

138141
DesignVariables._({
@@ -142,6 +145,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
142145
required this.mainBackground,
143146
required this.title,
144147
required this.streamColorSwatches,
148+
required this.star,
145149
});
146150

147151
/// The [DesignVariables] from the context's active theme.
@@ -163,6 +167,9 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
163167
// Not exactly from the Figma design, but from Vlad anyway.
164168
final StreamColorSwatches streamColorSwatches;
165169

170+
// Not named variables in Figma; taken from older Figma drafts, or elsewhere.
171+
final Color star;
172+
166173
@override
167174
DesignVariables copyWith({
168175
Color? bgTopBar,
@@ -171,6 +178,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
171178
Color? mainBackground,
172179
Color? title,
173180
StreamColorSwatches? streamColorSwatches,
181+
Color? star,
174182
}) {
175183
return DesignVariables._(
176184
bgTopBar: bgTopBar ?? this.bgTopBar,
@@ -179,6 +187,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
179187
mainBackground: mainBackground ?? this.mainBackground,
180188
title: title ?? this.title,
181189
streamColorSwatches: streamColorSwatches ?? this.streamColorSwatches,
190+
star: star ?? this.star,
182191
);
183192
}
184193

@@ -194,6 +203,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
194203
mainBackground: Color.lerp(mainBackground, other.mainBackground, t)!,
195204
title: Color.lerp(title, other.title, t)!,
196205
streamColorSwatches: StreamColorSwatches.lerp(streamColorSwatches, other.streamColorSwatches, t),
206+
star: Color.lerp(star, other.star, t)!,
197207
);
198208
}
199209
}

0 commit comments

Comments
 (0)