Anthony Martin

    Anthony Martin

    11 months ago
    Does
    AlertDialog
    work with Compose
    Preview
    ? I can't get it to work as it's saying "The graphics preview in the layout editor may not be accurate - The preview does not support multiple windows." Just trying to gain an understanding on what's doing wrong. Code:
    @Preview
    @Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
    @Composable
    private fun SimpleComposeUIPreview() {
        AppTheme {
            DialogUI(
                message = "This is an example dialog message...",
                onPopBackStack = {}
            )
        }
    }
    @Composable
    private fun DialogUI(
        title: String = stringResource(R.string.title),
        message: String,
        positiveBtn: String = stringResource(R.string.pos),
        onPopBackStack: () -> Unit
    ) {
        AlertDialog(
            onDismissRequest = onPopBackStack,
            title = {
                Text(text = title)
            },
            text = {
                Text(text = message)
            },
            confirmButton = {
                TextButton(
                    onClick = onPopBackStack,
                ) {
                    Text(positiveBtn)
                }
            },
        )
    }
    Using version 1.1.0-alpha04 for Compose
    Albert Chang

    Albert Chang

    11 months ago
    Anthony Martin

    Anthony Martin

    11 months ago
    Thanks Albert