sen
12/31/2022, 4:54 AMimage▾
DisposableEffect
is invoked within the AnimatedContent, but for whatever reason it seems to be "delayed" by a value. Observing the value (the actual one, not the previous) I saw it cycles between the current and value it just was right before it incremented. IMarcin Wisniowski
01/01/2023, 10:42 AMsen
01/01/2023, 11:20 PMAnimatedContent
?Marcin Wisniowski
01/02/2023, 4:00 PM@Composable
fun AnimatedNumberText(
number: Int,
style: TextStyle,
color: Color,
modifier: Modifier = Modifier
) {
AnimatedContent(
targetState = number,
transitionSpec = {
if (this.targetState > this.initialState) {
slideIntoContainer(AnimatedContentScope.SlideDirection.Down) with
slideOutOfContainer(AnimatedContentScope.SlideDirection.Down)
} else {
slideIntoContainer(AnimatedContentScope.SlideDirection.Up) with
slideOutOfContainer(AnimatedContentScope.SlideDirection.Up)
}
},
modifier = modifier
) {
Text(
text = "$it",
style = style,
color = color
)
}
}