-
Notifications
You must be signed in to change notification settings - Fork 376
refactor(ui)!: redesign Avatar components #2502
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
+944
−938
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d2f6653
feat(ui): add new avatar components
xsahil03x e3f6040
refactor(ui)!: Redesign Avatar components
xsahil03x bbcd62b
feat: Use git version for stream_core_flutter
xsahil03x 6e34e50
chore: skip smudge on CI
xsahil03x dadceee
docs: update user avatar group/stack doc comments
xsahil03x a116c5a
chore: Update Goldens
xsahil03x c867072
fix: set user avatar size in thread list tile
xsahil03x bb06d81
chore: Update Goldens
xsahil03x a81f99f
docs: add theming guide for redesigned components
xsahil03x c82b422
chore: pin stream_core_flutter dependency to a specific commit
xsahil03x ffe2720
feat: Sort users to show current user first
xsahil03x cc1045e
chore: prevent publishing of stream_core_flutter until available on p…
xsahil03x 84f7954
chore: update stream_core_flutter dependency
xsahil03x 285b47b
chore: remove GIT_LFS_SKIP_SMUDGE from workflows
xsahil03x File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Stream Chat Flutter UI Redesign Migration Guide | ||
|
|
||
| This folder contains migration guides for the redesigned UI components in Stream Chat Flutter SDK. | ||
|
|
||
| ## Overview | ||
|
|
||
| The redesigned components aim to provide: | ||
| - Simplified and consistent APIs | ||
| - Better theme integration | ||
| - Improved developer experience | ||
| - Reduced boilerplate | ||
|
|
||
| Each component migration guide contains specific details about the changes and how to migrate. | ||
|
|
||
| ## Theming | ||
|
|
||
| The redesigned components use `StreamTheme` for theming. If no `StreamTheme` is provided, a default theme is automatically created based on `Theme.of(context).brightness` (light or dark mode). | ||
|
|
||
| To customize the default theming, add `StreamTheme` as a theme extension to your `MaterialApp`: | ||
|
|
||
| ```dart | ||
| MaterialApp( | ||
| theme: ThemeData( | ||
| extensions: [ | ||
| StreamTheme( | ||
| brightness: Brightness.light, | ||
| colorScheme: StreamColorScheme.light().copyWith( | ||
| // Customize colors... | ||
| ), | ||
| avatarTheme: const StreamAvatarThemeData( | ||
| // Customize avatar defaults... | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| // ... | ||
| ) | ||
| ``` | ||
|
|
||
| You can also use the convenience factories `StreamTheme.light()` or `StreamTheme.dark()` as a starting point. | ||
|
|
||
| ## Components | ||
|
|
||
| | Component | Migration Guide | | ||
| |-----------|-----------------| | ||
| | Stream Avatar | [stream_avatar.md](stream_avatar.md) | | ||
|
|
||
| ## Need Help? | ||
|
|
||
| If you encounter any issues during migration or have questions, please [open an issue](https://github.com/GetStream/stream-chat-flutter/issues) on GitHub. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,225 @@ | ||
| # Stream Avatar Components Migration Guide | ||
|
|
||
| This guide covers the migration for the redesigned avatar components in Stream Chat Flutter SDK. | ||
|
|
||
| --- | ||
|
|
||
| ## Table of Contents | ||
|
|
||
| - [Quick Reference](#quick-reference) | ||
| - [StreamUserAvatar](#streamuseravatar) | ||
| - [StreamChannelAvatar](#streamchannelavatar) | ||
| - [StreamGroupAvatar](#streamgroupavatar) | ||
| - [StreamUserAvatarStack](#streamuseravatarstack) | ||
| - [Size Reference](#size-reference) | ||
| - [Migration Checklist](#migration-checklist) | ||
|
|
||
| --- | ||
|
|
||
| ## Quick Reference | ||
|
|
||
| | Component | Key Changes | | ||
| |-----------|-------------| | ||
| | [**StreamUserAvatar**](#streamuseravatar) | `constraints` → `size` enum, `showOnlineStatus` → `showOnlineIndicator`, `onTap` removed | | ||
| | [**StreamChannelAvatar**](#streamchannelavatar) | `constraints` → `size` enum, `onTap` and builder callbacks removed | | ||
| | [**StreamGroupAvatar**](#streamgroupavatar) | Renamed to `StreamUserAvatarGroup`, `members` → `users` | | ||
| | [**StreamUserAvatarStack**](#streamuseravatarstack) | New component for overlapping avatars | | ||
|
|
||
| --- | ||
|
|
||
| ## StreamUserAvatar | ||
|
|
||
| ### Breaking Changes: | ||
|
|
||
| - `constraints` parameter replaced with `size` enum (`StreamAvatarSize`) | ||
| - `showOnlineStatus` renamed to `showOnlineIndicator` | ||
| - `onTap` callback removed — wrap with `GestureDetector` or `InkWell` instead | ||
| - `borderRadius` parameter removed | ||
| - `selected`, `selectionColor`, `selectionThickness` parameters removed | ||
| - `onlineIndicatorAlignment` and `onlineIndicatorConstraints` removed | ||
|
|
||
| ### Migration: | ||
|
|
||
| **Before:** | ||
| ```dart | ||
| StreamUserAvatar( | ||
| user: user, | ||
| constraints: BoxConstraints.tight(const Size(40, 40)), | ||
| borderRadius: BorderRadius.circular(20), | ||
| showOnlineStatus: false, | ||
| onTap: (user) => print('Tapped ${user.name}'), | ||
| ) | ||
| ``` | ||
|
|
||
| **After:** | ||
| ```dart | ||
| GestureDetector( | ||
| onTap: () => print('Tapped ${user.name}'), | ||
| child: StreamUserAvatar( | ||
| size: StreamAvatarSize.lg, | ||
| user: user, | ||
| showOnlineIndicator: false, | ||
| ), | ||
| ) | ||
| ``` | ||
|
|
||
| > **Important:** | ||
| > - Use `GestureDetector` or `InkWell` to handle tap events | ||
| > - Use `StreamAvatarSize` enum values (`.xs`, `.sm`, `.md`, `.lg`, `.xl`) instead of `BoxConstraints` | ||
| > - See [Size Reference](#size-reference) for mapping old constraints to new enum values | ||
|
|
||
| --- | ||
|
|
||
| ## StreamChannelAvatar | ||
|
|
||
| ### Breaking Changes: | ||
|
|
||
| - `constraints` parameter replaced with `size` enum (`StreamAvatarGroupSize`) | ||
| - `onTap` callback removed — wrap with `GestureDetector` or `InkWell` instead | ||
| - `borderRadius` parameter removed | ||
| - `selected`, `selectionColor`, `selectionThickness` parameters removed | ||
| - `ownSpaceAvatarBuilder`, `oneToOneAvatarBuilder`, `groupAvatarBuilder` callbacks removed | ||
|
|
||
| ### Migration: | ||
|
|
||
| **Before:** | ||
| ```dart | ||
| StreamChannelAvatar( | ||
| channel: channel, | ||
| constraints: BoxConstraints.tight(const Size(40, 40)), | ||
| onTap: () => print('Tapped channel'), | ||
| selected: isSelected, | ||
| ) | ||
| ``` | ||
|
|
||
| **After:** | ||
| ```dart | ||
| GestureDetector( | ||
| onTap: () => print('Tapped channel'), | ||
| child: StreamChannelAvatar( | ||
| size: StreamAvatarGroupSize.lg, | ||
| channel: channel, | ||
| ), | ||
| ) | ||
| ``` | ||
|
|
||
| > **Important:** | ||
| > - Use `StreamAvatarGroupSize` enum values (`.lg`, `.xl`) instead of `BoxConstraints` | ||
| > - Custom avatar builders are no longer supported | ||
|
|
||
| --- | ||
|
|
||
| ## StreamGroupAvatar | ||
|
|
||
| ### Breaking Changes: | ||
|
|
||
| - Renamed from `StreamGroupAvatar` to `StreamUserAvatarGroup` | ||
| - `members` parameter replaced with `users` (`Iterable<User>` instead of `List<Member>`) | ||
| - `constraints` parameter replaced with `size` enum (`StreamAvatarGroupSize`) | ||
| - `channel` parameter removed | ||
| - `onTap` callback removed — wrap with `GestureDetector` or `InkWell` instead | ||
| - `borderRadius` parameter removed | ||
| - `selected`, `selectionColor`, `selectionThickness` parameters removed | ||
|
|
||
| ### Migration: | ||
|
|
||
| **Before:** | ||
| ```dart | ||
| StreamGroupAvatar( | ||
| channel: channel, | ||
| members: otherMembers, | ||
| constraints: BoxConstraints.tight(const Size(40, 40)), | ||
| onTap: () => print('Tapped group'), | ||
| ) | ||
| ``` | ||
|
|
||
| **After:** | ||
| ```dart | ||
| GestureDetector( | ||
| onTap: () => print('Tapped group'), | ||
| child: StreamUserAvatarGroup( | ||
| size: StreamAvatarGroupSize.lg, | ||
| users: otherMembers.map((m) => m.user!), | ||
| ), | ||
| ) | ||
| ``` | ||
|
|
||
| > **Important:** | ||
| > - Extract `User` objects from `Member` when migrating: `members.map((m) => m.user!)` | ||
| > - The component no longer requires a `channel` reference | ||
|
|
||
| --- | ||
|
|
||
| ## StreamUserAvatarStack | ||
|
|
||
| ### Breaking Changes: | ||
|
|
||
| - **New component** for displaying overlapping user avatars (e.g., thread participants) | ||
| - Replaces custom `Stack` + `Positioned` implementations | ||
|
|
||
| ### Parameters: | ||
|
|
||
| | Parameter | Type | Default | Description | | ||
| |-----------|------|---------|-------------| | ||
| | `users` | `Iterable<User>` | required | Users to display | | ||
| | `size` | `StreamAvatarStackSize?` | `.sm` | Size of avatars | | ||
| | `max` | `int` | `5` | Max avatars before overflow badge | | ||
| | `overlap` | `double` | `0.33` | Overlap fraction (0.0 - 1.0) | | ||
|
|
||
| ### Usage: | ||
|
|
||
| ```dart | ||
| StreamUserAvatarStack( | ||
| max: 3, | ||
| size: StreamAvatarStackSize.xs, | ||
| users: threadParticipants, | ||
| ) | ||
| ``` | ||
|
|
||
| > **Important:** | ||
| > - Use this component instead of manually building overlapping avatar stacks | ||
| > - The `overlap` parameter controls how much each avatar overlaps the previous one | ||
|
|
||
| --- | ||
|
|
||
| ## Size Reference | ||
|
|
||
| ### StreamAvatarSize | ||
|
|
||
| | Old Constraints | New Size | Diameter | | ||
| |-----------------|----------|----------| | ||
| | `BoxConstraints.tight(Size(20, 20))` | `.xs` | 20px | | ||
| | `BoxConstraints.tight(Size(24, 24))` | `.sm` | 24px | | ||
| | `BoxConstraints.tight(Size(32, 32))` | `.md` | 32px | | ||
| | `BoxConstraints.tight(Size(40, 40))` | `.lg` | 40px | | ||
| | `BoxConstraints.tight(Size(64, 64))` | `.xl` | 64px | | ||
|
|
||
| ### StreamAvatarGroupSize | ||
|
|
||
| | Old Constraints | New Size | Diameter | | ||
| |-----------------|----------|----------| | ||
| | `BoxConstraints.tight(Size(40, 40))` | `.lg` | 40px | | ||
| | `BoxConstraints.tight(Size(64, 64))` | `.xl` | 64px | | ||
|
|
||
| ### StreamAvatarStackSize | ||
|
|
||
| | Old Constraints | New Size | Diameter | | ||
| |-----------------|----------|----------| | ||
| | `BoxConstraints.tight(Size(20, 20))` | `.xs` | 20px | | ||
| | `BoxConstraints.tight(Size(24, 24))` | `.sm` | 24px | | ||
|
|
||
| > **Note:** | ||
| > If your old constraints don't match exactly, choose the closest available size. | ||
|
|
||
| --- | ||
|
|
||
| ## Migration Checklist | ||
|
|
||
| - [ ] Replace `StreamUserAvatar` `constraints` with `size` enum (`StreamAvatarSize`) | ||
| - [ ] Rename `showOnlineStatus` to `showOnlineIndicator` | ||
| - [ ] Move `onTap` callbacks to parent `GestureDetector` or `InkWell` widgets | ||
| - [ ] Replace `StreamGroupAvatar` with `StreamUserAvatarGroup` | ||
| - [ ] Change `members` parameter to `users` (extract `User` from `Member`) | ||
| - [ ] Replace `StreamChannelAvatar` `constraints` with `size` enum (`StreamAvatarGroupSize`) | ||
| - [ ] Remove `selected`, `selectionColor`, `selectionThickness` parameters | ||
| - [ ] Use `StreamUserAvatarStack` for overlapping avatar displays |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.