Chuck Stein
07/26/2022, 7:45 PMLazyList
is still under development, but what's the recommendation for animating insertions/deletions into a regular Column
or Row
?Column
these items live in cannot be a LazyColumn
because much higher up in the compose tree there is already a LazyColumn
container (and a LazyColumn
within another LazyColumn
causes an error).Joseph Hawkes-Cates
07/26/2022, 7:52 PMChuck Stein
07/26/2022, 8:10 PMColumnScope
extension, it doesn't work if my items are coming from the view state, because if an item is removed from the items
list, when I iterate over the list on the next composition, I won't even reach the AnimatedVisibility
that was previously wrapping that item
, because it's no longer in the list I'm iterating over. So the items don't animate even with the following code:
items.forEach { item ->
AnimatedVisibility(visible = item in items) {
MyItemImpl(item)
}
}
Joseph Hawkes-Cates
07/26/2022, 8:12 PMChuck Stein
07/26/2022, 8:14 PMLazyColumn
, which is under development. Is there anything under development to support this for regular Columns
? Or is there an existing recommendation for this use case?Alex Vanyo
07/26/2022, 8:59 PMLazyColumn
that is in AnimatedVisibilityLazyColumnDemo would also apply to a normal Column
. And you’re on the right track, it requires some bookkeeping to keep old items around until their delete animation completes, and using MutableTransitionState
to avoid the “pop in” effect.Chuck Stein
07/26/2022, 9:12 PMMutableStateList
in the view, containing the model objects + their transition state, and updating that animation-specific list in a LaunchedEffect
every time the domain model list changes. But I'm having some issuesAlex Vanyo
07/27/2022, 8:01 PMList<Pair<MyItemModel, MutableTransitionState>>
and then you wouldn’t need to change MyItemModel
at all. There would be a bit of work to create that list, and keep it up to date as the real list updates.Chuck Stein
07/27/2022, 8:17 PM.animate
modifier, similar to how easy it is with SwiftUI and Flutter? I got a working implementation going without changing my models but it still feels very cumbersome to require all this extra boilerplate compared to similar UI frameworks, and I'm sure a built-in compose version could better optimize it (I'm noticing some lag when typing into the TextFields contained within my list items, causing some text input to get lost)dambakk
08/11/2022, 10:03 AMChuck Stein
08/11/2022, 3:37 PManimatableListItems(items, id = { it.id }).forEach { animatableItem ->
AnimatedVisibility(visibleState = animatableItem.transitionState) {
MyListItemComposable(animatableItem.item)
}
}
where items
is your list of domain models representing each list itemdambakk
08/12/2022, 11:24 AMChuck Stein
08/18/2022, 2:09 AM