Issue
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
Solution
Preview of dialogs is not supported now. See https://issuetracker.google.com/issues/186502047.
Update: Supported since Android Studio Chipmunk Canary 5.
Answered By - H.D.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.