compose-samples
compose-samples copied to clipboard
Adding shared elements to Jetsnack 🎉
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
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.