compose-samples icon indicating copy to clipboard operation
compose-samples copied to clipboard

Adding shared elements to Jetsnack 🎉

Open riggaroo opened this issue 10 months ago • 1 comments

Adding shared elements between Home feed and SnackDetail.

Introduced SnackSharedElementKey to create a unique key for the shared element to match.

Using Modifier.sharedBounds() on the Card container, and Modifier.sharedElement() on the Image.

Using Modifier.sharedBounds() with Modifier.animateEnterExit() on Text.

The above modifiers require being in an AnimatedVisibilityScope and SharedTransitionScope, in order to use the correct scope at the correct point, we save the scopes in a CompositionLocal and retrieve it when required.

https://github.com/android/compose-samples/assets/9973046/2d0cf1d9-4ef2-4051-a2e9-b3255d45ac78

riggaroo avatar Apr 04 '24 14:04 riggaroo

Will values be added to the 'element' tab later, or is it normal for it to be empty. In my opinion, it would be convenient for debugging to display the values applied to parameters other than the key in sharedContentState.

스크린샷 2024-05-21 오후 5 34 40

yongsuk44 avatar May 21 '24 08:05 yongsuk44