https://kotlinlang.org logo
#kmdc
Title
# kmdc
r

rocketraman

03/23/2023, 8:28 PM
@Big Chungus I'm trying to use a
MDCDialog
in an MVI application. I have a view model which has an
open
state for the dialog. The dialog may be: a) closed by some button press by the user, in which case the dialog is closed when it sees the
open
state of the VM change to false, or b) closed on scrim or escape, in which case I need to send an event to the VM (using the
onClosed
hook seems appropriate) The problem I have is when the dialog is closed via (a), my view model receives two inputs: the button press and the event from the
onClosed
hook, which causes issues. Is there a way to trigger a callback only for the scrim/escape case?
b

Big Chungus

03/23/2023, 8:40 PM
Dunno, but I don't think so. Have you checked mdc docs for mdc-dialog yet?
r

rocketraman

03/23/2023, 8:42 PM
Yeah,
closing
and
closed
are documented as "Indicates when the dialog begins/finishes its closing animation." I'm checking the
action
value received in the event right now, they don't document what that is.
b

Big Chungus

03/23/2023, 8:43 PM
r

rocketraman

03/23/2023, 8:45 PM
Ah, so the string just gets set to something else so I can distinguish it. Got it!
b

Big Chungus

03/23/2023, 8:45 PM
Let me know if you manage to get it working
r

rocketraman

03/23/2023, 8:48 PM
Yep, it works. I don't even need to use
scrimClickAction
and
escapeKeyAction
because the close event action is
undefined
(null in Kotlin) if I close the popup through state, and `scrimClickAction`/`escapeKeyAction` (which defaults to
close
) if done via the scrim/esc.
b

Big Chungus

03/23/2023, 8:48 PM
I'd be curious to check out the website you're building once you have something to show
(assuming it's oss ofc)
r

rocketraman

03/23/2023, 8:51 PM
Not oss, but the site is already live: https://sell.diyoffer.com/. You have to login to see most of it -- feel free to create an account on the test site: https://test.diyoffer.com/home.
b

Big Chungus

03/23/2023, 8:51 PM
Thanks
Did you theme it with css variables or scss mixins?
Looks neat, btw!
r

rocketraman

03/23/2023, 8:55 PM
A small amount of scss but mostly css variables
Looks neat, btw!
Thanks!
7 Views