Merge pull request #1568 from qyo123oyq/fix/bookshelf-manual-sort
fix(bookshelf): improve manual sort drag visual feedback and selection handling
This commit is contained in:
@@ -85,6 +85,7 @@ import androidx.compose.runtime.setValue
|
|||||||
import androidx.compose.runtime.snapshotFlow
|
import androidx.compose.runtime.snapshotFlow
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.platform.ClipEntry
|
import androidx.compose.ui.platform.ClipEntry
|
||||||
@@ -1355,28 +1356,32 @@ fun BookshelfPage(
|
|||||||
state = reorderableState,
|
state = reorderableState,
|
||||||
key = bookUi.book.bookUrl,
|
key = bookUi.book.bookUrl,
|
||||||
enabled = canReorderBooks
|
enabled = canReorderBooks
|
||||||
) {
|
) { isDragging ->
|
||||||
BookItem(
|
BookItem(
|
||||||
bookUi = bookUi,
|
bookUi = bookUi,
|
||||||
modifier = Modifier.then(
|
modifier = Modifier
|
||||||
if (canReorderBooks) {
|
.then(
|
||||||
Modifier.longPressDraggableHandle(
|
if (canReorderBooks) {
|
||||||
onDragStarted = {
|
Modifier.longPressDraggableHandle(
|
||||||
onDragStarted(displayBooks)
|
onDragStarted = {
|
||||||
hapticFeedback.performHapticFeedback(
|
onDragStarted(displayBooks)
|
||||||
HapticFeedbackType.GestureThresholdActivate
|
hapticFeedback.performHapticFeedback(
|
||||||
)
|
HapticFeedbackType.GestureThresholdActivate
|
||||||
},
|
)
|
||||||
onDragStopped = {
|
},
|
||||||
hapticFeedback.performHapticFeedback(
|
onDragStopped = {
|
||||||
HapticFeedbackType.GestureEnd
|
hapticFeedback.performHapticFeedback(
|
||||||
)
|
HapticFeedbackType.GestureEnd
|
||||||
}
|
)
|
||||||
)
|
}
|
||||||
} else {
|
)
|
||||||
Modifier
|
} else {
|
||||||
}
|
Modifier
|
||||||
),
|
}
|
||||||
|
)
|
||||||
|
.graphicsLayer {
|
||||||
|
alpha = if (isDragging) 0.5f else 1f
|
||||||
|
},
|
||||||
layoutMode = bookshelfLayoutMode,
|
layoutMode = bookshelfLayoutMode,
|
||||||
isSelected = isSelected,
|
isSelected = isSelected,
|
||||||
gridStyle = bookItemGridStyle,
|
gridStyle = bookItemGridStyle,
|
||||||
|
|||||||
Reference in New Issue
Block a user