id like to decouple the dialog from activity. but ...
# compose-android
z
id like to decouple the dialog from activity. but i couldn't think of a way to do it, as when data is updated dialogShow variable is still false. does this mean, unlike with the older system where alert dialogs get stacked on the screen, we need to keep a queue of dialogs?
Copy code
@Composable
fun MainActivityScreen() {
val viewModel: MainActivityViewModel = viewModel()
    var userData by remember { mutableStateOf(viewModel.userLiveData.value ?: UserData.EMPTY) }

    Column(....) {
        Text(...)
        Button(onClick = {
            userData = UserData.getRandomUser()
        }) {
            Text(text = "get new user")
        }
    }
    UserDataDialog(userData)
}


@Composable
fun UserDataDialog(userData: UserData) {
    var dialogShow by remember { mutableStateOf(true) }

    fun onDismiss() {
        dialogShow = false
    }

    if (dialogShow) {
        AlertDialog(...)
    }
}