Hi! Im using `AnimatedVisibility` and notice some ...
# compose
t
Hi! Im using
AnimatedVisibility
and notice some weird behavior for
expandVertically
and
shrinkVertically
Is this expected?
Copy code
@ExperimentalAnimationApi
@Composable
fun AddressItem() {
    var selected by remember {
        mutableStateOf(false)
    }
    val radioThickness by animateDpAsState(targetValue = if (selected) 4.dp else 1.dp)
    val borderColor by animateColorAsState(targetValue = if (selected) ActionOrange else Color.White)
    Column(
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Box(
            modifier = Modifier
                .fillMaxWidth()
                .height(IntrinsicSize.Max)
                .shadow(8.dp, Rounded8dpShape)
                .background(Color.White)
                .border(width = 1.dp, borderColor, Rounded8dpShape)
                .clickable { selected = !selected }
        ) {
            Column {
                AnimatedVisibility(
                    visible = selected,
                    enter = expandVertically(expandFrom = <http://Alignment.Top|Alignment.Top>, animationSpec = tween(100)),
                    exit = shrinkVertically(shrinkTowards = <http://Alignment.Top|Alignment.Top>, animationSpec = tween(100))
                ) {
                    Box(
                        modifier = Modifier
                            .background(
                                brush = Brush.horizontalGradient(
                                    listOf(
                                        Color(0xffEE5C1D),
                                        Color(0xffFF9060)
                                    )
                                ),
                                RoundedCornerShape(topStart = 8.dp, bottomEnd = 8.dp)
                            )
                    ) {
                        Text(
                            text = "DEFAULT ADDRESS",
                            style = GolfTecFont.Roboto10W400,
                            color = Color.White,
                            modifier = Modifier.padding(horizontal = 12.dp, vertical = 2.dp)
                        )
                    }
                }
                Box(modifier = Modifier.height(200.dp).fillMaxWidth()) {
                    Text(text = "TEST", Modifier.align(Alignment.Center))
                }
            }
        }
    }
}
d
There's an issue on using
IntrinsicSize.Max
with `AnimatedVisibility`: https://issuetracker.google.com/193173055
👍 1
t
Thank you!