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

Kevin Aude

02/17/2021, 2:52 PM
Hi all, I'm currently working on a launcher app in Compose. In order to move an app from the app drawer to the home screen I'd need to be able to drag and drop an element from one composable to another one (not sure if the terminology is correct here). Any idea how to do that? I would need the full experience, with a drop shadow and everything and I can't seem to find anything that remotely compares to the system that existed in the traditional view system.
a

Albert Chang

02/17/2021, 3:41 PM
I think the only way is to use an overlay.
k

Kevin Aude

02/18/2021, 7:11 AM
If I understand correctly, you mean having an extra UI layer between my home screen and my app drawer that would mimic the drag and drop behaviour of the traditional view system? I think this is a good idea, although there are several challenges there, like figuring out which cell we are in when the user "drops" the app.
a

Albert Chang

02/18/2021, 8:53 AM
More like a layer at the top. Here's a sample that uses the overlay idea. https://github.com/mxalbert1996/compose-shared-elements
k

Kevin Aude

02/18/2021, 9:32 AM
Thanks a lot! Even though I spent hours researching this, I never came across that sample, I'll have a look.
I had a look and it seems like it could work. I must admit I'm fairly new to the compose world. Do you have any pointers for me? Like, in the sample you sent me which classes/files would be of most interest for me?
a

Albert Chang

02/18/2021, 10:07 AM
As for the overlay itself, there's nothing special. It's just a composable in a
Box
. You might want to see here (and also line 211) for how to get the coordinate of a composable in the root box.
3 Views