Tuba Kesten
12/02/2021, 6:40 PManimateColorAsState ; however, this causes to take action while tween animation is running. Is there any way to understand when the exit animation completed?Tuba Kesten
12/02/2021, 6:40 PMLazyColumn {
itemsIndexed(questionsData.questions) { index, item ->
if (index == 0)
Spacer(
modifier = Modifier
.height(56.dp)
.fillMaxWidth()
)
androidx.compose.animation.AnimatedVisibility(
visible = item.selectedAnswer.isNullOrEmpty(),
enter = expandHorizontally(),
exit = shrinkHorizontally(
animationSpec = tween(
durationMillis = 500,
)
)
) {
val color: Color by animateColorAsState(
if (item.selectedAnswer.isNullOrEmpty()) placeHolderColor else secondaryColor,
finishedListener = {
if (progress == 1f) {
backAction()
}
}
)
QuestionTitleView(
item.question,
onQuestionAnswerAction = {
onQuestionAnswerAction(item)
},
backgroundColor = color
)
}
}
}Colton Idle
12/02/2021, 10:18 PMDoris Liu
12/03/2021, 2:23 AMAnimatedVisibility consider using the AnimatedVisibility API that accepts a MutableTransitionState, you can then check its currentState against targetState for when the animation has finished.
Note that once the animation has finished exiting, the content block of the AnimatedVisibility will be skipped altogether. In other words, you won't be able to trigger animations in the child of AnimatedVisibility once it finishes exiting