Skip to content
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

Open
wants to merge 45 commits into
base: main
Choose a base branch
from

Conversation

riggaroo
Copy link
Collaborator

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.

arriolac and others added 30 commits January 24, 2024 11:55
* 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]>
* 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]>
Update Compose BOM to 2024.04.00

Co-authored-by: MagicalMeghan <[email protected]>
* 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]>
* add shared element snippets

* Apply Spotless

* Split snippets into different files.

* Apply Spotless

---------

Co-authored-by: riggaroo <[email protected]>
riggaroo and others added 14 commits May 1, 2024 11:13
* 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]>
Copy link

snippet-bot bot commented May 20, 2024

Here is the summary of changes.

You are about to add 1 region tag.

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:

  • Refresh this comment

try {
progress.collect { backEvent ->
// code for progress
seekableTransitionState.seekTo(backEvent.progress, targetState = Screen.Home)

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.

Base automatically changed from feature/animated-visibility-shared-elements to latest May 24, 2024 12:19
Base automatically changed from latest to main September 6, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants