Skip to content

Commit 4e16c2f

Browse files
chrisbobbegnprice
authored andcommitted
model [nfc]: Explicitly name light-theme constructor of StreamColorSwatch
1 parent 4ed0d5a commit 4e16c2f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

lib/api/model/model.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ class Subscription extends ZulipStream {
421421
// TODO I'm not sure this is the right home for this; it seems like we might
422422
// instead have chosen to put it in more UI-centered code, like in a custom
423423
// material [ColorScheme] class or something. But it works for now.
424-
StreamColorSwatch colorSwatch() => _swatch ??= StreamColorSwatch(color);
424+
StreamColorSwatch colorSwatch() => _swatch ??= StreamColorSwatch.light(color);
425425

426426
@visibleForTesting
427427
@JsonKey(includeToJson: false)
@@ -463,7 +463,7 @@ class Subscription extends ZulipStream {
463463
/// Use this in UI code for colors related to [Subscription.color],
464464
/// such as the background of an unread count badge.
465465
class StreamColorSwatch extends ColorSwatch<StreamColorVariant> {
466-
StreamColorSwatch(int base) : this._(base, _computeLight(base));
466+
StreamColorSwatch.light(int base) : this._(base, _computeLight(base));
467467
StreamColorSwatch.dark(int base) : this._(base, _computeDark(base));
468468

469469
const StreamColorSwatch._(int base, this._swatch) : super(base, _swatch);

test/api/model/model_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ void main() {
130130
group('StreamColorSwatch', () {
131131
group('light', () {
132132
test('base', () {
133-
check(StreamColorSwatch(0xffffffff)).base.equals(const Color(0xffffffff));
133+
check(StreamColorSwatch.light(0xffffffff)).base.equals(const Color(0xffffffff));
134134
});
135135

136136
test('unreadCountBadgeBackground', () {
137137
void runCheck(int base, Color expected) {
138-
check(StreamColorSwatch(base)).unreadCountBadgeBackground.equals(expected);
138+
check(StreamColorSwatch.light(base)).unreadCountBadgeBackground.equals(expected);
139139
}
140140

141141
// Check against everything in ZULIP_ASSIGNMENT_COLORS and EXTREME_COLORS
@@ -197,7 +197,7 @@ void main() {
197197

198198
test('iconOnPlainBackground', () {
199199
void runCheck(int base, Color expected) {
200-
check(StreamColorSwatch(base)).iconOnPlainBackground.equals(expected);
200+
check(StreamColorSwatch.light(base)).iconOnPlainBackground.equals(expected);
201201
}
202202

203203
// Check against everything in ZULIP_ASSIGNMENT_COLORS
@@ -238,7 +238,7 @@ void main() {
238238

239239
test('iconOnBarBackground', () {
240240
void runCheck(int base, Color expected) {
241-
check(StreamColorSwatch(base)).iconOnBarBackground.equals(expected);
241+
check(StreamColorSwatch.light(base)).iconOnBarBackground.equals(expected);
242242
}
243243

244244
// Check against everything in ZULIP_ASSIGNMENT_COLORS
@@ -279,7 +279,7 @@ void main() {
279279

280280
test('barBackground', () {
281281
void runCheck(int base, Color expected) {
282-
check(StreamColorSwatch(base)).barBackground.equals(expected);
282+
check(StreamColorSwatch.light(base)).barBackground.equals(expected);
283283
}
284284

285285
// Check against everything in ZULIP_ASSIGNMENT_COLORS
@@ -516,7 +516,7 @@ void main() {
516516
});
517517

518518
test('lerp (different a, b)', () {
519-
final swatchA = StreamColorSwatch(0xff76ce90);
519+
final swatchA = StreamColorSwatch.light(0xff76ce90);
520520

521521
// TODO(#95) use something like StreamColorSwatch.dark(), once
522522
// implemented, and remove debugFromBaseAndSwatch
@@ -551,7 +551,7 @@ void main() {
551551
test('lerp (identical a, b)', () {
552552
check(StreamColorSwatch.lerp(null, null, 0.0)).isNull();
553553

554-
final swatch = StreamColorSwatch(0xff76ce90);
554+
final swatch = StreamColorSwatch.light(0xff76ce90);
555555
check(StreamColorSwatch.lerp(swatch, swatch, 0.5)).isNotNull()
556556
..identicalTo(swatch)
557557
..base.equals(const Color(0xff76ce90));

test/widgets/unread_count_badge_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void main() {
3838
});
3939

4040
testWidgets('stream color', (WidgetTester tester) async {
41-
final swatch = StreamColorSwatch(0xff76ce90);
41+
final swatch = StreamColorSwatch.light(0xff76ce90);
4242
await prepare(tester, swatch);
4343
check(findBackgroundColor(tester)).equals(swatch.unreadCountBadgeBackground);
4444
});

0 commit comments

Comments
 (0)