Skip to content

Commit

Permalink
chore: make RNSScreenStack#hitTest:withEvent: method shared
Browse files Browse the repository at this point in the history
  • Loading branch information
kkafar committed May 13, 2022
1 parent c51233d commit c88fcc1
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,23 @@ - (BOOL)isInGestureResponseDistance:(UIGestureRecognizer *)gestureRecognizer top
(bottom != -1 && y > bottom));
}

// By default, the header buttons that are not inside the native hit area
// cannot be clicked, so we check it by ourselves
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
if (CGRectContainsPoint(_controller.navigationBar.frame, point)) {
// headerConfig should be the first subview of the topmost screen
UIView *headerConfig = [[_reactSubviews.lastObject reactSubviews] firstObject];
if ([headerConfig isKindOfClass:[RNSScreenStackHeaderConfig class]]) {
UIView *headerHitTestResult = [headerConfig hitTest:point withEvent:event];
if (headerHitTestResult != nil) {
return headerHitTestResult;
}
}
}
return [super hitTest:point withEvent:event];
}

#ifdef RN_FABRIC_ENABLED
#pragma mark - Fabric specific

Expand Down Expand Up @@ -892,23 +909,6 @@ - (void)didUpdateReactSubviews
});
}

// By default, the header buttons that are not inside the native hit area
// cannot be clicked, so we check it by ourselves
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
if (CGRectContainsPoint(_controller.navigationBar.frame, point)) {
// headerConfig should be the first subview of the topmost screen
UIView *headerConfig = [[_reactSubviews.lastObject reactSubviews] firstObject];
if ([headerConfig isKindOfClass:[RNSScreenStackHeaderConfig class]]) {
UIView *headerHitTestResult = [headerConfig hitTest:point withEvent:event];
if (headerHitTestResult != nil) {
return headerHitTestResult;
}
}
}
return [super hitTest:point withEvent:event];
}

- (void)invalidate
{
_invalidated = YES;
Expand Down

0 comments on commit c88fcc1

Please sign in to comment.