Skip to content

Commit 2f4baba

Browse files
committed
Distinguish between isDraggable and isCaption
1 parent 904645e commit 2f4baba

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenuEditor.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fun LongPressMenuEditor(modifier: Modifier = Modifier) {
204204
} else {
205205
var i = rawItem.index
206206
// make sure it is not possible to move items in between a *Caption and a HeaderBox
207-
if (!items[i].isDraggable) i += 1
207+
if (items[i].isCaption) i += 1
208208
if (i < items.size && items[i] == ItemInList.HeaderBox) i += 1
209209
if (rawItem.index in (prevDragMarkerIndex + 1)..<i) i -= 1
210210
i
@@ -467,18 +467,22 @@ fun autoScrollSpeedFromTouchPos(
467467
)
468468
}
469469

470-
sealed class ItemInList(val isDraggable: Boolean, open val columnSpan: Int? = 1) {
470+
sealed class ItemInList(
471+
val isDraggable: Boolean = false,
472+
val isCaption: Boolean = false,
473+
open val columnSpan: Int? = 1,
474+
) {
471475
// decoration items (i.e. text subheaders)
472-
object EnabledCaption : ItemInList(isDraggable = false, columnSpan = null /* i.e. all line */)
473-
object HiddenCaption : ItemInList(isDraggable = false, columnSpan = null /* i.e. all line */)
476+
object EnabledCaption : ItemInList(isCaption = true, columnSpan = null /* i.e. all line */)
477+
object HiddenCaption : ItemInList(isCaption = true, columnSpan = null /* i.e. all line */)
474478

475479
// actual draggable actions (+ a header)
476480
object HeaderBox : ItemInList(isDraggable = true, columnSpan = 2)
477481
data class Action(val type: LongPressAction.Type) : ItemInList(isDraggable = true)
478482

479483
// markers
480-
object NoneMarker : ItemInList(isDraggable = false)
481-
data class DragMarker(override val columnSpan: Int?) : ItemInList(isDraggable = false)
484+
object NoneMarker : ItemInList()
485+
data class DragMarker(override val columnSpan: Int?) : ItemInList()
482486

483487
fun stableUniqueKey(): Int {
484488
return when (this) {

0 commit comments

Comments
 (0)