diff --git a/submodules/Display/Source/WindowContent.swift b/submodules/Display/Source/WindowContent.swift index e1bbea3b17..b716d17fb4 100644 --- a/submodules/Display/Source/WindowContent.swift +++ b/submodules/Display/Source/WindowContent.swift @@ -231,6 +231,16 @@ private func layoutMetricsForScreenSize(size: CGSize, orientation: UIInterfaceOr } public final class WindowKeyboardGestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate { + public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool { + if let view = gestureRecognizer.view { + let location = touch.location(in: gestureRecognizer.view) + if location.y > view.bounds.height - 44.0 { + return false + } + } + return true + } + public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { return true } @@ -1299,7 +1309,7 @@ public class Window1 { } } - @objc func panGesture(_ recognizer: UIPanGestureRecognizer) { + @objc func panGesture(_ recognizer: WindowPanRecognizer) { switch recognizer.state { case .began: self.panGestureBegan(location: recognizer.location(in: recognizer.view)) diff --git a/submodules/Display/Source/WindowPanRecognizer.swift b/submodules/Display/Source/WindowPanRecognizer.swift index 53ed394912..7ef93a5ca6 100644 --- a/submodules/Display/Source/WindowPanRecognizer.swift +++ b/submodules/Display/Source/WindowPanRecognizer.swift @@ -7,6 +7,7 @@ public final class WindowPanRecognizer: UIGestureRecognizer { public var ended: ((CGPoint, CGPoint?) -> Void)? private var previousPoints: [(CGPoint, Double)] = [] + private var previousVelocity: CGFloat = 0.0 override public func reset() { super.reset() @@ -45,6 +46,11 @@ public final class WindowPanRecognizer: UIGestureRecognizer { } } + func velocity(in view: UIView?) -> CGPoint { + let point = CGPoint(x: 0.0, y: self.previousVelocity) + return self.view?.convert(point, to: view) ?? .zero + } + override public func touchesBegan(_ touches: Set, with event: UIEvent) { super.touchesBegan(touches, with: event) @@ -68,9 +74,12 @@ public final class WindowPanRecognizer: UIGestureRecognizer { override public func touchesEnded(_ touches: Set, with event: UIEvent) { super.touchesEnded(touches, with: event) + self.state = .ended + if let touch = touches.first { let location = touch.location(in: self.view) self.addPoint(location) + self.previousVelocity = self.estimateVerticalVelocity() self.ended?(location, CGPoint(x: 0.0, y: self.estimateVerticalVelocity())) } } @@ -78,6 +87,8 @@ public final class WindowPanRecognizer: UIGestureRecognizer { override public func touchesCancelled(_ touches: Set, with event: UIEvent) { super.touchesCancelled(touches, with: event) + self.state = .cancelled + if let touch = touches.first { self.ended?(touch.location(in: self.view), nil) }