Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 1.25 KB

README.md

File metadata and controls

40 lines (30 loc) · 1.25 KB

LazyColumnItemDiffAnimations

An experimental method for providing item diff animations in a LazyColumn. Note that this only handles additions and removals, not moves.

ezgif-4-c97be879c5b6

inline fun <T> LazyListScope.animatedItemsIndexed(
    state: List<AnimatedItem<T>>,
    enterTransition: EnterTransition = expandVertically(),
    exitTransition: ExitTransition = shrinkVertically(),
    noinline key: ((item: T) -> Any)? = null,
    crossinline itemContent: @Composable LazyItemScope.(index: Int, item: T) -> Unit
)

The state parameter should be obtained through the use of the updateAnimatedItemsState method:

fun <T> updateAnimatedItemsState(
    newList: List<T>
): State<List<AnimatedItem<T>>> 

Implementation is found here.

Example usage:

val animationState by updateAnimatedItemsState(list)
LazyColumn(Modifier.fillMaxSize()) {
    animatedItemsIndexed(animationState, key = { it }) { _, item ->
        // item content
        // ...
    }
}

This repo also provides an example activity.