Refactor the attachment factories to match with the new designs#6241
Draft
Refactor the attachment factories to match with the new designs#6241
Conversation
Contributor
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
Contributor
SDK Size Comparison 📏
|
aabb129 to
98652f8
Compare
98652f8 to
1e60eb1
Compare
…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.
1e60eb1 to
041da4a
Compare
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Goal
Describe why we are making this change
Implementation
Describe the implementation
🎨 UI Changes
Add relevant screenshots
Add relevant videos
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