Skip to content

Compute colorSwatchFor when subscription is null #1491

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

Merged
merged 1 commit into from
May 7, 2025

Conversation

PIG208
Copy link
Member

@PIG208 PIG208 commented Apr 30, 2025

Looking into the design requirement a bit more, we initially fall back to this color because we didn't have the logic to generate channel colors:
https://chat.zulip.org/#narrow/channel/48-mobile/topic/All.20channels.20screen.20-.20.23F832/near/1904009

This replaces the ad-hoc colors with generated colors based on a fallback base color.

The base color we fall back to is still a placeholder. Ideally, we should pick a color even for unsubscribed streams, as shown in the Figma design linked in #188. That issue is out-of-scope for this, though.

For now, it's sufficient to just remove the ad-hoc color on MessageListTheme. This way we don't have to reuse it in places where colors for unsubscribed streams are needed, namely the topic list (#1158).

before after
light light-before light-after-3
dark dark-before dark-after-3

@PIG208 PIG208 requested a review from chrisbobbe April 30, 2025 02:38
@PIG208 PIG208 added the maintainer review PR ready for review by Zulip maintainers label Apr 30, 2025
Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM except for a commit-message nit:

The base color we fall back to is still a placeholder.  Ideally, we
should pick a color for the unsubscribed streams, as shown in the
Figma design linked in https://github.com/zulip/zulip-flutter/issues/188.  That issue is out-of-scope for this,
though.

I was getting confused by "Ideally, we should pick a color for the unsubscribed streams", because that's exactly what this PR does, isn't it :) it picks kDefaultChannelColorSwatchBaseColor i.e. 0xffc2c2c2.

I think what's meant is that we should generate random colors (within constraints) separately for each unsubscribed channel, client-side, is that right?

(also nit: channels, not streams 🙂)

@PIG208
Copy link
Member Author

PIG208 commented Apr 30, 2025

Thanks! Updated the PR.

@PIG208 PIG208 force-pushed the pr-colors branch 2 times, most recently from 3ebe6fb to 806ea79 Compare May 1, 2025 02:09
@chrisbobbe
Copy link
Collaborator

Thanks! Marking for Greg's review.

@chrisbobbe chrisbobbe added integration review Added by maintainers when PR may be ready for integration and removed maintainer review PR ready for review by Zulip maintainers labels May 1, 2025
@chrisbobbe chrisbobbe assigned gnprice and unassigned chrisbobbe May 1, 2025
@chrisbobbe chrisbobbe requested a review from gnprice May 1, 2025 19:36
@gnprice
Copy link
Member

gnprice commented May 1, 2025

we initially fall back to this color because we didn't have the logic to generate channel colors: https://chat.zulip.org/#narrow/channel/48-mobile/topic/All.20channels.20screen.20-.20.23F832/near/1904009

Hmm. That's from 2024, and we already had the ChannelColorSwatch system (was StreamColorSwatch) in 2023. So it's not because we didn't have these swatches that we didn't use it then.

Rather I think the point in that message:

On web, we do show colors even for non-subscribed streams:
https://chat.zulip.org/#channels/notsubscribed
but I think generating those colors involves logic we don't currently have in mobile, so adding that would be out of scope here.

was that we haven't implemented the logic to make up a different base color for each non-subscribed channel. (Which I believe draws on the same logic that's used to pick a base color for your subscription if you do subscribe.)


The changes in the screenshots seem harmless, though. What's the motivation for this change — is it that in your work on #1158 you're finding you want a whole channel-color swatch for a non-subscribed channel, beyond .barBackground?

@PIG208
Copy link
Member Author

PIG208 commented May 1, 2025

Initially it was just the alternative solution to moving the ad-hoc color to design variables; but it is helpful for providing .iconOnBarBackground too, for the colored channel icon on the app bar.

@PIG208 PIG208 mentioned this pull request May 6, 2025
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The changes look good.

Please revise the commit message to not be inaccurate, though 🙂 — the motivation you mention above is fine.

/// For how this value is cached, see [ChannelColorSwatches.forBaseColor].
ChannelColorSwatch colorSwatchFor(BuildContext context, Subscription subscription) {
// TODO(#188) pick different colors for unsubscribed channels
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking into the design requirement a bit more, we initially fall back
to this color because we didn't have the logic to generate channel
colors:

As discussed at #1491 (comment) , the thing we didn't have then is exactly the thing we don't have now either, the one this TODO points out 🙂.

This removes the ad-hoc color we use for null subscriptions,
which is a workaround for not having logic to generate different base
colors within constraints for unsubscribed channels:
  https://chat.zulip.org/#narrow/channel/48-mobile/topic/All.20channels.20screen.20-.20.23F832/near/1904009

While this change does not implement that logic either,
it removes the ad-hoc color in favor of a constant base color,
intended for colorSwatchFor.  The base color can be reused on
topic-list page (zulip#1158), giving us access to `.iconOnBarBackground`
and friends for the app bar.
@PIG208
Copy link
Member Author

PIG208 commented May 7, 2025

Thanks! Updated the PR.

@gnprice gnprice merged commit 5fcf6e0 into zulip:main May 7, 2025
1 check passed
@gnprice
Copy link
Member

gnprice commented May 7, 2025

Thanks! Merging.

@PIG208 PIG208 deleted the pr-colors branch May 8, 2025 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration review Added by maintainers when PR may be ready for integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants