SnackbarManager

A global manager for displaying snackbars across the application. This allows ViewModels to trigger transient feedback messages without direct dependencies on UI components or SnackbarHostState.

Events are buffered in a Channel and consumed exactly once by the host composable via MeshtasticSnackbarHost.

showSnackbar here only buffers and returns. It is the host that waits: MeshtasticSnackbarHost consumes events from a single collect, and its SnackbarHostState.showSnackbar call suspends for as long as that snackbar is on screen — so an SnackbarDuration.Indefinite event with no dismiss affordance stalls the collector and leaves every later snackbar queued behind it. Action snackbars therefore default to SnackbarDuration.Long, not indefinite.

See also

for the modal dialog equivalent.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
data class SnackbarEvent(val message: String, val actionLabel: String? = null, val withDismissAction: Boolean = false, val duration: SnackbarDuration = SnackbarDuration.Short, val onAction: () -> Unit? = null)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open fun showSnackbar(message: String, actionLabel: String? = null, withDismissAction: Boolean = false, duration: SnackbarDuration = if (actionLabel != null) SnackbarDuration.Long else SnackbarDuration.Short, onAction: () -> Unit? = null)