Shared element experiment [DO NOT MERGE] #310
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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