What is the idiomatic way to manage multiple dialogs per screen?
is it to have a enum/sealed class and then `when`over it in the
@Composable
and the null the state to have it closed?
Copy code
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(...)
}
}