Make GestureView respond to double touch gesture (#1260)
Some checks are pending
Build 🔨 / Build 🔨 (Swiftfin tvOS) (push) Waiting to run
Build 🔨 / Build 🔨 (Swiftfin) (push) Waiting to run

This commit is contained in:
Ziyang Huang 2024-10-09 07:09:44 +08:00 committed by GitHub
parent c5d6539018
commit 071a1f98e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View File

@ -174,7 +174,7 @@ class UIGestureView: UIView {
let pinchGesture = UIPinchGestureRecognizer(target: self, action: #selector(didPerformPinch))
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(didPerformTap))
let doubleTouchGesture = UITapGestureRecognizer(target: self, action: #selector(didPerformTap))
let doubleTouchGesture = UITapGestureRecognizer(target: self, action: #selector(didPerformDoubleTouch))
doubleTouchGesture.numberOfTouchesRequired = 2
let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(didPerformLongPress))
longPressGesture.minimumPressDuration = longPressMinimumDuration

View File

@ -376,6 +376,11 @@ extension VideoPlayer {
}
private func handleDoubleTouchGesture(unitPoint: UnitPoint, taps: Int) {
if doubleTouchGesture == .gestureLock {
guard !isPresentingOverlay else { return }
isGestureLocked.toggle()
}
guard !isGestureLocked else {
updateViewProxy.present(systemName: "lock.fill", title: "Gestures Locked")
return
@ -385,10 +390,15 @@ extension VideoPlayer {
case .none:
return
case .aspectFill: ()
case .gestureLock:
guard !isPresentingOverlay else { return }
isGestureLocked.toggle()
case .pausePlay: ()
case .pausePlay:
switch videoPlayerManager.state {
case .playing:
videoPlayerManager.proxy.pause()
default:
videoPlayerManager.proxy.play()
}
default:
break
}
}
}