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

Lilly

12/10/2021, 1:55 PM
Is it possible to have a screen that is floating over other screens, kinda like a Full Screen Dialog? I'm not looking for a modification of a
Dialog
but something more low level, simply a screen that overlays another screen
m

mattinger

12/10/2021, 2:03 PM
You don’t need a route to have a dialog. You can simply take a normal approach of defining some remembered state:
Copy code
val (showDialog, onShowDialogChanged) = remember { mutableStateOf(false) }
Then just create the dialog:
Copy code
if (showDialog) {
   Dialog(....)
}
and just turn the flag on and off to show it. It can live entirely within your existing route.
l

Lilly

12/10/2021, 3:07 PM
Thanks but I'm not asking for how to create a dialog. I want a screen that overlays like a dialog does but dont want a dialog. I'm looking for a lower level component
a

allan.conda

12/10/2021, 8:52 PM
How about adding a new Window just like how Dialog does it?
👍 1
z

Zach Klippenstein (he/him) [MOD]

12/12/2021, 9:00 PM
There are two ways to do this, depending on what you need: 1. At the root of your composition use a
Box
to overlay your modal content over the other content . 1. Use the
Popup
composable . It uses a different window, like
Dialog
, but without all the styling implications of
Dialog
.
👍 1
Eg the text selection handles use
Popup
. I think
DropdownMenu
does as well.
l

Lilly

12/14/2021, 6:21 PM
@Allan @Zach Klippenstein (he/him) [MOD] Thanks guys. I'm interested in adding a new
Window
so
Dialog
or
Popup
would be suitable...but. I have a problem with the misleading intention (a
Popup
is a
Popup
, not a screen). So if I don't want to go with
Popup
or
Dialog
I would have to compose my own "FullScreen" component by leveraging the underlying
Dialog/Popup
logic (i.e. adding a new Window), right?
z

Zach Klippenstein (he/him) [MOD]

12/15/2021, 7:16 PM
You should be able to make a
Popup
take up the whole screen if you want. If you want to wrap that in your own composable to enforce styling or api requirements, go ahead.
2 Views