https://kotlinlang.org logo
#compose
Title
# compose
k

Kazemihabib1996

04/30/2020, 12:35 PM
Any chance we could use drawLayout with Dialogs in future? I'm trying to implement Overshoot animation with Dialogs
Copy code
Transition(
            definition = transDef,
            initState = AnimState.StartScale,
            toState = AnimState.EndScale
        ) { state ->
            Box(
                modifier = Modifier.drawLayer(
                    scaleX = state[scale],
                    scaleY = state[scale]
                )
            ) {
                Dialog(onCloseRequest = onDismiss) {
                ...
This doesn't work and I hope this works in future 🙂 And using
Copy code
Dialog(onCloseRequest = onDismiss) {
                    Surface(
                        shape = MaterialTheme.shapes.medium, modifier = Modifier.drawLayer(
                            scaleX = state[scale],
                            scaleY = state[scale]
                        )
                    ) {
                    ...
Just overshoots inside of the dialog not the dialog it self.
I found a kind of solution by wrapping the content inside bigger transparent parent. so it just like the dialog it self scales up and down when animation.
m

Mihai Popa

04/30/2020, 4:06 PM
Could you please file a bug with the code not working?
k

Kazemihabib1996

04/30/2020, 4:12 PM
OK
@Mihai Popa I'm not sure if this can be considered a bug Wrapping a Dialog with Box with drawLayer modifier not works, and the modifier should be added to Dialog content. But it will just scale, rotate and ... the content not dialog itself.
@Mihai Popa Also there is another problem with dialog that I don't know it was on purpose or bug. The source of AlertDialog copies the properties of the MaterialTheme (new added property shapes is forgotten) but Dialog do not do that and uses the default lightTheme. IMHO this should be done inside Dialog instead of AlertDialog
a

Andrey Kulikov

04/30/2020, 7:55 PM
this sounds like a bug, could you please file it?
k

Kazemihabib1996

04/30/2020, 7:58 PM
@Andrey Kulikov of course, you mean both of them?
a

Andrey Kulikov

04/30/2020, 8:03 PM
worth filling both, thought I am not sure we can fix the first one. the second one is a bug for sure
👍 1
k

Kazemihabib1996

04/30/2020, 8:57 PM
Done