diff --git a/submodules/Display/Source/InteractiveTransitionGestureRecognizer.swift b/submodules/Display/Source/InteractiveTransitionGestureRecognizer.swift index 8b72c2f7a0..56120b515e 100644 --- a/submodules/Display/Source/InteractiveTransitionGestureRecognizer.swift +++ b/submodules/Display/Source/InteractiveTransitionGestureRecognizer.swift @@ -61,21 +61,16 @@ public enum InteractiveTransitionGestureRecognizerEdgeWidth { } public class InteractiveTransitionGestureRecognizer: UIPanGestureRecognizer { - private let staticEdgeWidth: InteractiveTransitionGestureRecognizerEdgeWidth + private let edgeWidth: InteractiveTransitionGestureRecognizerEdgeWidth private let allowedDirections: (CGPoint) -> InteractiveTransitionGestureRecognizerDirections - public var dynamicEdgeWidth: ((CGPoint) -> InteractiveTransitionGestureRecognizerEdgeWidth)? - private var currentEdgeWidth: InteractiveTransitionGestureRecognizerEdgeWidth - - private var ignoreOffset: CGPoint = CGPoint() private var validatedGesture = false private var firstLocation: CGPoint = CGPoint() private var currentAllowedDirections: InteractiveTransitionGestureRecognizerDirections = [] public init(target: Any?, action: Selector?, allowedDirections: @escaping (CGPoint) -> InteractiveTransitionGestureRecognizerDirections, edgeWidth: InteractiveTransitionGestureRecognizerEdgeWidth = .constant(16.0)) { self.allowedDirections = allowedDirections - self.staticEdgeWidth = edgeWidth - self.currentEdgeWidth = edgeWidth + self.edgeWidth = edgeWidth super.init(target: target, action: action) @@ -86,7 +81,6 @@ public class InteractiveTransitionGestureRecognizer: UIPanGestureRecognizer { override public func reset() { super.reset() - self.ignoreOffset = CGPoint() self.validatedGesture = false self.currentAllowedDirections = [] } @@ -105,10 +99,6 @@ public class InteractiveTransitionGestureRecognizer: UIPanGestureRecognizer { return } - if let dynamicEdgeWidth = self.dynamicEdgeWidth { - self.currentEdgeWidth = dynamicEdgeWidth(point) - } - super.touchesBegan(touches, with: event) self.firstLocation = point @@ -138,11 +128,6 @@ public class InteractiveTransitionGestureRecognizer: UIPanGestureRecognizer { } } - override public func translation(in view: UIView?) -> CGPoint { - let result = super.translation(in: view) - return result//.offsetBy(dx: self.ignoreOffset.x, dy: self.ignoreOffset.y) - } - override public func touchesMoved(_ touches: Set, with event: UIEvent) { let location = touches.first!.location(in: self.view) let translation = CGPoint(x: location.x - self.firstLocation.x, y: location.y - self.firstLocation.y) @@ -161,63 +146,41 @@ public class InteractiveTransitionGestureRecognizer: UIPanGestureRecognizer { if absTranslationX > 2.0 && absTranslationX > absTranslationY * 2.0 { self.state = .failed } else if absTranslationY > 2.0 && absTranslationX * 2.0 < absTranslationY { - self.ignoreOffset = CGPoint(x: -translation.x, y: -translation.y) self.validatedGesture = true } } } else { - let defaultEdgeWidth: CGFloat - switch self.staticEdgeWidth { + let edgeWidth: CGFloat + switch self.edgeWidth { case let .constant(value): - defaultEdgeWidth = value + edgeWidth = value case let .widthMultiplier(factor, minValue, maxValue): - defaultEdgeWidth = max(minValue, min(size.width * factor, maxValue)) - } - - let extendedEdgeWidth: CGFloat - switch self.currentEdgeWidth { - case let .constant(value): - extendedEdgeWidth = value - case let .widthMultiplier(factor, minValue, maxValue): - extendedEdgeWidth = max(minValue, min(size.width * factor, maxValue)) + edgeWidth = max(minValue, min(size.width * factor, maxValue)) } if !self.validatedGesture { - if self.firstLocation.x < extendedEdgeWidth && !self.currentAllowedDirections.contains(.rightEdge) { + if self.firstLocation.x < edgeWidth && !self.currentAllowedDirections.contains(.rightEdge) { self.state = .failed return } - if self.firstLocation.x > size.width - extendedEdgeWidth && !self.currentAllowedDirections.contains(.leftEdge) { + if self.firstLocation.x > size.width - edgeWidth && !self.currentAllowedDirections.contains(.leftEdge) { self.state = .failed return } - if self.currentAllowedDirections.contains(.rightEdge) && self.firstLocation.x < extendedEdgeWidth { - if absTranslationY > 2.0 && absTranslationY > absTranslationX * 2.0 { - self.state = .failed - } else if absTranslationX > 2.0 && absTranslationY * 2.0 < absTranslationX { - self.ignoreOffset = CGPoint(x: -translation.x, y: -translation.y) - self.validatedGesture = true - fireBegan = true - } - } else { - if self.currentAllowedDirections.contains(.rightEdge) && self.firstLocation.x < defaultEdgeWidth { - self.ignoreOffset = CGPoint(x: -translation.x, y: -translation.y) - self.validatedGesture = true - } else if self.currentAllowedDirections.contains(.leftEdge) && self.firstLocation.x > size.width - defaultEdgeWidth { - self.ignoreOffset = CGPoint(x: -translation.x, y: -translation.y) - self.validatedGesture = true - } else if !self.currentAllowedDirections.contains(.leftCenter) && translation.x < 0.0 { - self.state = .failed - } else if !self.currentAllowedDirections.contains(.rightCenter) && translation.x > 0.0 { - self.state = .failed - } else if absTranslationY > 2.0 && absTranslationY > absTranslationX * 2.0 { - self.state = .failed - } else if absTranslationX > 2.0 && absTranslationY * 2.0 < absTranslationX { - self.ignoreOffset = CGPoint(x: -translation.x, y: -translation.y) - self.validatedGesture = true - fireBegan = true - } + if self.currentAllowedDirections.contains(.rightEdge) && self.firstLocation.x < edgeWidth { + self.validatedGesture = true + } else if self.currentAllowedDirections.contains(.leftEdge) && self.firstLocation.x > size.width - edgeWidth { + self.validatedGesture = true + } else if !self.currentAllowedDirections.contains(.leftCenter) && translation.x < 0.0 { + self.state = .failed + } else if !self.currentAllowedDirections.contains(.rightCenter) && translation.x > 0.0 { + self.state = .failed + } else if absTranslationY > 2.0 && absTranslationY > absTranslationX * 2.0 { + self.state = .failed + } else if absTranslationX > 2.0 && absTranslationY * 2.0 < absTranslationX { + self.validatedGesture = true + fireBegan = true } } } diff --git a/submodules/Display/Source/Navigation/NavigationContainer.swift b/submodules/Display/Source/Navigation/NavigationContainer.swift index 2a9614ff24..516639626d 100644 --- a/submodules/Display/Source/Navigation/NavigationContainer.swift +++ b/submodules/Display/Source/Navigation/NavigationContainer.swift @@ -142,12 +142,12 @@ public final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelega } return .right }) - panRecognizer.dynamicEdgeWidth = { [weak self] _ in + /*panRecognizer.dynamicEdgeWidth = { [weak self] _ in guard let self, let controller = self.controllers.last, let value = controller.interactiveNavivationGestureEdgeWidth else { return .constant(16.0) } return value - } + }*/ if #available(iOS 13.4, *) { panRecognizer.allowedScrollTypesMask = .continuous } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift index 6347011a3c..f75ac88511 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift @@ -305,7 +305,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { if let item = self.item { let _ = item replyRecognizer.allowBothDirections = false//!item.context.sharedContext.immediateExperimentalUISettings.unidirectionalSwipeToReply - self.view.disablesInteractiveTransitionGestureRecognizer = true + self.view.disablesInteractiveTransitionGestureRecognizer = false } replyRecognizer.shouldBegin = { [weak self] in if let strongSelf = self, let item = strongSelf.item {