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

Shared element experiment [DO NOT MERGE] #310

Conversation

StylianosGakis
Copy link
Contributor

This is a sample added to support my case for #308
The one thing which I would like this library to do is to expose the already used AnimatedContentScope.
That would then allow callers to use it in their sharedElement modifiers.
The APIs are not there yet for compose multiplatform as I explain further down and in the sample commit, but this library can make this API change to prepare for the future where the APIs are there.

Note that the changes I make in the library itself are not meant to stay as-is. I hacked away a bit by wrapping the existing DSL functions to just wrap the content with an empty AnimatedContent {} block which is probably not what should really be done here to support this change.

For the real impl I support some inspiration can be taken from what the real androidx.navigation library has done here https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavGraphBuilder.kt;l=46-55 by deprecating the old functions and showing only the new ones, while keeping backwards compatibility with the old one.

Note that the sample crashes when going back since
SeekableTransitionState from google's compose
and SeekableTransitionState from jetbrains compose
have a breaking API change between them, making it
impossible to call it at runtime.

This will be fixed as soon as Jetbrains compose
catches up with those breaking changes. This should
not be a concern of this library however in order to
support its users to use the provided
AnimatedContentScope

I attach a video of the sample playing here, again, only going forward due to the aforementioned bug to show what I would like to be possible to be done in the future with PreCompose 😊

precompose_shared_element_github.mp4

Note that the sample crashes when going back since
SeekableTransitionState from google's compose
and SeekableTransitionState from jetbrains compose
have a breaking API change between them, making it
impossible to call it at runtime.

This will be fixed as soon as Jetbrains compose
catches up with those breaking changes. This should
not be a concern of this library however in order to
support its users to use the provided
AnimatedContentScope
@StylianosGakis StylianosGakis changed the title Stylianos: shared element experiment [DO NOT MERGE] Shared element experiment [DO NOT MERGE] Apr 17, 2024
@StylianosGakis
Copy link
Contributor Author

#312 (comment)

Will wait for the CMP release to start bringing in these new APIs and will re-do this sample with those. Until then this can be closed I think.

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.

1 participant