Skip to content

Commit 70343d4

Browse files
chrisbobbegnprice
authored andcommitted
emoji_reaction [nfc]: Make EmojiReactionTheme.{light,dark} static finals
Like we did for MessageListTheme in the previous commit and DesignVariables in dcc8123.
1 parent 164c228 commit 70343d4

File tree

3 files changed

+37
-39
lines changed

3 files changed

+37
-39
lines changed

lib/widgets/emoji_reaction.dart

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,36 @@ import 'theme.dart';
1616

1717
/// Emoji-reaction styles that differ between light and dark themes.
1818
class EmojiReactionTheme extends ThemeExtension<EmojiReactionTheme> {
19-
EmojiReactionTheme.light() :
20-
this._(
21-
bgSelected: Colors.white,
22-
23-
// TODO shadow effect, following web, which uses `box-shadow: inset`:
24-
// https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow#inset
25-
// Needs Flutter support for something like that:
26-
// https://github.com/flutter/flutter/issues/18636
27-
// https://github.com/flutter/flutter/issues/52999
28-
// Until then use a solid color; a much-lightened version of the shadow color.
29-
// Also adapt by making [borderUnselected] more transparent, so we'll
30-
// want to check that against web when implementing the shadow.
31-
bgUnselected: const HSLColor.fromAHSL(0.08, 210, 0.50, 0.875).toColor(),
32-
33-
borderSelected: Colors.black.withValues(alpha: 0.45),
34-
35-
// TODO see TODO on [bgUnselected] about shadow effect
36-
borderUnselected: Colors.black.withValues(alpha: 0.05),
37-
38-
textSelected: const HSLColor.fromAHSL(1, 210, 0.20, 0.20).toColor(),
39-
textUnselected: const HSLColor.fromAHSL(1, 210, 0.20, 0.25).toColor(),
40-
);
41-
42-
EmojiReactionTheme.dark() :
43-
this._(
44-
bgSelected: Colors.black.withValues(alpha: 0.8),
45-
bgUnselected: Colors.black.withValues(alpha: 0.3),
46-
borderSelected: Colors.white.withValues(alpha: 0.75),
47-
borderUnselected: Colors.white.withValues(alpha: 0.15),
48-
textSelected: Colors.white.withValues(alpha: 0.85),
49-
textUnselected: Colors.white.withValues(alpha: 0.75),
50-
);
19+
static final light = EmojiReactionTheme._(
20+
bgSelected: Colors.white,
21+
22+
// TODO shadow effect, following web, which uses `box-shadow: inset`:
23+
// https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow#inset
24+
// Needs Flutter support for something like that:
25+
// https://github.com/flutter/flutter/issues/18636
26+
// https://github.com/flutter/flutter/issues/52999
27+
// Until then use a solid color; a much-lightened version of the shadow color.
28+
// Also adapt by making [borderUnselected] more transparent, so we'll
29+
// want to check that against web when implementing the shadow.
30+
bgUnselected: const HSLColor.fromAHSL(0.08, 210, 0.50, 0.875).toColor(),
31+
32+
borderSelected: Colors.black.withValues(alpha: 0.45),
33+
34+
// TODO see TODO on [bgUnselected] about shadow effect
35+
borderUnselected: Colors.black.withValues(alpha: 0.05),
36+
37+
textSelected: const HSLColor.fromAHSL(1, 210, 0.20, 0.20).toColor(),
38+
textUnselected: const HSLColor.fromAHSL(1, 210, 0.20, 0.25).toColor(),
39+
);
40+
41+
static final dark = EmojiReactionTheme._(
42+
bgSelected: Colors.black.withValues(alpha: 0.8),
43+
bgUnselected: Colors.black.withValues(alpha: 0.3),
44+
borderSelected: Colors.white.withValues(alpha: 0.75),
45+
borderUnselected: Colors.white.withValues(alpha: 0.15),
46+
textSelected: Colors.white.withValues(alpha: 0.85),
47+
textUnselected: Colors.white.withValues(alpha: 0.75),
48+
);
5149

5250
EmojiReactionTheme._({
5351
required this.bgSelected,

lib/widgets/theme.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ThemeData zulipThemeData(BuildContext context) {
3030
themeExtensions = [
3131
ContentTheme.light(context),
3232
designVariables,
33-
EmojiReactionTheme.light(),
33+
EmojiReactionTheme.light,
3434
MessageListTheme.light,
3535
];
3636
}
@@ -39,7 +39,7 @@ ThemeData zulipThemeData(BuildContext context) {
3939
themeExtensions = [
4040
ContentTheme.dark(context),
4141
designVariables,
42-
EmojiReactionTheme.dark(),
42+
EmojiReactionTheme.dark,
4343
MessageListTheme.dark,
4444
];
4545
}

test/widgets/emoji_reaction_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,25 +251,25 @@ void main() {
251251
}
252252

253253
check(backgroundColor('smile')).isNotNull()
254-
.isSameColorAs(EmojiReactionTheme.light().bgSelected);
254+
.isSameColorAs(EmojiReactionTheme.light.bgSelected);
255255
check(backgroundColor('tada')).isNotNull()
256-
.isSameColorAs(EmojiReactionTheme.light().bgUnselected);
256+
.isSameColorAs(EmojiReactionTheme.light.bgUnselected);
257257

258258
tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark;
259259
await tester.pump();
260260

261261
await tester.pump(kThemeAnimationDuration * 0.4);
262-
final expectedLerped = EmojiReactionTheme.light().lerp(EmojiReactionTheme.dark(), 0.4);
262+
final expectedLerped = EmojiReactionTheme.light.lerp(EmojiReactionTheme.dark, 0.4);
263263
check(backgroundColor('smile')).isNotNull()
264264
.isSameColorAs(expectedLerped.bgSelected);
265265
check(backgroundColor('tada')).isNotNull()
266266
.isSameColorAs(expectedLerped.bgUnselected);
267267

268268
await tester.pump(kThemeAnimationDuration * 0.6);
269269
check(backgroundColor('smile')).isNotNull()
270-
.isSameColorAs(EmojiReactionTheme.dark().bgSelected);
270+
.isSameColorAs(EmojiReactionTheme.dark.bgSelected);
271271
check(backgroundColor('tada')).isNotNull()
272-
.isSameColorAs(EmojiReactionTheme.dark().bgUnselected);
272+
.isSameColorAs(EmojiReactionTheme.dark.bgUnselected);
273273
});
274274

275275
testWidgets('use emoji font', (tester) async {

0 commit comments

Comments
 (0)