Queue row gestures: album art as grab surface + swipe-to-remove #118
@@ -234,23 +234,7 @@ private fun QueueRow(
|
|||||||
.graphicsLayer { translationY = dragOffsetY }
|
.graphicsLayer { translationY = dragOffsetY }
|
||||||
.background(highlight)
|
.background(highlight)
|
||||||
.clickable(onClick = onClick)
|
.clickable(onClick = onClick)
|
||||||
// Replaces the capability the grip icon carried. Its
|
.queueReorderActions(index = index, queueSize = queueSize, onMove = onMove)
|
||||||
// contentDescription ("Reorder track") was the ONLY thing telling a
|
|
||||||
// screen reader this list could be reordered, and a long-press drag
|
|
||||||
// is not operable with TalkBack at all. These custom actions are the
|
|
||||||
// Android counterpart to the web row's ArrowUp/ArrowDown keys —
|
|
||||||
// without them, dropping the grip would have quietly removed
|
|
||||||
// reordering for anyone not using touch.
|
|
||||||
.semantics {
|
|
||||||
customActions = listOf(
|
|
||||||
CustomAccessibilityAction("Move up") {
|
|
||||||
if (index > 0) { onMove(index, index - 1); true } else false
|
|
||||||
},
|
|
||||||
CustomAccessibilityAction("Move down") {
|
|
||||||
if (index < queueSize - 1) { onMove(index, index + 1); true } else false
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
@@ -290,6 +274,31 @@ private fun QueueRow(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Screen-reader reordering for a queue row.
|
||||||
|
*
|
||||||
|
* Replaces the capability the grip icon carried: its contentDescription
|
||||||
|
* ("Reorder track") was the ONLY thing telling a screen reader this list could
|
||||||
|
* be reordered, and a long-press drag is not operable with TalkBack at all.
|
||||||
|
* These are the Android counterpart to the web row's ArrowUp/ArrowDown keys —
|
||||||
|
* without them, dropping the grip would have quietly removed reordering for
|
||||||
|
* anyone not using touch.
|
||||||
|
*/
|
||||||
|
private fun Modifier.queueReorderActions(
|
||||||
|
index: Int,
|
||||||
|
queueSize: Int,
|
||||||
|
onMove: (Int, Int) -> Unit,
|
||||||
|
): Modifier = semantics {
|
||||||
|
customActions = listOf(
|
||||||
|
CustomAccessibilityAction("Move up") {
|
||||||
|
if (index > 0) { onMove(index, index - 1); true } else false
|
||||||
|
},
|
||||||
|
CustomAccessibilityAction("Move down") {
|
||||||
|
if (index < queueSize - 1) { onMove(index, index + 1); true } else false
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reorder-drag behaviour for a queue row, applied to whatever element is the
|
* Reorder-drag behaviour for a queue row, applied to whatever element is the
|
||||||
* grab surface — the album art, since #2395 removed the grip icon.
|
* grab surface — the album art, since #2395 removed the grip icon.
|
||||||
|
|||||||
Reference in New Issue
Block a user