feat(ui): factory slots for message item leading, header, footer#2710
feat(ui): factory slots for message item leading, header, footer#2710xsahil03x wants to merge 3 commits into
Conversation
Move the leading avatar rendering out of DefaultStreamMessageItem.build and into its own NullableStatelessWidget under components/, mirroring the structure already used by StreamMessageHeader and StreamMessageFooter. Behavior is unchanged; the three slots are now composed symmetrically. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v10.0.0 #2710 +/- ##
==========================================
Coverage ? 67.59%
==========================================
Files ? 408
Lines ? 24506
Branches ? 0
==========================================
Hits ? 16564
Misses ? 7942
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Register messageLeading, messageHeader, and messageFooter in streamChatComponentBuilders so integrators can override each sub-component independently instead of replacing the whole messageItem. Each slot follows the same shape as StreamMessageItem: a public widget that resolves chatComponentBuilder<...Props>(), a Props data class, and a DefaultStream... implementation holding the rendering. The widgets are now exported from the package barrel. Closes a gap with iOS (makeUserAvatarView), Android Compose (MessageAuthor / MessageTop / MessageBottom) and React Native (MessageAuthor / MessageHeader / MessageFooter). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
19550de to
b2d686e
Compare
…cing When the leading slot's nullableBuild returns null (e.g. message.user is null) the framework substitutes _CollapsedWidget. A regular Row counts this as a child and applies its spacing, leaving an extra gap before the content column. StreamRow skips _RenderCollapsed children, matching the StreamColumn already used inside StreamMessageContent for header and footer. Defers the visibility decision to the theme: if a theme resolves the avatar to .visible while message.user is null, the slot renders an empty widget without disturbing the row's horizontal rhythm. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
messageItem, which forced integrators to replace the entire item even when they only wanted to swap the avatar, the pinned/reminder annotations, or the timestamp row.makeUserAvatarView(ViewFactory.swift:120-123)MessageAuthor/MessageTop/MessageBottomonChatComponentFactoryMessageAuthor/MessageHeader/MessageFooteron the components contextWhat's in this PR
Commit 1 —
refactor(ui): extract StreamMessageLeading from message itemExtracts the message item's inline avatar block (
stream_message_item.dart:433-443) into a newStreamMessageLeadingwidget undercomponents/, mirroring the existingStreamMessageHeaderandStreamMessageFooter.DefaultStreamMessageItemnow composes leading, header, and footer symmetrically.Commit 2 —
feat(ui): factory slots for message item leading, header, footerRefactors each of the three sub-components into the
StreamMessageItemshape (public widget →Default…impl →…Props) and registers three new keys instreamChatComponentBuilders:The widgets are also exported from the package barrel so integrators can reference the props and default classes from their custom builders.
Usage
Each slot is independently overridable — none of them require touching the whole
messageItem.Test plan
dart analyze --fatal-infos packages/stream_chat_flutter— cleandart format— clean (page width 120)melos run test:flutter— golden tests forStreamMessageItemstill match (no visual change expected; local run shows 115 pre-existing macOS golden mismatches unrelated to this change, none referencing the touched files)🤖 Generated with Claude Code