-
Notifications
You must be signed in to change notification settings - Fork 172
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
Add an example of seeking between shared element states manually using SeekableTransitionState #273
base: main
Are you sure you want to change the base?
Conversation
* Add ripple snippets. * Add new ripple APIs. * Add snippets for interactions. * Added more ripple snippets. * Update foundation and material to 1.7.0-alpha01 * Fix snippet tag. * Apply Spotless --------- Co-authored-by: arriolac <[email protected]>
* Adding pip snippets to latest branch * Apply Spotless * Adding pip snippets to latest --------- Co-authored-by: MagicalMeghan <[email protected]>
🤖 Sync main to latest
🤖 Sync main to latest
🤖 Sync main to latest
🤖 Sync main to latest
* Migrate recomposeHighlighter to Modifier.Node * Apply Spotless * Simplify recompose highlighter * Apply Spotless --------- Co-authored-by: Tomáš Mlynarič <[email protected]> Co-authored-by: mlykotom <[email protected]>
* Add snippets for ContextualFlowRow * Apply Spotless * Update flow snippets * Apply Spotless --------- Co-authored-by: riggaroo <[email protected]>
🤖 Sync main to latest
Update Compose BOM to 2024.04.00 Co-authored-by: MagicalMeghan <[email protected]>
🤖 Sync main to latest
* Update libs.versions.toml (#251) * Replace Graphics bitmap snippets with new Graphics Layer snippets. * Replace Graphics bitmap snippets with new Graphics Layer snippets. * Apply Spotless --------- Co-authored-by: Simona <[email protected]> Co-authored-by: riggaroo <[email protected]>
…/android/snippets into riggaroo/shared-element-snippets
* add shared element snippets * Apply Spotless * Split snippets into different files. * Apply Spotless --------- Co-authored-by: riggaroo <[email protected]>
Co-authored-by: Simona <[email protected]>
* add shared element snippets * Apply Spotless * Split snippets into different files. * Apply Spotless * Snippet updates based on peer feedback. * Apply Spotless --------- Co-authored-by: riggaroo <[email protected]>
* Update libs.versions.toml (#251) * Updated ListDetailPaneScaffold use to alpha12 (#255) This eliminates storing state outside and directly uses the navigator as the source of truth. This also gets rid of the Modifier for AnimatedPane as it's no longer a required argument. * Added NavigationSuiteScaffold snippets (#261) * Added NavigationSuiteScaffold snippets * Apply Spotless * 🤖 Update Dependencies (#262) * Added snippets for SupportingPaneScaffold (#260) * Added snippets for SupportingPaneScaffold * Apply Spotless * Update compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/SampleSupportingPaneScaffold.kt * Migrate to material3-adaptive WindowSizeClass method (#264) * Migrate to material3-adaptive WindowSizeClass method * Update comments to be single line * Apply Spotless --------- Co-authored-by: Simona <[email protected]> Co-authored-by: Ian G. Clifton <[email protected]> Co-authored-by: Alex Vanyo <[email protected]> Co-authored-by: compose-devrel-github-bot <[email protected]>
* Update to new beta01 version * Apply Spotless * Update shared element text composable * Apply Spotless --------- Co-authored-by: riggaroo <[email protected]>
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
try { | ||
progress.collect { backEvent -> | ||
// code for progress | ||
seekableTransitionState.seekTo(backEvent.progress, targetState = Screen.Home) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seekTo may be cancelled as expected, if animateTo
or subsequent seekTo
gets called before the current seekTo
finishes. See the mutatorMutex shared between these calls: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Transition.kt;l=507
You may need a try-catch around this seekTo as well to ignore the cancellation from seekTo.
Using
SeekableTransitionState
andrememberUpdatedTransition()
withTransition#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.