google / accompanist

A collection of extension libraries for Jetpack Compose
https://google.github.io/accompanist
Apache License 2.0
7.45k stars 599 forks source link

[Idea] Content placeholder/skeleton UI #336

Closed chrisbanes closed 3 years ago

chrisbanes commented 3 years ago

Something along the lines of https://www.smashingmagazine.com/2020/04/skeleton-screens-react/

I imagine that we can add a Modifier.placeholder(enabled: Boolean), which will draw some skeleton color/shape in-front of the layout content.

kosyak commented 3 years ago

On the other hand - maybe we can have a result: Drawable? on ImageState.Empty and ImageState.Loading? This would be consistent with the current API, but I don't know about fancy stuff like animations (such a placeholder would fullfil my needs - I just need a ColorDrawable or BitmapDrawable to show while loading).

chrisbanes commented 3 years ago

Note: this API is not specific to the image loading libraries. This is a general purpose placeholder API.

kosyak commented 3 years ago

Oh, got it. Sure, skeletons are not only about images.

moffpage commented 3 years ago

Yes please! SwiftUI has redacted modifier which allows the view to be displayed with grey color like a placeholder. It'd be amazing having a native from-the-box one-liner solution for these types of cases! Before rewriting my app to Jetpack Compose, I used libraries like Facebook Shimmer: https://github.com/facebook/shimmer-android but I noticed that it uses shaders and it's a little GPU-heavy if I'm not mistaken (also I had to create the exact copies of my XML layout), so then I replaced it with Skelly: https://github.com/int02h/skelly, but it was still cumbersome, I don't think it needs to be that hard... Thanks for your contribution Chris!) P.S. out of my curiosity I've searched for ready-made solutions that work with Jetpack Compose (cause the two I've mentioned - don't) - and I've found this library: https://github.com/kazemihabib/compose-shimmer and I know that you gogglers are great and are trying to make it real: https://gist.github.com/lelandrichardson/35b2743e1acd5d672f963f92aca57d4a so I just wanted to give more inspiration since I wanna push Jetpack Compose so much, I'm sick of writing legacy-style Android Applications, it's a pain.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Kernald commented 3 years ago

This is still relevant.