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

View File

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