Tin Tran
07/30/2021, 3:28 PMAnimatedVisibility
and notice some weird behavior for expandVertically
and shrinkVertically
Is this expected?Tin Tran
07/30/2021, 3:29 PM@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
07/30/2021, 6:22 PMIntrinsicSize.Max
with `AnimatedVisibility`: https://issuetracker.google.com/193173055Tin Tran
07/30/2021, 6:52 PM