Replace old Avatar implementation with redesigned one#6100
Conversation
SDK Size Comparison 📏
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThis PR refactors the avatar component system by simplifying Avatar, UserAvatar, and ChannelAvatar signatures, removing deprecated avatar types, introducing AvatarSize as a centralized sizing object, and updating all usages across codebase, samples, and documentation to align with the new APIs. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~90 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/components/UserAvatarTest.kt (1)
30-35: Snapshot cases no longer reflect different indicator positions.
With alignment options removed, the four “Top/Bottom/Start/End” tests now render the same UI (justshowIndicator = true), making snapshots redundant and names misleading. Consider collapsing to a single online-indicator case or renaming to match the default placement.Also applies to: 39-44, 48-53, 57-62, 66-71, 75-80
🤖 Fix all issues with AI agents
In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/avatar/UserAvatar.kt`:
- Around line 19-83: BoxWithConstraints can pass maxWidth = Dp.Infinity in
unbounded layouts causing Avatar( imageUrl=..., fallback = {
UserAvatarPlaceholder(user, maxWidth) }, modifier = Modifier.size(maxWidth) )
and resolveIndicatorDimensions() to miscompute sizes; update UserAvatar to check
BoxWithConstraintsScope.constraints.hasBoundedWidth and when false use a
concrete fallback size (e.g., AvatarSize.Medium) for both the Modifier.size(...)
and the fallback call (pass a concrete Dp), and use that same finite size when
calling resolveIndicatorDimensions() (or compute dimensions from
AvatarSize.Medium) so OnlineIndicator positioning is correct; apply the
identical guard/fallback change to ChannelAvatar's GroupAvatar composable as
well.
🧹 Nitpick comments (5)
stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/ui/component/MessageInfoComponentFactory.kt (1)
252-254: Consider usingStreamPreviewhelpers for preview.Based on learnings, Compose previews in this codebase should use
StreamPreviewhelpers for consistency. If this convention applies to sample modules as well, consider updating this preview.stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/StreamTypography.kt (1)
64-64: Add KDoc documentation for the newheadingLargeparameter.The class KDoc documents all other typography properties with
@paramtags (lines 29-44), butheadingLargeis missing. As per coding guidelines, public APIs should be documented with KDoc.📝 Suggested KDoc addition
Add the following
@paramtag to the class KDoc (around line 44):* `@param` captionEmphasis Used for emphasized captions requiring attention while maintaining compact display. +* `@param` headingLarge Used for large headings requiring visual prominence. * `@param` metadataEmphasis Used for emphasized metadata and supplementary information in secondary content areas.stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/ChannelMembersItem.kt (1)
78-83: Consider using@StreamPreviewhelper for consistency.Per coding guidelines, Compose previews in the main compose library should use
@StreamPreviewhelpers. Based on learnings, Compose previews should useStreamPreviewhelpers.stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/avatar/AvatarStack.kt (1)
60-67: Consider using@StreamPreviewhelper for consistency.Per coding guidelines, Compose previews in the main compose library should use
@StreamPreviewhelpers. Based on learnings, Compose previews should useStreamPreviewhelpers.stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/avatar/Avatar.kt (1)
93-96: UseStreamPreviewfor Compose previews in this module.
Please swap@Previewfor the project’s@StreamPreviewhelper to keep previews consistent with the compose module conventions.As per coding guidelines, please use
StreamPreviewhelpers for previews instream-chat-android-compose/**/*.kt.
...d-compose/src/main/java/io/getstream/chat/android/compose/ui/components/avatar/UserAvatar.kt
Show resolved
Hide resolved
...va/io/getstream/chat/android/compose/ui/channel/attachments/ChannelMediaAttachmentsScreen.kt
Show resolved
Hide resolved
...ompose/src/main/java/io/getstream/chat/android/compose/ui/components/avatar/ChannelAvatar.kt
Show resolved
Hide resolved
...src/main/java/io/getstream/chat/android/compose/ui/components/messages/ThreadParticipants.kt
Show resolved
Hide resolved
...apshots/images/io.getstream.chat.android.compose.ui.channels_ChannelItemTest_no_messages.png
Show resolved
Hide resolved
|



🎯 Goal
Actually use the avatar implementation brought in #6089.
🛠 Implementation details
🎨 UI Changes
🧪 Testing
You can see it in action in the sample.
Summary by CodeRabbit
New Features
AvatarSizeobject with five predefined avatar sizes (ExtraSmall, Small, Medium, Large, ExtraLarge)showBorderflag to control avatar border visibilityheadingLargefor improved typographic optionsBug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.