Skip to content

Refactor the attachment factories to match with the new designs#6241

Draft
andremion wants to merge 15 commits intov7from
redesign/AND-1114-refactor-the-attachment-factories
Draft

Refactor the attachment factories to match with the new designs#6241
andremion wants to merge 15 commits intov7from
redesign/AND-1114-refactor-the-attachment-factories

Conversation

@andremion
Copy link
Contributor

Goal

Describe why we are making this change

Implementation

Describe the implementation

🎨 UI Changes

Add relevant screenshots

Before After
img img

Add relevant videos

Before After

Testing

Explain how this change can be tested (or why it can't be tested)

Provide a patch below if it is necessary for testing

Provide the patch summary here
Provide the patch code here

@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled.

🎉 Great job! This PR is ready for review.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.25 MB 5.70 MB 0.45 MB 🟡
stream-chat-android-ui-components 10.60 MB 11.00 MB 0.40 MB 🟡
stream-chat-android-compose 12.81 MB 12.04 MB -0.78 MB 🚀

@andremion andremion force-pushed the redesign/AND-1114-refactor-the-attachment-factories branch from aabb129 to 98652f8 Compare March 11, 2026 17:31
@andremion andremion added pr:breaking-change Breaking change pr:new-feature New feature labels Mar 12, 2026
@andremion andremion force-pushed the redesign/AND-1114-refactor-the-attachment-factories branch from 98652f8 to 1e60eb1 Compare March 12, 2026 11:28
…ovided by `ChatTheme.componentFactory` to support component overriding
- Delete `AudioRecordAttachmentPreviewContent`, `FileAttachmentPreviewContent`, `ImageAttachmentPreviewContent`, and `MediaAttachmentPreviewContent` from the `io.getstream.chat.android.compose.ui.attachments.content` package.
- Introduce new internal components in `io.getstream.chat.android.compose.ui.messages.composer.internal.attachments`: `MessageComposerAttachments`, `MessageComposerAttachmentAudioRecordItem`, `MessageComposerAttachmentFileItem`, and `MessageComposerAttachmentMediaItem`.
- Consolidate attachment rendering logic into `MessageComposerAttachments`, using a single horizontal scrolling `LazyRow` to handle different attachment types (audio, image/video, files).
- Integrate `AudioPlayerViewModel` and lifecycle management directly into the new attachment components for audio recording previews.
- Update `PreviewAttachmentData` to use `AttachmentType` constants and include additional sample data for files and audio recordings.
- Leverage `ChatTheme.componentFactory` for rendering specific attachment items to support better extensibility.
…ne their respective parameter classes.

- Introduce `MessageComposerAttachmentsParams`, `MessageComposerAttachmentAudioRecordItemParams`, `MessageComposerAttachmentMediaItemParams`, `MessageComposerAttachmentMediaItemOverlayParams`, and `MessageComposerAttachmentFileItemParams` to encapsulate component parameters.
- Add `MessageComposerAttachments` to `ChatComponentFactory` for rendering the horizontal row of selected attachments.
- Add specialized factory methods for individual attachment types: `MessageComposerAttachmentAudioRecordItem`, `MessageComposerAttachmentMediaItem`, `MessageComposerAttachmentMediaItemOverlay`, and `MessageComposerAttachmentFileItem`.
- Remove `FileAttachmentPreviewContent` from the factory in favor of the new granular attachment components.
…napshot tests.

- Create `MessageComposerAttachmentsTest` to test attachment items within the message composer, including audio records, media, and files.
- Move snapshot tests for file, image, and media attachment previews from `AttachmentsContentTest` to the new `MessageComposerAttachmentsTest`.
- Update snapshot image references to reflect the new test structure and locations.
…ment` for better `ViewModelStore` management.

- Introduce `TestEnvironment` composable in `PaparazziComposeTest` to provide common `CompositionLocal` values, including a new `FakeViewModelStoreOwner`.
- Update `snapshot`, `snapshotWithDarkMode`, and `snapshotComparison` to utilize the `TestEnvironment`.
- Remove the redundant `ViewModelStore` wrapper from individual test files, including `AttachmentMediaPickerTest`, `AttachmentFilePickerTest`, `AttachmentSystemPickerTest`, and `CreatePollScreenTest`.
- Ensure all tests that require a `ViewModel` have a valid `LocalViewModelStoreOwner` provided automatically.
…f a more direct, component-based approach.

- **Refactor Message Composer UI**: Replaced dynamic attachment previews in `MessageInput` with explicit calls to `ChatTheme.componentFactory.MessageComposerAttachments`.
- **Simplify `MessagePreviewFormatter`**: Removed dependency on `AttachmentFactory`. The preview text for attachments now defaults to a join of the title, name, or fallback fields.
- **Streamline `ChatTheme`**: Removed `attachmentFactories` from the theme and `LocalAttachmentFactories` from the composition locals.
- **API Clean-up**: Removed several internal preview content composables and simplified the public API surface area related to attachment handling.
- Remove `MultimediaAttachmentFactory.kt` and `dateAttachmentFactory` in favor of overriding methods in `ChatComponentFactory`.
- Update `CustomChatComponentFactory` to override `MessageComposerAttachments`, providing custom logic for filtering and rendering date-type attachments.
- Implement `MessageComposerAttachmentMediaItemOverlay` in `CustomMediaChatComponentFactory` to handle custom video play button overlays in the message composer.
- Simplify `ChatTheme` initialization in `ChannelsActivity` and `MessagesActivity` by removing explicit `attachmentFactories` lists.
- Update documentation and guide samples to reflect the shift from `AttachmentFactory` to `ChatComponentFactory` for UI customization.
@andremion andremion force-pushed the redesign/AND-1114-refactor-the-attachment-factories branch from 1e60eb1 to 041da4a Compare March 12, 2026 15:15
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
71.3% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:breaking-change Breaking change pr:new-feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant