Jetpack compose Preview not showing in one of the components of the Google Rally Sample app

Viewed 615

I am trying to preview the RallyAlertDialog composable which is one of the components used in the Rally Sample from Google. The code I want to preview is the following:

@Composable
fun RallyAlertDialog(
    onDismiss: () -> Unit,
    bodyText: String,
    buttonText: String
) {
    RallyDialogThemeOverlay {
        AlertDialog(
            onDismissRequest = onDismiss,
            text = { Text(bodyText) },
            buttons = {
                Column {
                    Divider(
                        Modifier.padding(horizontal = 12.dp),
                        color = MaterialTheme.colors.onSurface.copy(alpha = 0.2f)
                    )
                    TextButton(
                        onClick = onDismiss,
                        shape = RectangleShape,
                        contentPadding = PaddingValues(16.dp),
                        modifier = Modifier.fillMaxWidth()
                    ) {
                        Text(buttonText)
                    }
                }
            }
        )
    }
}

The composable RallyDialogThemeOverlay(content: @Composable () -> Unit) is defined in another kotlin file, RallyTheme.kt, and is a custom MaterialTheme.

The code I am using for the @Preview is the following:

@Preview(showBackground = true)
@Composable
fun PreviewRallyAlertDialog() {
    val alertMessage = "Heads up, you've used up 90% of your Shopping budget for this month."
    val buttonText = "Dismiss".uppercase(Locale.getDefault())
    RallyAlertDialog(
        onDismiss = { /*TODO*/ },
        bodyText = alertMessage,
        buttonText = buttonText
    )
}

Since I can not preview and there is no error, what am I doing wrong?

Thanks

1 Answers
Related