RemoteStateLayoutEnumSample
@Sampled
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteStateLayoutEnumSample() {
val state = rememberMutableRemoteEnum(SampleState.Loading)
RemoteStateLayout(currentState = state) { screen ->
when (screen) {
SampleState.Loading -> RemoteText("Loading...".rs, color = Color.Gray.rc)
SampleState.Success -> RemoteText("Success!".rs, color = Color.Green.rc)
SampleState.Error -> RemoteText("Error occurred".rs, color = Color.Red.rc)
}
}
}
RemoteStateLayoutBooleanSample
@Sampled
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteStateLayoutBooleanSample() {
val state = rememberMutableRemoteBoolean(true)
RemoteStateLayout(currentState = state) { isTrue ->
if (isTrue) {
RemoteText("True State".rs, color = Color.Green.rc)
} else {
RemoteText("False State".rs, color = Color.Red.rc)
}
}
}
RemoteStateLayoutIntSample
@Sampled
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteStateLayoutIntSample() {
val state = rememberMutableRemoteInt(0)
RemoteStateLayout(currentState = state, 0, 1, 2) { index ->
when (index) {
0 -> RemoteText("State 0".rs, color = Color.Red.rc)
1 -> RemoteText("State 1".rs, color = Color.Green.rc)
2 -> RemoteText("State 2".rs, color = Color.Blue.rc)
}
}
}
enum class SampleState {
Loading,
Success,
Error,
}