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

mattinger

07/11/2022, 4:36 PM
Does anyone know if there’s a way to intercept the dismiss operation of the scrim was clicked? I don’t want to stop it from dismission, but i do want to log that it occurred. I could use the confirmStateChange as that does get called when the scrim is clicked, and appears to not be called if i programatically close using the .hide() function. But that seems odd to put it in the state.
Copy code
Scrim(
                color = scrimColor,
                onDismiss = {
                    if (sheetState.confirmStateChange(Hidden)) {
                        scope.launch { sheetState.hide() }
                    }
                },
                visible = sheetState.targetValue != Hidden
            )
As a side question, under what other circumstances would confirmStateChange be called? I see a bunch of stuff in the semantics area, but on testing, i don’t see confirmStateChange called if i manually call hide().
t

Tristan Hamilton

08/09/2022, 11:35 AM
I actually left an answer that solves a similar issue to this here: https://stackoverflow.com/a/73208530/5401098 so you could probably just observe
Copy code
LaunchedEffect(sheetState.targetValue)
4 Views