Repository navigation
Align feedback thumb icon colors with iOS after interaction - #211
Conversation
The selected feedback thumb now tints with the primary brand color and the unselected thumb dims, matching iOS behavior. Previously Android kept a single icon color for all states, so the selected thumb stayed the message text color while iOS changed to the primary color. - Add selectedIconColor (primary) and dimmedIconColor (text at 40% alpha) to FeedbackButtonsStyle - Resolve per-state tint in FeedbackComponents ThumbsRow Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| spacing = 4.dp, | ||
| iconColor = textColor, | ||
| selectedIconColor = themeColors.primary, | ||
| dimmedIconColor = textColor.copy(alpha = 0.4f), |
There was a problem hiding this comment.
This doesn't quite match iOS. Both MessageFeedbackView.swift and SourcesListView.swift use Color.gray.opacity(0.4) for the thumb that wasn't chosen, no matter the theme. Here the dimmed thumb keeps the message text color, so it comes out black at 40% in light theme, near-white in dark theme, or a custom color, which differs from iOS. Should we align on gray, or update the parity table in the description if theme-aware dimming is intended?
Also, copy(alpha = 0.4f) replaces the existing alpha. If a theme sets a text color more transparent than 40%, the "dimmed" thumb ends up more visible than an unselected one. textColor.copy(alpha = textColor.alpha * 0.4f) avoids that if we keep this approach.
There was a problem hiding this comment.
Thanks for switching to a fixed gray, that fixes the theme and alpha issues. The value is still off though: (0.5, 0.5, 0.5) is UIKit UIColor.gray, while SwiftUI Color.gray is system gray (142, 142, 147). Left details on the new line.
There was a problem hiding this comment.
Fixed with Color(0x668E8E93), thanks!
| val iconSize: Dp, | ||
| val spacing: Dp, | ||
| val iconColor: Color, | ||
| /** Tint for the thumb that was selected after feedback is submitted. Defaults to the primary brand color, matching iOS. */ |
There was a problem hiding this comment.
nit: "Defaults to the primary brand color" reads like a parameter default, but selectedIconColor is required. Maybe something like "Set to the primary brand color in feedbackButtonsStyle".
| // Resolve the tint for each thumb from the feedback state, matching iOS: | ||
| // no vote yet -> default text color; selected thumb -> primary brand color; | ||
| // the thumb not chosen -> dimmed. | ||
| val thumbUpTint = when (feedbackState) { |
There was a problem hiding this comment.
Could we add test coverage for the new tints? The existing positive/negative tests in FeedbackComponentsTest only check that the icons are displayed, so they'd still pass if this change were reverted. Pulling the tint selection into a small pure function (state + which thumb -> color) would make it easy to unit test all three states without an emulator.
There was a problem hiding this comment.
Thanks, iconTintFor plus FeedbackIconTintTest covers this nicely. Left one non-blocking note on the pixel check in FeedbackIconColorsTest.
Use fixed neutral gray at 40% opacity for the unchosen thumb. Extract shared tint selection and clarify selected-color documentation. Add state-selection unit tests and rendered-color coverage across feedback states, placements, and default/custom/translucent themes. Document feedback tint behavior in the style guide.
| iconColor = textColor, | ||
| selectedIconColor = themeColors.primary, | ||
| // Match SwiftUI Color.gray.opacity(0.4); Compose Color.Gray uses a lighter RGB value. | ||
| dimmedIconColor = Color(red = 0.5f, green = 0.5f, blue = 0.5f, alpha = 0.4f), |
There was a problem hiding this comment.
(0.5, 0.5, 0.5) is UIKit's UIColor.gray, but SwiftUI Color.gray is a different color. It resolves to system gray, (142, 142, 147) / #8E8E93. I checked Color.gray.resolve(in:) and UIColor(Color.gray) on the iOS simulator, and it's the same in light and dark. So the comment above is reversed: Compose Color.Gray (#888888) is actually closer to iOS than this value.
Suggest:
// Match SwiftUI Color.gray.opacity(0.4) (system gray #8E8E93 at 40%).
dimmedIconColor = Color(0x668E8E93),The expected values in FeedbackIconColorsTest (lines 112 and 150) and the RGB in the style guide would need to change to match.
There was a problem hiding this comment.
Looks good, #8E8E93 at 40% matches SwiftUI Color.gray.opacity(0.4). Thanks!
| | `behavior.feedback.showCancelButton` | boolean \| null | `null` | Cancel button visibility. `null` = shown for `"modal"`, hidden for `"action"`. Both set to `false` is honored: Submit and (in action mode) drag-down still dismiss. | | ||
| | `behavior.feedback.alwaysDisplay` | boolean | `false` | When `true`, shows the feedback thumbs as soon as the response finishes streaming, bypassing the server's `feedbackEligible` flag. Does not bypass the streaming-complete requirement. | | ||
|
|
||
| Before a vote, both thumbs use the concierge message text color. After a vote, the selected thumb uses the primary brand color and the other thumb uses fixed neutral gray (RGB 128, 128, 128) at 40% opacity, matching iOS. The gray tint is independent of the theme's text color and opacity. This applies to both inline and below-message placement. |
There was a problem hiding this comment.
Since SwiftUI Color.gray is (142, 142, 147), "RGB 128, 128, 128 … matching iOS" isn't accurate. This should be updated along with the color fix.
| } | ||
| assertTrue( | ||
| "${case.name}, below=$showLabel, $vote, $description: expected $expected", | ||
| matchingPixels >= 5 |
There was a problem hiding this comment.
Non-blocking: passing when any 5 pixels roughly match is a fairly loose check. Anti-aliased edges of a wrong (darker) tint can produce pixels that match a lighter expected color, and the count depends on screen density. It might be sturdier to require a minimum fraction of the icon's opaque pixels to match, or to sample known interior pixels of the filled icon. Also note that in the default light theme, text and primary are both black, so that case can't tell the selected thumb from the unvoted one (the dark and custom cases cover it).
There was a problem hiding this comment.
Thanks, the relative sampling is a nice improvement. Left a couple of follow-up notes on the new version.
| spacing = 4.dp, | ||
| iconColor = textColor, | ||
| selectedIconColor = themeColors.primary, | ||
| dimmedIconColor = textColor.copy(alpha = 0.4f), |
There was a problem hiding this comment.
Thanks for switching to a fixed gray, that fixes the theme and alpha issues. The value is still off though: (0.5, 0.5, 0.5) is UIKit UIColor.gray, while SwiftUI Color.gray is system gray (142, 142, 147). Left details on the new line.
| val iconSize: Dp, | ||
| val spacing: Dp, | ||
| val iconColor: Color, | ||
| /** Tint for the thumb that was selected after feedback is submitted. Defaults to the primary brand color, matching iOS. */ |
| // Resolve the tint for each thumb from the feedback state, matching iOS: | ||
| // no vote yet -> default text color; selected thumb -> primary brand color; | ||
| // the thumb not chosen -> dimmed. | ||
| val thumbUpTint = when (feedbackState) { |
There was a problem hiding this comment.
Thanks, iconTintFor plus FeedbackIconTintTest covers this nicely. Left one non-blocking note on the pixel check in FeedbackIconColorsTest.
Use #8E8E93 at 40% opacity for the unselected thumb. Update the style guide and tighten rendered-color assertions to check a fraction of foreground icon pixels.
Compare sampled opaque foreground colors instead of requiring a large fraction of exact-color pixels, which varies with anti-aliasing and emulator density. Retain exact tint assertions in the style test.
rymorale
left a comment
There was a problem hiding this comment.
Approved the pr with just a couple of nit / non blocking issues remaining
| (pixel.green - case.background.green) * (pixel.green - case.background.green) + | ||
| (pixel.blue - case.background.blue) * (pixel.blue - case.background.blue) | ||
| } | ||
| .take((foregroundPixels.size * 0.1f).toInt().coerceAtLeast(1)) |
There was a problem hiding this comment.
Non-blocking: this is much better, but "most distant from the background" still isn't quite the same as "fully opaque". In the transparent-text case, the expected unvoted color (#CCFFCC) and the dimmed gray (#D2D2D4) are only ~0.18 apart, which is less than twice the 0.12 tolerance. A wrongly dimmed thumb with partial anti-aliased coverage (about #E4E4E5) is within 0.106 of #CCFFCC and would pass. The coerceAtLeast(1) also means a single pixel can satisfy the check. Sampling known interior pixels of the icon, or requiring a minimum pixel count, would close this off.
| (pixel.blue - case.background.blue) * (pixel.blue - case.background.blue) | ||
| } | ||
| .take((foregroundPixels.size * 0.1f).toInt().coerceAtLeast(1)) | ||
| val sampledColor = Color( |
There was a problem hiding this comment.
nit: if no foreground pixels are found, the averages are NaN and Color(...) throws IllegalArgumentException here, before the mostOpaquePixels.isNotEmpty() check in the assertion runs. The test still fails, but without the helpful message. Asserting non-empty before building sampledColor would keep the context.
| spacing = 4.dp, | ||
| iconColor = textColor, | ||
| selectedIconColor = themeColors.primary, | ||
| dimmedIconColor = textColor.copy(alpha = 0.4f), |
There was a problem hiding this comment.
Fixed with Color(0x668E8E93), thanks!
| iconColor = textColor, | ||
| selectedIconColor = themeColors.primary, | ||
| // Match SwiftUI Color.gray.opacity(0.4); Compose Color.Gray uses a lighter RGB value. | ||
| dimmedIconColor = Color(red = 0.5f, green = 0.5f, blue = 0.5f, alpha = 0.4f), |
There was a problem hiding this comment.
Looks good, #8E8E93 at 40% matches SwiftUI Color.gray.opacity(0.4). Thanks!
| | `behavior.feedback.showCancelButton` | boolean \| null | `null` | Cancel button visibility. `null` = shown for `"modal"`, hidden for `"action"`. Both set to `false` is honored: Submit and (in action mode) drag-down still dismiss. | | ||
| | `behavior.feedback.alwaysDisplay` | boolean | `false` | When `true`, shows the feedback thumbs as soon as the response finishes streaming, bypassing the server's `feedbackEligible` flag. Does not bypass the streaming-complete requirement. | | ||
|
|
||
| Before a vote, both thumbs use the concierge message text color. After a vote, the selected thumb uses the primary brand color and the other thumb uses fixed neutral gray (RGB 128, 128, 128) at 40% opacity, matching iOS. The gray tint is independent of the theme's text color and opacity. This applies to both inline and below-message placement. |
| } | ||
| assertTrue( | ||
| "${case.name}, below=$showLabel, $vote, $description: expected $expected", | ||
| matchingPixels >= 5 |
There was a problem hiding this comment.
Thanks, the relative sampling is a nice improvement. Left a couple of follow-up notes on the new version.
Require multiple foreground samples and tighten tint tolerance in the rendered feedback color test. Assert a minimum sample count before calculating the sampled color.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Measure icon coverage using independent black-on-white reference renders and compare each sampled pixel against its coverage-adjusted expected tint. Keep the 0.05 channel tolerance and require at least eight reference samples. Add regression checks rejecting the wrong dimmed gray and insufficient reference samples. No production code or dependency changes.
Summary
The selected feedback thumb now uses the primary brand color and the unselected thumb dims, matching iOS behavior. Previously Android kept a single icon color for all states.
Changes
selectedIconColor(primary brand color) anddimmedIconColor(SwiftUI system gray#8E8E93at 40% opacity) toFeedbackButtonsStyle.FeedbackComponents.kt:Behavior parity
#8E8E93at 40%#8E8E93at 40%Testing
FeedbackIconTintTest: 3 unit tests passed.FeedbackComponentsTest,FeedbackIconColorsTest, andConciergeStylesTest: 66 instrumented tests passed on the Android 17 emulator.