I have a list with 10 items one of them have this elements "rankingCurrentPlace"
, "rankingPastPlace"
and "isUser:true"
.
What i need to do its an animation on the lazycolumn if the api esponse is like this
"isUser:true"
, "rankingPastPlace:3"
, "rankingCurrentPlace:7"
i need to show an animation in the list where the row starts in the third place and descend to the seventh place
is there a way to do this?
this is what I actually have
LazyColumn(
contentPadding = PaddingValues(horizontal = 10.dp, vertical = 0.dp),
) {
items(
items = leaderboard,
key = { leaderBoard ->
leaderBoard.rankingPlace
}
) { leaderBoard ->
RowComposable( modifier = Modifier
.fillMaxWidth(),
topicsItem = leaderBoard,)
}
This answer works except when swapping first item with any item even with basic swap function without animation. I think it would be better to ask a new question about why swapping first item doesn't work or if it is bug. Other than that works as expected. If you need to move to items that are not in screen you can
lazyListState.layoutInfo.visibleItemsInfo
and compare with initial item and scroll to it before animation1.Have a SnapshotStateList of data to trigger recomposition when we swap 2 items
2.Function to swap items
3.Function to swap items one by one. There is a bug with swapping first item. Even if it's with function above when swapping first item other one moves up without showing animation via
Modififer.animateItemPlacement()
.4.List with items that have
Modifier.animateItemPlacement()
Demo
Edit: Animating with Animatable
Another method for animating is using
Animatable
with Integer vector.And can be used as
on button click, i'm getting values from TextField fo i convert from String
Result