Skip to content

Commit e7de8ec

Browse files
chrisbobbegnprice
authored andcommitted
model [nfc]: Make StreamColorVariant visibleForTesting
1 parent 83acd9c commit e7de8ec

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

lib/api/model/model.dart

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -462,62 +462,62 @@ class Subscription extends ZulipStream {
462462
///
463463
/// Use this in UI code for colors related to [Subscription.color],
464464
/// such as the background of an unread count badge.
465-
class StreamColorSwatch extends ColorSwatch<_StreamColorVariant> {
465+
class StreamColorSwatch extends ColorSwatch<StreamColorVariant> {
466466
StreamColorSwatch(int base) : super(base, _compute(base));
467467

468468
/// The [Subscription.color] int that the swatch is based on.
469-
Color get base => this[_StreamColorVariant.base]!;
469+
Color get base => this[StreamColorVariant.base]!;
470470

471-
Color get unreadCountBadgeBackground => this[_StreamColorVariant.unreadCountBadgeBackground]!;
471+
Color get unreadCountBadgeBackground => this[StreamColorVariant.unreadCountBadgeBackground]!;
472472

473473
/// The stream icon on a plain-colored surface, such as white.
474474
///
475475
/// For the icon on a [barBackground]-colored surface,
476476
/// use [iconOnBarBackground] instead.
477-
Color get iconOnPlainBackground => this[_StreamColorVariant.iconOnPlainBackground]!;
477+
Color get iconOnPlainBackground => this[StreamColorVariant.iconOnPlainBackground]!;
478478

479479
/// The stream icon on a [barBackground]-colored surface.
480480
///
481481
/// For the icon on a plain surface, use [iconOnPlainBackground] instead.
482482
/// This color is chosen to enhance contrast with [barBackground]:
483483
/// <https://github.com/zulip/zulip/pull/27485>
484-
Color get iconOnBarBackground => this[_StreamColorVariant.iconOnBarBackground]!;
484+
Color get iconOnBarBackground => this[StreamColorVariant.iconOnBarBackground]!;
485485

486486
/// The background color of a bar representing a stream, like a recipient bar.
487487
///
488488
/// Use this in the message list, the "Inbox" view, and the "Streams" view.
489-
Color get barBackground => this[_StreamColorVariant.barBackground]!;
489+
Color get barBackground => this[StreamColorVariant.barBackground]!;
490490

491-
static Map<_StreamColorVariant, Color> _compute(int base) {
491+
static Map<StreamColorVariant, Color> _compute(int base) {
492492
final baseAsColor = Color(base);
493493

494494
final clamped20to75 = clampLchLightness(baseAsColor, 20, 75);
495495
final clamped20to75AsHsl = HSLColor.fromColor(clamped20to75);
496496

497497
return {
498-
_StreamColorVariant.base: baseAsColor,
498+
StreamColorVariant.base: baseAsColor,
499499

500500
// Follows `.unread-count` in Vlad's replit:
501501
// <https://replit.com/@VladKorobov/zulip-sidebar#script.js>
502502
// <https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/design.3A.20.23F117.20.22Inbox.22.20screen/near/1624484>
503503
//
504504
// TODO fix bug where our results differ from the replit's (see unit tests)
505-
_StreamColorVariant.unreadCountBadgeBackground:
505+
StreamColorVariant.unreadCountBadgeBackground:
506506
clampLchLightness(baseAsColor, 30, 70)
507507
.withOpacity(0.3),
508508

509509
// Follows `.sidebar-row__icon` in Vlad's replit:
510510
// <https://replit.com/@VladKorobov/zulip-topic-feed-colors#script.js>
511511
//
512512
// TODO fix bug where our results differ from the replit's (see unit tests)
513-
_StreamColorVariant.iconOnPlainBackground: clamped20to75,
513+
StreamColorVariant.iconOnPlainBackground: clamped20to75,
514514

515515
// Follows `.recepeient__icon` in Vlad's replit:
516516
// <https://replit.com/@VladKorobov/zulip-topic-feed-colors#script.js>
517517
// <https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/design.3A.20.23F117.20.22Inbox.22.20screen/near/1624484>
518518
//
519519
// TODO fix bug where our results differ from the replit's (see unit tests)
520-
_StreamColorVariant.iconOnBarBackground:
520+
StreamColorVariant.iconOnBarBackground:
521521
clamped20to75AsHsl
522522
.withLightness(clamped20to75AsHsl.lightness - 0.12)
523523
.toColor(),
@@ -530,15 +530,16 @@ class StreamColorSwatch extends ColorSwatch<_StreamColorVariant> {
530530
// <https://pub.dev/documentation/flutter_color_models/latest/flutter_color_models/ColorModel/interpolate.html>
531531
// which does ordinary RGB mixing. Investigate and send a PR?
532532
// TODO fix bug where our results differ from the replit's (see unit tests)
533-
_StreamColorVariant.barBackground:
533+
StreamColorVariant.barBackground:
534534
LabColor.fromColor(const Color(0xfff9f9f9))
535535
.interpolate(LabColor.fromColor(clamped20to75), 0.22)
536536
.toColor(),
537537
};
538538
}
539539
}
540540

541-
enum _StreamColorVariant {
541+
@visibleForTesting
542+
enum StreamColorVariant {
542543
base,
543544
unreadCountBadgeBackground,
544545
iconOnPlainBackground,

0 commit comments

Comments
 (0)