Animated LazyColumn/LazyRow
POC of how you can animate LazyColumn/LazyRow insertions/deletions/moving
Note, this is not production ready or a library, but just a POC on a potential workaround until official support for LazyColumn
animations is available, follow issue tracker: https://issuetracker.google.com/issues/150812265
(EDIT: The above issue tracker has been updated and there's an experimental modifier for item animations now!)
DEMO:
Android.Emulator.-.Pixel_5_API_31_5554.2021-10-02.16-48-38.mp4
Android.Emulator.-.Pixel_5_API_31_5554.2021-10-02.20-09-33.mp4
Example usage:
data class MainItem(
val id: String,
val text: String
)
val items = List(10) { MainItem(UUID.randomUUID().toString(), UUID.randomUUID().toString()) }
val state = rememberLazyListState()
AnimatedLazyColumn(
state = state,
items = items.map {
AnimatedLazyListItem(key = it.id, value = it.text) {
TextItem(viewModel, it)
}
}
)
AnimatedLazyRow(
state = state,
items = items.map {
AnimatedLazyListItem(key = it.id, value = it.text) {
TextItem(viewModel, it)
}
}
)