Skip to content

Commit

Permalink
Fix stack with gestureEnabled=false on iOS (#283)
Browse files Browse the repository at this point in the history
#254 without breaking changes

Instead of moving gestureEnabled to the screen we find the header config subview.
  • Loading branch information
janicduplessis authored and osdnk committed Jan 14, 2020
1 parent ce819f6 commit 27ef6dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 10 additions & 1 deletion ios/RNSScreenStack.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,16 @@ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
RCTRootContentView *rootView = (RCTRootContentView *)parent;
[rootView.touchHandler cancel];

return _controller.viewControllers.count > 1;
UIView *topView = _controller.viewControllers.lastObject.view;
RNSScreenStackHeaderConfig *config = nil;
for (UIView *subview in topView.reactSubviews) {
if ([subview isKindOfClass:[RNSScreenStackHeaderConfig class]]) {
config = (RNSScreenStackHeaderConfig*) subview;
break;
}
}

return _controller.viewControllers.count > 1 && (config == nil || config.gestureEnabled);
}

- (void)markChildUpdated
Expand Down
1 change: 0 additions & 1 deletion ios/RNSScreenStackHeaderConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ + (void)updateViewController:(UIViewController *)vc withConfig:(RNSScreenStackHe
}

[navctr setNavigationBarHidden:shouldHide animated:YES];
navctr.interactivePopGestureRecognizer.enabled = config.gestureEnabled;
#ifdef __IPHONE_13_0
if (@available(iOS 13.0, *)) {
vc.modalInPresentation = !config.gestureEnabled;
Expand Down

0 comments on commit 27ef6dc

Please sign in to comment.