mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-28 08:30:11 +00:00
Fixed navigation buttons touch insets
This commit is contained in:
parent
5bd6ce75fd
commit
af872377a3
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -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<Bool>? = nil) {
|
||||
public func replaceAllButRootController(_ controller: ViewController, animated: Bool, ready: ValuePromise<Bool>? = 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()
|
||||
|
@ -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);
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user