Dave Scheck
12/09/2022, 3:39 PMdata class ScreenState(val intValue: Int = 0, val boolValue: Boolean = false)@Composable
fun TestScreen() {
    // Screen state managed by the composable
    val screenState = remember { mutableStateOf(ScreenState()) }
    /**
    Update the integer value of the state once per second
    Note that the boolean value is never changed and is always false
     **/
    LaunchedEffect(key1 = null) {
        while (true) {
            delay(1000)
            screenState.value = screenState.value.copy(
                intValue = screenState.value.intValue + 1,
            )
        }
    }
    Box(
        modifier = Modifier
            .fillMaxSize()
            .background(Color(0xFF272727)),
        contentAlignment = Alignment.Center
    ) {
        // Simple composable that takes the state object as an input
        ContainerBox(screenState.value)
    }
}@Composable
fun ContainerBox(value: ScreenState) {
    Column(
        modifier = Modifier
            .width(300.dp)
            .height(300.dp)
            .border(
                border = BorderStroke(1.dp, Color(0xFF23C42A)),
                shape = RoundedCornerShape(10.dp)
            )
            .clip(RoundedCornerShape(10.dp))
            .background(Color(0xFF75757A)),
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Center
    ) {
        if (value.boolValue) {
            Text("Dynamic Text ${value.intValue}")
        } else {
            Text("Static Text")
        }
    }
}Pablichjenkov
12/09/2022, 9:54 PMContainerBox(value: ScreenState)Dave Scheck
12/09/2022, 9:56 PMPablichjenkov
12/09/2022, 9:57 PMPablichjenkov
12/09/2022, 9:59 PMZach Klippenstein (he/him) [MOD]
12/11/2022, 1:11 AMDave Scheck
12/12/2022, 4:35 PM