I've got a dialog where the user can select something and depending on the choice, the layout will be updated. The problem is that the height of the dialog is never updated to reflect the layout changes.
How to recompose the dialog to make the layout fit in the dialog?
Example:
@Composable
fun AlertDialogTest() {
var showDialog by remember { mutableStateOf(false)}
var showExtra by remember { mutableStateOf(false)}
Button(onClick = { showDialog = true }) {
Text("Open dialog")
}
if (showDialog) {
AlertDialog(
text = {
Column { Button(onClick = {showExtra = true}) {
Text ("Show rest of dialog")
}
if (showExtra) {
Text("More text", style = MaterialTheme.typography.h5)
Text("Even more text", style = MaterialTheme.typography.h5)
}
}
},
confirmButton = { TextButton(onClick = { showDialog = false }) {
Text("Close")
}},
onDismissRequest = {showDialog = false},
)
}
}
And the result: