https://kotlinlang.org logo
#compose
Title
# compose
i

iamthevoid

10/27/2020, 7:11 PM
is there native way to calculate and apply diff to lazy column items like DiffUtils for recycler view?
j

jim

10/27/2020, 7:16 PM
Is there a feature of DiffUtils that you feel is missing? As I understand it, DiffUtil is not specific to recycler view and can be used to compare lists, so you can just use it in Compose if you need that functionality.
i

iamthevoid

10/27/2020, 7:34 PM
i just want to imitate recycler view content animated change. You gave me good advice, i'll try use diff utils with compose. But it looks a bit complex, dont't it? I waited than this basic functionality supports by default. Looks strange that it doesn't
May be problem problem is that i very new with compose. If you can give me please an article about lazyColumn and animations. Or advice where to find start point to do this
I saw AnimatedSwipeRefresh https://gist.github.com/bmc08gt/fca95db3bf9fcf255d76f03ec10ea3f9 but in this sample item can stay in list until animation will finished. But i try to make MVI with apply new state when it changes, and here are an another data flow direction
j

jim

10/27/2020, 7:51 PM
But it looks a bit complex, dont't it?
Hey, you're the one who asked for something "like DiffUtils", I was just pointing out that you can use the exact library you requested. But yes, I agree it looks complicated. For most use cases, I imagine a simple enter/exit animation would be sufficient, in which case you would want to take a look at
AnimatedVisibility
which might just do what you want more-or-less out of the box. I'm not sure the extent to which this has been tested with LazyColumn in particular (that widget is still under development), but your feedback would be useful here. Without knowing your background and specific use cases, it's hard to give a better recommendation. But like I mentioned, probably
AnimatedVisibility
will be useful, and failing that, DiffUtil would be the more brute force general purpose solution. If you're reasonably new to Jetpack Compose, there are lots of third party tutorials and blog posts about
Jetpack Compose animations
so a quick Google search might help you learn more about the topic, and I expect that we will publish some more complete animation documentation once we get to Beta or 1.0.