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

Eric Martori

03/15/2022, 1:45 PM
Hello everyone! I've been researching about how to change/remove the dimming/scrim in the Dialog composable. I've found some outdated solutions in the chat history and this ticket in the issue tracker: https://issuetracker.google.com/issues/159900354 but I do not know how to proceed with this. Is there a way to do it without re-implementing the whole thing? If re-implementation is needed what exactly needs to be changed? I cannot find in the Dialog Composable code where the dimming effect is being applied.
c

Colton Idle

03/16/2022, 4:14 AM
I feel like if I needed a "dialog" but remove the scrim I think I would just use a Box{ MyContent() if (dialogShowing){ MyDialog } } and call it a day? A dialog uses Window apis and stuff and so I think there's just a bunch of default stuff that just doesn't have any controls AFAIK. So yeah, I'd just try to fake it. Curious if someone else has an actual solution.
e

Eric Martori

03/16/2022, 11:31 AM
that is what I have right now, but this requires a lot of boiler plate to correctly manage the back press behaviour
I need a dialog that prevents the user to exit the dialog without interacting with it. Think of a mandatory update alert for example. And the client is very adamant that the scrim is not there for some of this dialogs
l

lhwdev

03/16/2022, 1:10 PM
I don't know more but you can get
LocalView.current
, get its parent view then cast into DialogWindowProvider. (seeing Dialog source code; but don't know something can happen with it)
e

Eric Martori

03/17/2022, 4:53 PM
@lhwdev This approach worked, it might break in the future but for now it does what I need. Thank you
👍 1