diff --git a/Display/NavigationBar.swift b/Display/NavigationBar.swift index 61931c9b67..abf0d835e3 100644 --- a/Display/NavigationBar.swift +++ b/Display/NavigationBar.swift @@ -603,6 +603,7 @@ open class NavigationBar: ASDisplayNode { self.backButtonArrow.displaysAsynchronously = false self.leftButtonNode = NavigationButtonNode() self.rightButtonNode = NavigationButtonNode() + self.rightButtonNode.hitTestSlop = UIEdgeInsets(top: -4.0, left: -4.0, bottom: -4.0, right: -10.0) self.clippingNode = ASDisplayNode() self.clippingNode.clipsToBounds = true @@ -1003,4 +1004,15 @@ open class NavigationBar: ASDisplayNode { } } } + + override open func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { + if self.frame.contains(point) { + if !self.rightButtonNode.isHidden { + if let result = self.rightButtonNode.hitTest(self.view.convert(point, to: self.rightButtonNode.view), with: event) { + return result + } + } + } + return super.hitTest(point, with: event) + } } diff --git a/Display/NavigationButtonNode.swift b/Display/NavigationButtonNode.swift index a56663fcc3..d2db53b9d8 100644 --- a/Display/NavigationButtonNode.swift +++ b/Display/NavigationButtonNode.swift @@ -149,9 +149,9 @@ private final class NavigationButtonItemNode: ASTextNode { var apparentBounds = self.bounds let hitTestSlop = self.hitTestSlop apparentBounds.origin.x += hitTestSlop.left - apparentBounds.size.width -= hitTestSlop.left + hitTestSlop.right + apparentBounds.size.width += -hitTestSlop.left - hitTestSlop.right apparentBounds.origin.y += hitTestSlop.top - apparentBounds.size.height -= hitTestSlop.top + hitTestSlop.bottom + apparentBounds.size.height += -hitTestSlop.top - hitTestSlop.bottom return apparentBounds.contains(touch.location(in: self.view)) } diff --git a/Display/NavigationController.swift b/Display/NavigationController.swift index 5cbee58463..0994fb007d 100644 --- a/Display/NavigationController.swift +++ b/Display/NavigationController.swift @@ -718,6 +718,10 @@ open class NavigationController: UINavigationController, ContainableController, } public func pushViewController(_ controller: ViewController) { + self.pushViewController(controller, completion: {}) + } + + public func pushViewController(_ controller: ViewController, completion: @escaping () -> Void) { let navigateAction: () -> Void = { [weak self] in guard let strongSelf = self else { return @@ -784,7 +788,7 @@ open class NavigationController: UINavigationController, ContainableController, })) } - public func replaceAllButRootController(_ controller: ViewController, animated: Bool, ready: ValuePromise? = nil) { + public func replaceAllButRootController(_ controller: ViewController, animated: Bool, ready: ValuePromise? = nil, completion: @escaping () -> Void = {}) { self.view.endEditing(true) if let validLayout = self.validLayout { var (_, controllerLayout) = self.layoutDataForConfiguration(self.layoutConfiguration(for: validLayout), layout: validLayout, index: self.viewControllers.count) @@ -794,6 +798,7 @@ open class NavigationController: UINavigationController, ContainableController, self.currentPushDisposable.set((controller.ready.get() |> take(1)).start(next: { [weak self] _ in if let strongSelf = self { ready?.set(true) + completion() var controllers = strongSelf.viewControllers while controllers.count > 1 { controllers.removeLast() diff --git a/Display/UIViewController+Navigation.h b/Display/UIViewController+Navigation.h index ff134d36c1..5c71ced132 100644 --- a/Display/UIViewController+Navigation.h +++ b/Display/UIViewController+Navigation.h @@ -21,6 +21,8 @@ typedef NS_OPTIONS(NSUInteger, UIResponderDisableAutomaticKeyboardHandling) { @interface UIView (Navigation) @property (nonatomic) bool disablesInteractiveTransitionGestureRecognizer; +@property (nonatomic, copy) bool (^ disablesInteractiveTransitionGestureRecognizerNow)(); + @property (nonatomic) UIResponderDisableAutomaticKeyboardHandling disableAutomaticKeyboardHandling; @property (nonatomic, copy) BOOL (^_Nullable interactiveTransitionGestureRecognizerTest)(CGPoint); diff --git a/Display/UIViewController+Navigation.m b/Display/UIViewController+Navigation.m index 2aed4b00ad..cfef8b7103 100644 --- a/Display/UIViewController+Navigation.m +++ b/Display/UIViewController+Navigation.m @@ -35,6 +35,7 @@ static const void *UIViewControllerNavigationControllerKey = &UIViewControllerNa static const void *UIViewControllerPresentingControllerKey = &UIViewControllerPresentingControllerKey; static const void *UIViewControllerPresentingProxyControllerKey = &UIViewControllerPresentingProxyControllerKey; static const void *disablesInteractiveTransitionGestureRecognizerKey = &disablesInteractiveTransitionGestureRecognizerKey; +static const void *disablesInteractiveTransitionGestureRecognizerNowKey = &disablesInteractiveTransitionGestureRecognizerNowKey; static const void *disableAutomaticKeyboardHandlingKey = &disableAutomaticKeyboardHandlingKey; static const void *setNeedsStatusBarAppearanceUpdateKey = &setNeedsStatusBarAppearanceUpdateKey; static const void *inputAccessoryHeightProviderKey = &inputAccessoryHeightProviderKey; @@ -232,6 +233,14 @@ static bool notyfyingShiftState = false; [self setAssociatedObject:@(disablesInteractiveTransitionGestureRecognizer) forKey:disablesInteractiveTransitionGestureRecognizerKey]; } +- (bool (^)())disablesInteractiveTransitionGestureRecognizerNow { + return [self associatedObjectForKey:disablesInteractiveTransitionGestureRecognizerNowKey]; +} + +- (void)setDisablesInteractiveTransitionGestureRecognizerNow:(bool (^)())disablesInteractiveTransitionGestureRecognizerNow { + [self setAssociatedObject:[disablesInteractiveTransitionGestureRecognizerNow copy] forKey:disablesInteractiveTransitionGestureRecognizerNowKey]; +} + - (BOOL (^)(CGPoint))interactiveTransitionGestureRecognizerTest { return [self associatedObjectForKey:interactiveTransitionGestureRecognizerTestKey]; } diff --git a/Display/WindowContent.swift b/Display/WindowContent.swift index 19ea652fe6..bb9f097419 100644 --- a/Display/WindowContent.swift +++ b/Display/WindowContent.swift @@ -132,6 +132,9 @@ public func doesViewTreeDisableInteractiveTransitionGestureRecognizer(_ view: UI if view.disablesInteractiveTransitionGestureRecognizer { return true } + if let f = view.disablesInteractiveTransitionGestureRecognizerNow, f() { + return true + } if let superview = view.superview { return doesViewTreeDisableInteractiveTransitionGestureRecognizer(superview) }