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
suspend fun SnackbarManager.reportingChannelUpdateFailure(retry: () -> Unit, write: suspend () -> Unit)

Runs a channel write and, when it fails, tells the user with a snackbar whose Retry action calls retry. The failure is rethrown afterwards so the caller's safeLaunch still logs it.

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)