ScreenStates

class ScreenStates(val loading: @Composable (StateSlot) -> Unit = { slot -> LoadingScreen(paddingValues = slot.contentPadding) }, val empty: @Composable (StateSlot, Loadable.Empty) -> Unit = { slot, empty -> NoDataScreen( message = empty.message?.asString(), icon = slot.icon, showRetry = slot.onRetry != null, onRetry = { slot.onRetry?.invoke() }, showAd = slot.showAd, paddingValues = slot.contentPadding, ) }, val failed: @Composable (StateSlot, Loadable.Failed) -> Unit = { slot, failed -> NoDataScreen( message = failed.message.asString(), icon = slot.icon, isError = true, showRetry = slot.onRetry != null, onRetry = { slot.onRetry?.invoke() }, showAd = slot.showAd, paddingValues = slot.contentPadding, ) }, val transition: ContentTransform? = null)(source)

How an app draws loading, empty and failed content, and how one case replaces another. Every ScreenStateHandler and StateContent follows the nearest LocalScreenStates, so an app sets its own once around its content and every screen follows; a single section passes its own onLoading, onEmpty or onError instead.

CompositionLocalProvider(
LocalScreenStates provides ScreenStates(loading = { slot -> AppLoading(slot.contentPadding) }),
) {
ShellHost(graph = graph)
}

The defaults are the Toolkit's: LoadingScreen, and NoDataScreen with the slot's icon, retry and ad, cross-faded on the app's motion scheme.

Constructors

Link copied to clipboard
constructor(loading: @Composable (StateSlot) -> Unit = { slot -> LoadingScreen(paddingValues = slot.contentPadding) }, empty: @Composable (StateSlot, Loadable.Empty) -> Unit = { slot, empty -> NoDataScreen( message = empty.message?.asString(), icon = slot.icon, showRetry = slot.onRetry != null, onRetry = { slot.onRetry?.invoke() }, showAd = slot.showAd, paddingValues = slot.contentPadding, ) }, failed: @Composable (StateSlot, Loadable.Failed) -> Unit = { slot, failed -> NoDataScreen( message = failed.message.asString(), icon = slot.icon, isError = true, showRetry = slot.onRetry != null, onRetry = { slot.onRetry?.invoke() }, showAd = slot.showAd, paddingValues = slot.contentPadding, ) }, transition: ContentTransform? = null)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

How one case replaces another; null cross-fades on MaterialTheme.motionScheme, so it follows the app's motion tempo.