ursus
08/29/2023, 2:51 PM@Composable
and the null the state to have it closed?
sealed class FooScreenDialog {
object class Whatever() : FooScreenDialog
data class ConfirmSomething(val someId: Id) : FooScreenDialog
}
class ViewModel {
private val _showDialog = MutableStateFlow<FooScreenDialog?>(null)
val showDialog: Flow<FooScreenDialog?> get() = _showDialog
fun foo() {
_showDialog.value = FooScreenDialog.Whatever
}
fun closeDialog() {
_showDialog.value = null
}
}
@Composable fun Screen(...) {
when showDialog {
is Whatever -> AlertDialog(...)
is ConfirmSomething -> AlertDialog(...)
}
}