ScreenStateHandler
Draws state, animating between its cases with the app's ScreenStates.
Every case but Loadable.Ready is drawn by the nearest LocalScreenStates, so a screen passes only what differs: its icon, whether an empty result is worth another try, whether the ad shows. A failure always shows something, with a retry button when onRetry is given and the failure is retryable. The animation runs when the case changes, not when the content inside Loadable.Ready does.
Inside a ScreenHost, the loading content stays until the screen's entrance can begin: a result that arrives while the screen is still sliding in waits there, then the loading content fades as the result's elements enter, so the screen is never blank between the two.
ScreenStateHandler(state = state.config, icon = Icons.Outlined.Settings, onRetry = onRetry) { ready ->
SettingsList(ready.value)
}Use it for one Loadable field of a screen's state; a screen with several draws one each.
Parameters
Padding the loading, empty and failure content keeps, usually the screen's content padding.
What the failure content's retry button does; without it there is none.
Whether the empty content offers onRetry too, for a result that may change, such as a catalog that may have been updated.
The icon of the empty and failure content: any ToolkitIcon, such as a drawable or an animated icon. An overload takes an ImageVector.
Whether the empty and failure content show their native ad.
Replaces the loading content for this section only, such as with a skeleton of its layout.
Replaces the empty content for this section only.
Replaces the failure content for this section only.
Draws the content. It receives the whole Loadable.Ready, so it can mark a refresh or a stale copy.
ScreenStateHandler with an ImageVector icon.