AnimatedVisibility.kt

Home   »   AnimatedVisibility.kt

    @ExperimentalAnimationApi
    @Composable
    private fun DefaultAnimatedVisibilityExample(modifier: Modifier = Modifier, ) {
        Column(modifier = modifier) {
            val visible = remember { mutableStateOf(true) }
            AnimatedVisibility(visible = visible.value) {
                Box(modifier = Modifier.background(color = Color.Gray).fillMaxWidth()) {
                    Text(
                        text = "default animated visibility",
                        fontSize = 14.sp,
                        style = TextStyle(color = Color.White),
                        modifier = Modifier.padding(10.dp)
                    )
                }
            }

            Button(
                modifier = Modifier.padding(top = 10.dp),
                onClick = { visible.value = visible.value.not() },
                content = { Text(text = if (visible.value) getString(R.string.text_hide) else getString(R.string.text_show)) }
            )
        }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *