ScaffoldSnackbars
The snackbars of the Toolkit scaffold around a screen: a page's frame or the shell's tabs. The scaffold draws them above its bottom bar, its floating action buttons and the system bars; the screen only says what to show.
val snackbars = rememberScaffoldSnackbars()
Button(onClick = {
snackbars.post(
message = context.getString(R.string.deleted),
actionLabel = context.getString(R.string.undo),
onAction = { viewModel.onEvent(Event.Undo) },
)
})Content copied to clipboard
A new snackbar replaces the one showing. Each can take the ToolkitSnackbarStyle.Normal or ToolkitSnackbarStyle.Error look, an icon, colours of its own, or be drawn entirely by the screen through content.
Functions
Link copied to clipboard
fun post(message: String, style: ToolkitSnackbarStyle = ToolkitSnackbarStyle.Normal, actionLabel: String? = null, withDismissAction: Boolean = true, duration: SnackbarDuration? = null, icon: ToolkitIcon? = null, colors: ToolkitSnackbarColors? = null, content: @Composable (SnackbarData) -> Unit? = null, onAction: () -> Unit? = null, onDismiss: () -> Unit? = null): Job
Link copied to clipboard
suspend fun show(message: String, style: ToolkitSnackbarStyle = ToolkitSnackbarStyle.Normal, actionLabel: String? = null, withDismissAction: Boolean = true, duration: SnackbarDuration? = null, icon: ToolkitIcon? = null, colors: ToolkitSnackbarColors? = null, content: @Composable (SnackbarData) -> Unit? = null): SnackbarResult
Shows a snackbar and suspends until it leaves, replacing any snackbar showing.