# RemoteAllStatesLayout

> Displays the child layout matching [currentState] across all entries of [T].

## API Reference

### RemoteAllStatesLayout

> Source set: JvmAndAndroid

```kotlin
@Composable
public fun <T : Enum<T>> RemoteAllStatesLayout(
    currentState: RemoteEnum<T>,
    modifier: RemoteModifier = RemoteModifier,
    content: @RemoteComposable @Composable (T) -> Unit,
)
```

Displays the child layout matching `currentState` across all entries of `T`.

Interactive example cycling through enum states:

Reducing a larger enum domain to fewer UI states:

#### Parameters

| | |
| --- | --- |
| currentState | `RemoteEnum` selecting the active child layout |
| modifier | [RemoteModifier](https://composables.com/jetpack-compose/androidx.compose.remote/remote-creation-compose/interfaces/RemoteModifier/api.md) applied to this layout |
| content | composable invoked once per entry of `T` to build each state's layout |

### RemoteAllStatesLayout

> Source set: JvmAndAndroid

```kotlin
@Composable
public fun RemoteAllStatesLayout(
    currentState: RemoteBoolean,
    modifier: RemoteModifier = RemoteModifier,
    content: @RemoteComposable @Composable (Boolean) -> Unit,
)
```

Displays the child layout matching `currentState` for both boolean states.

Interactive example toggling between boolean states:

#### Parameters

| | |
| --- | --- |
| currentState | `RemoteBoolean` selecting the active child layout |
| modifier | [RemoteModifier](https://composables.com/jetpack-compose/androidx.compose.remote/remote-creation-compose/interfaces/RemoteModifier/api.md) applied to this layout |
| content | composable invoked once for `false` and once for `true` |

### RemoteAllStatesLayout

> Source set: JvmAndAndroid

```kotlin
@Composable
public fun RemoteAllStatesLayout(
    currentState: RemoteInt,
    @IntRange(from = 1) stateCount: Int,
    modifier: RemoteModifier = RemoteModifier,
    content: @RemoteComposable @Composable (Int) -> Unit,
)
```

Displays the child layout matching `currentState` across states `0` through `stateCount - 1`.

Interactive example cycling through integer states:

#### Parameters

| | |
| --- | --- |
| currentState | `RemoteInt` selecting the active child layout by zero-based index (falls back to index `0` if out of range at runtime) |
| stateCount | number of integer states (`0` through `stateCount - 1`), must be positive |
| modifier | [RemoteModifier](https://composables.com/jetpack-compose/androidx.compose.remote/remote-creation-compose/interfaces/RemoteModifier/api.md) applied to this layout |
| content | composable invoked once per index in `0 until stateCount` to build each state's layout |

## Code Examples

### RemoteAllStatesLayoutEnumSample

```kotlin
@Sampled
@Preview
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteAllStatesLayoutEnumSample() {
    val state = remember { MutableRemoteEnum(SampleState.Loading) }
    RemoteAllStatesLayout(currentState = state) { screen ->
        when (screen) {
            SampleState.Loading ->
                RemoteText(
                    "Loading... (tap for Success)".rs,
                    color = Color.Gray.rc,
                    modifier =
                        RemoteModifier.clickable(
                                valueChangeAction(state, RemoteEnum(SampleState.Success))
                            )
                            .padding(8.rdp),
                )
            SampleState.Success ->
                RemoteText(
                    "Success! (tap for Error)".rs,
                    color = Color.Green.rc,
                    modifier =
                        RemoteModifier.clickable(
                                valueChangeAction(state, RemoteEnum(SampleState.Error))
                            )
                            .padding(8.rdp),
                )
            SampleState.Error ->
                RemoteText(
                    "Error occurred (tap to retry)".rs,
                    color = Color.Red.rc,
                    modifier =
                        RemoteModifier.clickable(
                                valueChangeAction(state, RemoteEnum(SampleState.Loading))
                            )
                            .padding(8.rdp),
                )
        }
    }
}

enum class DownloadStatus {
    Queued,
    Connecting,
    Downloading,
    Verifying,
    Completed,
    FailedNetwork,
    FailedDisk,
    Cancelled,
}
```
