What’s the expected visual appearance when multipl...
# compose
m
What’s the expected visual appearance when multiple dialogs are stacked on top of each other? I would expect (for the visible parts of non-top dialogs) to be progressively darker according to how far down the order they are. However, this is not the case. It seems the darkening is only applied on the top-most dialog.
s
To be honest I would simply not expect to ever get a dialog on top of a dialog 😅
☝️ 2
😅 2
☝🏾 2
m
If I didn’t know what I know about the nature & intent of these dialogs, then I’d probably agree with you.
s
I am afraid to ask for more information now
m
Solution is to simply hide non top-level dialogs
Copy code
@Composable
fun DialogStack(
    dialogState: DialogState,
    onDismissRequest: () -> Unit,
    dialog: @Composable (
        state: DialogState,
        onSubDialogState: (DialogState) -> Unit,
        onDismissRequest: () -> Unit,
    ) -> Unit,
) {
    var subDialogState: DialogState? by remember {
        mutableStateOf(null)
    }
    if (subDialogState == null) {
        dialog(dialogState, { subDialogState = it }, onDismissRequest)
    } else {
        DialogStack(
            dialogState = subDialogState!!,
            onDismissRequest = { subDialogState = null },
            dialog = dialog,
        )
    }
}