android / snippets

Main repository for snippets surfaced on developer.android.com.
Apache License 2.0
561 stars 152 forks source link

Add an example of seeking between shared element states manually using SeekableTransitionState #273

Open riggaroo opened 2 months ago

riggaroo commented 2 months ago

Using SeekableTransitionState and rememberUpdatedTransition() with Transition#AnimatedContent, we can control the shared element seeking state,

In this example, a Slider is added to allow for seeking between Home and Details state. The slider also shows progress as the animation happens - so when you click on an item, the progress bar will animate from 0 to 1 - and then back to 0 as it completes the transition.

SeekableTransitionState can be used to build up your own navigation library, or between different states within one Screen of your UI, if you need the ability to seek between states.

snippet-bot[bot] commented 2 months ago

Here is the summary of changes.

You are about to add 1 region tag. - [compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/SharedElementsWithNavigationSnippets.kt:228](https://github.com/android/snippets/blob/e484b058c6ec02e50d41c7aa071da3aeb592b6e8/compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/SharedElementsWithNavigationSnippets.kt#L228), tag `android_compose_shared_element_custom_seeking`

This comment is generated by snippet-bot. If you find problems with this result, please file an issue at: https://github.com/googleapis/repo-automation-bots/issues. To update this comment, add snippet-bot:force-run label or use the checkbox below: