I have some issues with the newly added shared tra...
# compose-android
o
I have some issues with the newly added shared transition element.
java.lang.IllegalArgumentException: layouts are not part of the same hierarchy
I have a card with an image and a Dialog with the same image. I want to make a smooth transition between them. Basic structure is:
Copy code
SharedTransitionLayout{
Column{
...
AsyncImage(modifier = Modifier.sharedElementWithCallerManagedVisibility(
    sharedContentState =rememberSharedContentState(key = order.id!!),
    visible = true
))
if (boolean){
Dialog{
AsyncImage(modifier = Modifier.sharedElementWithCallerManagedVisibility(
    sharedContentState =rememberSharedContentState(key = order.id!!),
    visible = true
))
}
}
}
}
I also tried wrapping it inside animatedVisibility instead of if block and still same issue, how do I make it work?
t
For the moment you can't with dialog and m3 modalbottom sheets, so anything in a popup that is a different window.
😦 1
o
So what are my options? Do I use navigation to a different screen or whatever? Or just wait and hope it'll be added?
t
You can emulate a dialog without it being a popup. @Doris Liu said it will be looked into, but it's probably not a trivial change so will probably not be ready for 1.7 final.
o
How can I do that? Do I use some modifier for a z order? How do I go out of composable bounds?
d
For now you'll need to create a full screen layout with a translucent grey scrim to emulate the visual of a dialog. Here's an example from Konstantin, similar to what you are aiming to achieve: https://twitter.com/Snokbert/status/1776919708119203939
👍 1
a
That answers a question I had yet to experiment with, so no shared elements between windows for now?
d
Some investigation has revealed quite a few challenges involved in supporting shared transition between Windows. 🙃 • The biggest challenge is that a new Window brings a new ComposeView. Views don't differentiate between lookahead measure and approach measure, which would prevent us from getting the correct lookahead results for calculating target bounds for shared elements. • Aside from that, Views are also slow to resize, I'm not sure we can achieve a smooth shared element transition into window without a lot of carefully dancing around the performance issues related to remeasuring Views every frame. • Another issue we'd need to solve is how to avoid the new window rendering on top of the shared transition overlay where all the active shared elements are rendered.
355 Views