Skip to content
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

[AND-318] Fix fading issue in media attachment content items #5631

Merged
merged 11 commits into from
Feb 19, 2025

Conversation

andremion
Copy link
Contributor

@andremion andremion commented Feb 12, 2025

🎯 Goal

Address #5582

🛠 Implementation details

  • Introduce ShimmerProgressIndicator component, which can be used to indicate loading states. It uses a default StreamShimmerTheme provided as a local composition component through the ChatTheme.
  • Replace StreamImage with StreamAsyncImage in MediaAttachmentContent and handles content for the each async image state using the foundation Crossfade animation component.
  • Replace StreamImage with StreamAsyncImage in MediaGalleryPreviewActivity and GiphyAttachmentContent so that we can remove the dependency of placeholder.shimmer.ShimmerPlugin from Compose SDK.

🎨 UI Changes

MediaAttachmentContent

Before After
media.issue.webm
media.fix.webm

GiphyAttachmentContent

Before After
giphy.before.webm
giphy.media.after.webm

🎉 GIF

gif

Copy link
Contributor

github-actions bot commented Feb 12, 2025

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 3.17 MB 3.17 MB 0.00 MB 🟢
stream-chat-android-offline 3.38 MB 3.38 MB 0.00 MB 🟢
stream-chat-android-ui-components 7.87 MB 7.87 MB 0.00 MB 🟢
stream-chat-android-compose 8.75 MB 8.75 MB 0.01 MB 🟢

@andremion andremion force-pushed the media-attachment-content-item-fix branch 2 times, most recently from cc52f97 to 308ebd6 Compare February 13, 2025 10:18
@andremion andremion added bug Something isn't working compose Jetpack Compose labels Feb 13, 2025
@andremion andremion changed the title Media attachment content item fix [AND-238] Media attachment content item fix Feb 13, 2025
@andremion andremion force-pushed the media-attachment-content-item-fix branch from 308ebd6 to e0e361d Compare February 13, 2025 10:28
@andremion andremion changed the title [AND-238] Media attachment content item fix [AND-218] Media attachment content item fix Feb 13, 2025
@andremion andremion force-pushed the media-attachment-content-item-fix branch from 5872224 to db8b077 Compare February 13, 2025 13:19
@andremion andremion marked this pull request as ready for review February 13, 2025 13:59
@andremion andremion requested a review from a team as a code owner February 13, 2025 13:59
@andremion andremion force-pushed the media-attachment-content-item-fix branch from d24026b to 3753cf8 Compare February 13, 2025 14:21
@andremion andremion changed the title [AND-218] Media attachment content item fix [AND-218] Media attachment content fix Feb 13, 2025
Copy link
Contributor

@skydoves skydoves left a comment

Choose a reason for hiding this comment

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

Overall, it looks good to me! Out of curiosity, are there any critical issues with the previous StreamImage, or specific benefits to migrating to StreamAsyncImage? Since I've been maintaining Landscapist myself, I'd be happy to address any issues or improvements if needed.

@andremion
Copy link
Contributor Author

Overall, it looks good to me! Out of curiosity, are there any critical issues with the previous StreamImage, or specific benefits to migrating to StreamAsyncImage? Since I've been maintaining Landscapist myself, I'd be happy to address any issues or improvements if needed.

Thanks for reviewing it, @skydoves

We have seen issues like that, which also happens with the avatars because they use the CrossfadePlugin.

The idea with moving out from StreamImage was to make it simpler to maintain and give more flexibility to build content based on the image loading states.

@skydoves
Copy link
Contributor

To be honest, I don’t see the advantages you mentioned—"simpler to maintain and provides more flexibility for building content based on image loading states"—since Landscapist already offers richer APIs that support these functionalities.

Such as,

@andremion
Copy link
Contributor Author

To be honest, I don’t see the advantages you mentioned—"simpler to maintain and provides more flexibility for building content based on image loading states"—since Landscapist already offers richer APIs that support these functionalities.

Such as,

The Landscapist is a great library, indeed. It has innumerable possibilities for customization.
However, IMO, when it comes to a chat library, a couple of helper-composable functions and Coil dependency should be enough to support their features, with no need for any other external dependency.

Base automatically changed from AND-313-avatar-fading-fix to develop February 17, 2025 12:27
@andremion andremion force-pushed the media-attachment-content-item-fix branch from 3753cf8 to ccf4cd8 Compare February 17, 2025 12:38
@andremion andremion changed the title [AND-218] Media attachment content fix [AND-318] Media attachment content fix Feb 17, 2025
@andremion andremion changed the title [AND-318] Media attachment content fix [AND-318] Fix fading issue in media attachment content items Feb 17, 2025
@andremion andremion force-pushed the media-attachment-content-item-fix branch from df28da5 to 96aa2bf Compare February 18, 2025 09:24
@skydoves
Copy link
Contributor

I understand your concerns, and that’s a great point. The reason I introduced Landscapist was for its greater flexibility in state customization and additional features like crossfade, shimmering effects, placeholders, and seamless previews, which offload responsibilities to the library. However, as you mentioned, implementing all the things ourselves also has its advantages, such as reducing dependency on third-party libraries, and we can customize them under our control.

Since we've already started the migration, we can consider removing all landscapist dependencies across the project to maintain consistency, not at once but gradually. What do you think?

Copy link

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@JcMinarro JcMinarro merged commit f4a2d18 into develop Feb 19, 2025
12 of 13 checks passed
@JcMinarro JcMinarro deleted the media-attachment-content-item-fix branch February 19, 2025 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compose Jetpack Compose
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants