add double tap play/pause gesture

This commit is contained in:
Christian Schabesberger 2024-08-26 12:39:47 +02:00
parent 63334f5893
commit d4d29f4c5c
2 changed files with 36 additions and 2 deletions

View File

@ -63,9 +63,13 @@ fun EmbeddedGestureUI(
Row(modifier = modifier) {
GestureSurface(
modifier = Modifier.weight(1f), onRegularTap = defaultOnRegularTap, onMultiTap = {
modifier = Modifier.weight(1f),
onRegularTap = defaultOnRegularTap,
onMultiTap = {
viewModel.fastSeek(-it)
}, onMultiTapFinished = viewModel::finishFastSeek, onMovement = handleDownwardMovement
},
onMultiTapFinished = viewModel::finishFastSeek,
onMovement = handleDownwardMovement
) {
FadedAnimationForSeekFeedback(
uiState.fastSeekSeconds, backwards = true
@ -79,6 +83,26 @@ fun EmbeddedGestureUI(
}
}
}
GestureSurface(
modifier = Modifier.weight(1f),
onRegularTap = defaultOnRegularTap,
onMultiTap = { count ->
if(count == 1) {
if(uiState.playing) {
viewModel.pause()
viewModel.showUi()
} else {
viewModel.play()
}
}
},
onMultiTapFinished = viewModel::finishFastSeek,
onMovement = handleDownwardMovement
) {
Box(modifier = Modifier.fillMaxSize())
}
GestureSurface(
modifier = Modifier.weight(1f),
onRegularTap = defaultOnRegularTap,

View File

@ -121,6 +121,16 @@ fun FullscreenGestureUI(
if (0 < movement.y) {
viewModel.switchToEmbeddedView()
}
},
onMultiTap = { count ->
if(count == 1) {
if(uiState.playing) {
viewModel.pause()
viewModel.showUi()
} else {
viewModel.play()
}
}
})
GestureSurface(modifier = Modifier.weight(1f),
onRegularTap = defaultOnRegularTap,