Make `GestureView` respond to double touch gesture (#1260)

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 pinchGesture = UIPinchGestureRecognizer(target: self, action: #selector(didPerformPinch))
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(didPerformTap)) 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 doubleTouchGesture.numberOfTouchesRequired = 2
let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(didPerformLongPress)) let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(didPerformLongPress))
longPressGesture.minimumPressDuration = longPressMinimumDuration longPressGesture.minimumPressDuration = longPressMinimumDuration

View File

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