Alexandru Hadăr
02/06/2023, 6:03 PMstrings and I’m using Crossfade to animate between them (I’m showing 1 string at a time), like this:
var index by remember { mutableStateOf(0) }
Crossfade(targetState = index) {
Text(strings[it])
}
Is there something that takes index from 0 to strings.size incrementally each second?
What I’m doing so far is
LaunchedEffect(news) {
while (isActive) {
delay(1_000)
index += 1
index %= news.size
}
}
However, I’m not sure if this is the right approach. Is there something like animateFloatAsState for int, for what I need?Stylianos Gakis
02/06/2023, 7:47 PMproduceState instead. You are in a suspending context there so you can do while (isActive) and in there delay and increment the value returning it to 0 when you reach the text's size.