From 128ced64db11f98d4754cfc5260c5c23eca41c1b Mon Sep 17 00:00:00 2001 From: andrekir Date: Sun, 8 Sep 2024 08:41:41 -0300 Subject: [PATCH] chore(LazyColumnDragAndDropDemo): update to Compose 1.7 APIs --- .../components/LazyColumnDragAndDropDemo.kt | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/ui/components/LazyColumnDragAndDropDemo.kt b/app/src/main/java/com/geeksville/mesh/ui/components/LazyColumnDragAndDropDemo.kt index a2f7d492..64d35cee 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/components/LazyColumnDragAndDropDemo.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/components/LazyColumnDragAndDropDemo.kt @@ -20,10 +20,8 @@ import androidx.compose.animation.core.Animatable import androidx.compose.animation.core.Spring import androidx.compose.animation.core.animateDpAsState import androidx.compose.animation.core.spring -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.gestures.detectDragGesturesAfterLongPress import androidx.compose.foundation.gestures.scrollBy -import androidx.compose.foundation.gestures.stopScroll import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope @@ -192,19 +190,10 @@ internal constructor( draggingItem.index == state.firstVisibleItemIndex || targetItem.index == state.firstVisibleItemIndex ) { -// state.requestScrollToItem( FIXME 1.7.0 method -// state.firstVisibleItemIndex, -// state.firstVisibleItemScrollOffset -// ) - scope.launch { - if (state.isScrollInProgress) { - state.stopScroll() - } - state.scrollToItem( - state.firstVisibleItemIndex, - state.firstVisibleItemScrollOffset - ) - } + state.requestScrollToItem( + state.firstVisibleItemIndex, + state.firstVisibleItemScrollOffset + ) } onMove.invoke(draggingItem.index - headerCount, targetItem.index - headerCount) draggingItemIndex = targetItem.index @@ -248,7 +237,6 @@ fun Modifier.dragContainer( } } -@OptIn(ExperimentalFoundationApi::class) @Composable fun LazyItemScope.DraggableItem( dragDropState: DragDropState, @@ -266,7 +254,7 @@ fun LazyItemScope.DraggableItem( .zIndex(1f) .graphicsLayer { translationY = dragDropState.previousItemOffset.value } } else { - Modifier.animateItemPlacement() + Modifier.animateItem(fadeInSpec = null, fadeOutSpec = null) } Column(modifier = modifier.then(draggingModifier)) { content(dragging) } }