-
Notifications
You must be signed in to change notification settings - Fork 340
inbox: Fix bug where channel unread badge text color was slightly wrong #1895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
inbox: Fix bug where channel unread badge text color was slightly wrong #1895
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @chrisbobbe! LGTM and tests great. Over to Greg's review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @chrisbobbe for the fix, and thanks @rajveermalviya for testing it! Two nits below; otherwise all looks good.
lib/widgets/unread_count_badge.dart
Outdated
super.key, | ||
required this.count, | ||
required this.backgroundColor, | ||
this.channelIdForBackground, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps keep this required? I think "use the not-in-a-channel coloring" isn't necessarily a good default, even though it's represented by null.
await prepare(tester, | ||
child: UnreadCountBadge( | ||
count: 1, | ||
channelIdForBackground: subscription.streamId), | ||
subscription: subscription); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: subscription before child; logically it comes first (it gets applied first), plus the child is a longer argument in the source code
UnreadCountBadge has a needlessly loose API for specifying a background color, with three options: 1. Channel-colorized: callers are supposed to pass a ChannelColorSwatch and the implementation picks `unreadCountBadgeBackground` off of that. 2. Any other Color. (ChannelColorSwatch is a Color.) 3. A default color, chosen by the implementation, if `null` is passed. We don't actually have any use for option 2, at least currently, so we'll remove it next. The buggy caller here was using option 2 when it should have used option 1: it wanted a channel-colored background, but it itself picked `unreadCountBadgeBackground` off of the swatch instead of passing the whole swatch to UnreadCountBadge for it to do that. That would have been fine except that the channel-colorized case has its own associated *text* color, and that's conditioned on whether the passed background color is a ChannelColorSwatch.
Previously, this widget had three options for the background color: 1. Colorized for a channel: callers could pass a ChannelColorSwatch, and the implementation would pick `unreadCountBadgeBackground` off of that. 2. Any `Color`. 3. A default, chosen by the implementation. One caller was using option 2 when option 1 would be a better fit: it wanted a channel-colored background, but it was picking `unreadCountBadgeBackground` itself from the ChannelColorSwatch instead of letting the implementation do that. After changing that caller to just pass the ChannelColorSwatch (option 1), no more callers use option 2, so we remove it. Now UnreadCountBadge has a tighter interface. Next we'll encapsulate finding the channel color swatch itself, so callers only need to have a channel ID if they want a channel-colored background.
9edefdb
to
ce945d0
Compare
Thanks for the review! Revision pushed. |
cc @alya