aclassen / ComposeReorderable

Enables reordering by drag and drop in Jetpack Compose (Desktop) LazyList & LazyGrid.
Apache License 2.0
836 stars 89 forks source link

Swipe to Dismiss #224

Closed denisvasyanin closed 1 year ago

denisvasyanin commented 1 year ago

When swipe to dismiss used, and dragging item from top to bottom, draggable item is going under the lower item, dragging upwards is ok

Am I doing somethiing wrong?

        LazyColumn(
            state = state.listState,
            modifier = Modifier
                .fillMaxHeight()
                .background(Red50)
                .then(Modifier.reorderable(state)),
            contentPadding = PaddingValues(5.dp),
            verticalArrangement = Arrangement.spacedBy(5.dp),
        ) {

            items(exercisePlans, { it }) { item ->

                val dismissState = rememberDismissState()

                if (dismissState.isDismissed(DismissDirection.EndToStart)) {
                    //notesList.remove(item)
                }

                SwipeToDismiss(
                    state = dismissState,
                    modifier = Modifier
                        .padding(vertical = 1.dp),
                    directions = setOf(
                        DismissDirection.EndToStart
                    ),

                    background = {

                    },
                    dismissContent = {
                        ReorderableItem(state, item) { isDragging ->
                            val elevation = animateDpAsState(if (isDragging) 8.dp else 0.dp)
                            Row(
                                modifier = Modifier
                                    .shadow(elevation.value)
                                    .background(
                                        color = Color.White,
                                        shape = RoundedCornerShape(14.dp)
                                    )
                                    .padding(10.dp)
                                    .detectReorderAfterLongPress(state)
                                    .fillMaxWidth(),
                                verticalAlignment = Alignment.CenterVertically
                            ) {
                                Image(
                                    Icons.Default.List,
                                    "",
                                    colorFilter = ColorFilter.tint(color = MaterialTheme.colorScheme.onBackground),
                                    modifier = Modifier
                                        .detectReorder(state)
                                        .padding(start = 10.dp)
                                )
                                Text(
                                    text = item.exerciseUiModel.name,
                                    modifier = Modifier.padding(16.dp)
                                )
                            }

                        }
                    }
                )

            }
        }