Skip to content

Commit

Permalink
Add partial fix allowing for presenting outer-modal from the inner one
Browse files Browse the repository at this point in the history
  • Loading branch information
kkafar committed Oct 4, 2023
1 parent e9c45df commit 7c463a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions ios/RNSScreen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ - (void)initCommonProps
#if !TARGET_OS_TV
_sheetExpandsWhenScrolledToEdge = YES;
#endif // !TARGET_OS_TV
NSLog(@"RNSScreenView alloc at %p with VC at %p", self, _controller);
}

- (UIViewController *)reactViewController
Expand Down
12 changes: 12 additions & 0 deletions ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ - (void)initCommonProps
// the header will render in collapsed state which is perhaps a bug
// in UIKit but ¯\_(ツ)_/¯
[_controller setViewControllers:@[ [UIViewController new] ]];
NSLog(@"RNSScreenStackView alloc at %p with NavVC at %p", self, _controller);
}

#pragma mark - helper methods
Expand Down Expand Up @@ -399,7 +400,17 @@ - (void)setModalViewControllers:(NSArray<UIViewController *> *)controllers
afterTransitions();
return;
} else {
NSLog(@"visibleViewController %p", self->_controller.visibleViewController);
UIViewController *previous = changeRootController;
UIViewController *visibleViewController = self->_controller.visibleViewController;
if ([visibleViewController isKindOfClass:RNSScreen.class]) {
RNSScreen *screen = (RNSScreen *)visibleViewController;
if (screen.screenView.isModal && screen.presentingViewController != weakSelf) {
// We have already presented a modal from different (nested) stack
// So the first view controller to be used as presenting view controller should be the last current modal.
previous = screen;
}
}
for (NSUInteger i = changeRootIndex; i < controllers.count; i++) {
UIViewController *next = controllers[i];
BOOL lastModal = (i == controllers.count - 1);
Expand All @@ -424,6 +435,7 @@ - (void)setModalViewControllers:(NSArray<UIViewController *> *)controllers
return;
}

NSLog(@"%p is presenting %p modally", previous, next);
[previous presentViewController:next
animated:shouldAnimate
completion:^{
Expand Down

0 comments on commit 7c463a1

Please sign in to comment.