Skip to content

Replace old Avatar implementation with redesigned one#6100

Merged
gpunto merged 9 commits intov7from
redesign/avatar-replace
Jan 26, 2026
Merged

Replace old Avatar implementation with redesigned one#6100
gpunto merged 9 commits intov7from
redesign/avatar-replace

Conversation

@gpunto
Copy link
Contributor

@gpunto gpunto commented Jan 23, 2026

🎯 Goal

Actually use the avatar implementation brought in #6089.

🛠 Implementation details

  • Replace previous avatar composables with the new ones
  • Restructure a bit the files
  • Introduce new AvatarSize extra large
  • Update KDoc

🎨 UI Changes

Before After
Screenshot_20260123_163828 Screenshot_20260123_163717
Screenshot_20260123_163837 Screenshot_20260123_163908

🧪 Testing

You can see it in action in the sample.

Summary by CodeRabbit

  • New Features

    • Added AvatarSize object with five predefined avatar sizes (ExtraSmall, Small, Medium, Large, ExtraLarge)
    • Added showBorder flag to control avatar border visibility
    • Added new typography style headingLarge for improved typographic options
  • Bug Fixes

    • Simplified avatar component APIs for more consistent rendering
    • Improved online indicator handling with cleaner parameter names
  • Chores

    • Refactored avatar components for streamlined configuration
    • Removed deprecated avatar variants and consolidated avatar rendering logic

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.25 MB 5.25 MB 0.00 MB 🟢
stream-chat-android-offline 5.48 MB 5.48 MB 0.00 MB 🟢
stream-chat-android-ui-components 10.62 MB 10.61 MB -0.01 MB 🚀
stream-chat-android-compose 12.84 MB 11.64 MB -1.20 MB 🚀

@gpunto gpunto marked this pull request as ready for review January 26, 2026 09:52
@gpunto gpunto requested a review from a team as a code owner January 26, 2026 09:52
@gpunto
Copy link
Contributor Author

gpunto commented Jan 26, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 26, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Jan 26, 2026

Walkthrough

This 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

Cohort / File(s) Summary
Avatar Component Core Refactoring
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/avatar/Avatar.kt, UserAvatar.kt, ChannelAvatar.kt, AvatarPlaceholder.kt, AvatarStack.kt, OnlineIndicator.kt
Simplified Avatar to accept nullable imageUrl, fallback composable, and showBorder flag; removed initials/textStyle/shape parameters. UserAvatar reduced to user, modifier, showIndicator, showBorder. ChannelAvatar simplified similarly. Introduced AvatarSize object with ExtraSmall/Small/Medium/Large/ExtraLarge. Updated OnlineIndicator to use OnlineIndicatorDimensions enum with offset property and ExtraLarge variant.
Removed Avatar Components
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/avatar/GroupAvatar.kt, ImageAvatar.kt, InitialsAvatar.kt, UserAvatarRow.kt, StreamAvatar.kt
Deleted five avatar-related files: GroupAvatar composable rendering 2-column grid, ImageAvatar rendering images with optional click, InitialsAvatar rendering text-based avatars, UserAvatarRow for horizontal avatar rows, and StreamAvatar containing legacy implementations.
ChatComponentFactory API Updates
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/ChatComponentFactory.kt
Updated public method signatures: Avatar changed from multi-parameter (imageUrl, initials, shape, textStyle, etc.) to simplified form (imageUrl, fallback, showBorder). UserAvatar signature reduced; ChannelAvatar signature reduced. Removed FallbackAvatar and GroupAvatar exports.
Typography and Theme Tokens
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/StreamTypography.kt, StreamTokens.kt
Added headingLarge TextStyle property to StreamTypography initialized with fontWeightSemiBold, fontSizeXl, lineHeightRelaxed. Added fontSizeXl (20.sp) and lineHeightRelaxed (24.sp) to StreamTokens.
Avatar Usages in Channel/Info Components
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/info/ChannelInfoMemberInfoModalSheet.kt, DirectChannelInfoScreen.kt, GroupChannelInfoScreen.kt, ChannelMediaAttachmentsScreen.kt, attachments/preview/internal/MediaGalleryPhotosMenu.kt
Replaced Avatar/UserAvatar invocations with simplified parameters: removed textStyle, showOnlineIndicator, onlineIndicator, onClick; added showIndicator/showBorder flags. Updated imports to remove OnlineIndicatorAlignment and DefaultOnlineIndicator.
Avatar Usages in Channel List Components
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channels/header/ChannelListHeader.kt, list/ChannelItem.kt, list/SearchResultItem.kt, channels/ChannelMembersItem.kt
Updated ChannelAvatar and UserAvatar invocations to use showIndicator/showBorder instead of showOnlineIndicator/onlineIndicator. Removed textStyle parameters and onClick handlers. Added showBorder = false where applicable.
Avatar Usages in Message Components
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/header/MessageListHeader.kt, messages/list/MessageItem.kt, messages/preview/internal/MessagePreviewItem.kt, components/messages/ThreadParticipants.kt, threads/ThreadItem.kt
Replaced Avatar/UserAvatar calls with simplified signatures. Moved click handling to modifier-based clickable wrapper using ifNotNull utility. Removed textStyle, onlineIndicator, and onClick parameters; added showIndicator/showBorder flags.
Avatar Usages in Poll/Reaction Components
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/PollMessageContent.kt, components/poll/PollAnswers.kt, components/poll/PollVoteItem.kt, components/userreactions/UserReactionItem.kt
Updated Avatar/UserAvatar usages to new API. Replaced hardcoded sizes with AvatarSize constants (ExtraSmall, Medium, Large). Removed initials/image-based rendering in favor of user object. Updated PollMessageContent to use UserAvatarStack with spacing/size/border config.
Avatar Usages in Suggestion Components
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/suggestions/mentions/MentionSuggestionItem.kt
Updated UserAvatar call to use showIndicator instead of showOnlineIndicator, removed onlineIndicator and onClick parameters, added showBorder = false.
Sample App Avatar Size Migrations
stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/feature/channel/add/AddChannelScreen.kt, feature/channel/add/component/SearchUserResultsContent.kt, feature/channel/add/group/AddGroupChannelScreen.kt, feature/channel/list/ChannelsScreenNavigationDrawer.kt, feature/reminders/MessageRemindersScreen.kt, ui/login/UserLoginActivity.kt
Replaced hardcoded avatar sizes (24.dp, 32.dp, 40.dp) with AvatarSize constants (Small, Medium, Large, ExtraLarge). Added AvatarSize imports.
Sample App Avatar Component Migrations
stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/ui/channel/AddMembersDialog.kt, ui/component/MessageInfoComponentFactory.kt, ui/component/SharedLocationItem.kt, ui/profile/UserProfileScreen.kt
Updated avatar components to use new API. Replaced Avatar with UserAvatar where applicable. Changed showOnlineIndicator to showIndicator. Wrapped avatars with clickable modifiers using ifNotNull. Updated UserAvatar parameter showOnlineIndicator to showIndicator and added showBorder configurations.
Documentation and Utility Updates
stream-chat-android-docs/src/main/kotlin/io/getstream/chat/docs/kotlin/compose/messages/MessageList.kt, compose/utility/ChannelAvatar.kt, compose/utility/UserAvatar.kt, stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/ModifierUtils.kt
Updated documentation examples to use new Avatar/UserAvatar APIs. Added ifNotNull inline modifier extension for conditional modifier application. Moved click handling from composable parameters to modifier-based approach in examples.
Test Updates
stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/components/UserAvatarTest.kt, uicomponents/channels/ChannelListItemViewTest.kt
Updated UserAvatar test invocations to use showIndicator instead of showOnlineIndicator/onlineIndicatorAlignment. Removed channelLastMessageAt test data in some scenarios.
Public API Surface (stream-chat-android-compose.api)
stream-chat-android-compose/api/stream-chat-android-compose.api
Updated ComposableSingletons and UI component interface signatures across ChannelInfo, ChannelList, Thread, Attachment, and Message components to reflect reduced lambda arities (Function3→Function2, Function4→Function3, etc.). Updated ChatComponentFactory Avatar/UserAvatar/ChannelAvatar method signatures. Added new AvatarSize accessor. Updated StreamTypography with component17 and getHeadingLarge() accessor.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~90 minutes

Possibly related PRs

  • Introduce new Avatar designs #6089: Directly introduces the new Avatar/UserAvatar API surface, AvatarSize constants, OnlineIndicator refactoring, and simplified composable signatures—core implementation that this PR applies throughout the codebase.
  • Message Composer structural redesign #6088: Refactors Avatar/UserAvatar APIs and adds/renames AvatarSize accessors in the theme layer, providing foundational API changes that cascade through this PR's usages.

Suggested labels

compose, ui-components

Suggested reviewers

  • andremion
  • VelikovPetar

Poem

🐰 Avatars once bloated with sizes and styles,
Now simplified gracefully, making us smile,
AvatarSize holds the new rightful place,
UserAvatar's showIndicator lights up the face,
Cleaner composables across the land! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: replacing the old Avatar implementation with a redesigned one, which aligns with the core objective of the PR.
Description check ✅ Passed The description covers the goal, implementation details, and includes UI changes with before/after screenshots and testing information, though some template sections like changelog and contributor checklist are incomplete.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 (just showIndicator = 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 using StreamPreview helpers for preview.

Based on learnings, Compose previews in this codebase should use StreamPreview helpers 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 new headingLarge parameter.

The class KDoc documents all other typography properties with @param tags (lines 29-44), but headingLarge is missing. As per coding guidelines, public APIs should be documented with KDoc.

📝 Suggested KDoc addition

Add the following @param tag 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 @StreamPreview helper for consistency.

Per coding guidelines, Compose previews in the main compose library should use @StreamPreview helpers. Based on learnings, Compose previews should use StreamPreview helpers.

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/avatar/AvatarStack.kt (1)

60-67: Consider using @StreamPreview helper for consistency.

Per coding guidelines, Compose previews in the main compose library should use @StreamPreview helpers. Based on learnings, Compose previews should use StreamPreview helpers.

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/avatar/Avatar.kt (1)

93-96: Use StreamPreview for Compose previews in this module.
Please swap @Preview for the project’s @StreamPreview helper to keep previews consistent with the compose module conventions.

As per coding guidelines, please use StreamPreview helpers for previews in stream-chat-android-compose/**/*.kt.

@sonarqubecloud
Copy link

@gpunto gpunto merged commit 020205f into v7 Jan 26, 2026
18 of 19 checks passed
@gpunto gpunto deleted the redesign/avatar-replace branch January 26, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants