KPStateComposeLayout

fun KPStateComposeLayout(modifier: Modifier = Modifier, state: State, contentStateLayout: @Composable () -> Unit = {}, warningInfoStateLayout: @Composable (WarningInfoStateLayoutStyle) -> Unit = { warningInfoStateLayoutStyle -> KPWarningInfoStateComposable( warningInfoStateLayoutStyle = warningInfoStateLayoutStyle, ) }, loadingStateLayout: @Composable (message: String) -> Unit = { KPCircularLoadingIndicator() })

A composable function that renders different layouts based on the given State. It supports displaying content, warning/informational states, and loading indicators.

This function acts as a state-based UI manager, delegating the rendering of specific states to the provided composable lambdas.

Parameters

modifier

Modifier to apply to the root container. Default is Modifier.

state

The current State which determines what layout is displayed.

contentStateLayout

A composable lambda for rendering the content state. Default is an empty composable.

warningInfoStateLayout

A composable lambda for rendering a warning or informational state. By default, it uses KPWarningInfoStateComposable.

loadingStateLayout

A composable lambda for rendering a loading state. By default, it displays a circular loading indicator using KPCircularLoadingIndicator.

Supported States

  • ContentWithLoading: Displays content with an optional loading indicator.

  • WarningInfo: Displays a warning or informational layout based on WarningInfoStateLayoutStyle.

  • Loading: Displays a loading indicator with an optional message.

Example Usage

val currentState: State = State.WarningInfo(WarningInfoStateLayoutStyle(/* ... */))
KPStateComposeLayout(
state = currentState,
contentStateLayout = {
Text("This is the content layout")
}
)

See also