fix(player): disable swipe gestures when player controls are shown

This commit is contained in:
2026-06-19 15:47:08 +00:00
parent 31f9fe5d4c
commit 05f58295ad

View File

@@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.input.pointer.pointerInput
@@ -37,6 +38,7 @@ fun PlayerGesturesLayer(
val horizontalThresholdPx = with(density) { HorizontalSeekGestureHelper.START_THRESHOLD.toPx() } val horizontalThresholdPx = with(density) { HorizontalSeekGestureHelper.START_THRESHOLD.toPx() }
val directionThresholdPx = with(density) { 20.dp.toPx() } val directionThresholdPx = with(density) { 20.dp.toPx() }
val dragActive = remember { mutableStateOf(false) } val dragActive = remember { mutableStateOf(false) }
val currentControlsVisible = rememberUpdatedState(controlsVisible)
Box( Box(
modifier = modifier modifier = modifier
@@ -64,6 +66,13 @@ fun PlayerGesturesLayer(
val startX = down.position.x val startX = down.position.x
dragActive.value = false dragActive.value = false
if (currentControlsVisible.value) {
// Swipe gestures are disabled while the controls overlay is visible.
// Tap gestures (single/double tap) are still handled by the
// pointerInput block above.
return@awaitEachGesture
}
var accumulatedDrag = Offset.Zero var accumulatedDrag = Offset.Zero
var dragDirection: DragDirection? = null var dragDirection: DragDirection? = null
var accumulatedHorizontalDrag = 0f var accumulatedHorizontalDrag = 0f
@@ -105,7 +114,6 @@ fun PlayerGesturesLayer(
} }
DragDirection.VERTICAL -> { DragDirection.VERTICAL -> {
change.consume() change.consume()
if (controlsVisible) return@drag
val isLeftSide = startX < size.width / 2 val isLeftSide = startX < size.width / 2
if (isLeftSide) { if (isLeftSide) {
onVerticalDragLeft(delta.y) onVerticalDragLeft(delta.y)