Thread
#compose
    t

    Tin Tran

    1 year ago
    Hi! Im using
    AnimatedVisibility
    and notice some weird behavior for
    expandVertically
    and
    shrinkVertically
    Is this expected?
    @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))
                    }
                }
            }
        }
    }
    Doris Liu

    Doris Liu

    1 year ago
    There's an issue on using
    IntrinsicSize.Max
    with AnimatedVisibility: https://issuetracker.google.com/193173055
    t

    Tin Tran

    1 year ago
    Thank you!