Change controls tap behavior

This commit is contained in:
Arkadiusz Fal 2022-12-26 19:41:58 +01:00
parent 8ca499756a
commit 1d0615c9e1
2 changed files with 10 additions and 7 deletions

View File

@ -10,12 +10,13 @@ struct PlayerGestures: View {
gestureRectangle
.tapRecognizer(
tapSensitivity: 0.2,
singleTapAction: { singleTapAction() },
doubleTapAction: {
model.presentingControls = false
let interval = TimeInterval(Defaults[.gestureBackwardSeekDuration]) ?? 10
player.backend.seek(relative: .secondsInDefaultTimescale(-interval), seekType: .userInteracted)
},
anyTapAction: {
singleTapAction()
model.update()
}
)
@ -23,20 +24,22 @@ struct PlayerGestures: View {
gestureRectangle
.tapRecognizer(
tapSensitivity: 0.2,
singleTapAction: { singleTapAction() },
doubleTapAction: {
model.presentingControls = false
player.backend.togglePlay()
}
},
anyTapAction: singleTapAction
)
gestureRectangle
.tapRecognizer(
tapSensitivity: 0.2,
singleTapAction: { singleTapAction() },
doubleTapAction: {
model.presentingControls = false
let interval = TimeInterval(Defaults[.gestureForwardSeekDuration]) ?? 10
player.backend.seek(relative: .secondsInDefaultTimescale(interval), seekType: .userInteracted)
}
},
anyTapAction: singleTapAction
)
}
}

View File

@ -53,8 +53,8 @@ struct TapRecognizerViewModifier: ViewModifier {
extension View {
func tapRecognizer(
tapSensitivity: Double,
singleTapAction: @escaping () -> Void,
doubleTapAction: @escaping () -> Void,
singleTapAction: @escaping () -> Void = {},
doubleTapAction: @escaping () -> Void = {},
anyTapAction: @escaping () -> Void = {}
) -> some View {
modifier(