Skip to content

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kkafar committed Oct 17, 2023
1 parent 3d1fb05 commit 2022c76
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,14 @@ - (void)setModalViewControllers:(NSArray<UIViewController *> *)controllers
NSMutableArray<UIViewController *> *newControllers = [NSMutableArray arrayWithArray:controllers];
[newControllers removeObjectsInArray:_presentedModals];

// find bottom-most controller that should stay on the stack for the duration of transition
// We need to find bottom-most view controller that should stay on the stack
// for the duration of transition. There are couple of scenarios:
// (1) No modals are presented or all modals were presented by this RNSNavigationController,
// (2) There are modals presented by other RNSNavigationControllers (nested/outer)

// Szukamy ile modali od dołu jest takich samych jak wcześniej
// Jeżeli nie ma takiego "prefixu", to "bazowym" kontrollerem jest wtedy
// RNSNavigationController skojarzony z tym widokiem
NSUInteger changeRootIndex = 0;
UIViewController *changeRootController = _controller;
for (NSUInteger i = 0; i < MIN(_presentedModals.count, controllers.count); i++) {
Expand Down Expand Up @@ -458,6 +465,9 @@ - (void)setModalViewControllers:(NSArray<UIViewController *> *)controllers
[changeRootController.presentedViewController isKindOfClass:[RNSScreen class]] &&
((RNSScreen *)changeRootController.presentedViewController).screenView.stackAnimation !=
RNSScreenStackAnimationNone;
// We dismiss every VC that was presented by changeRootController VC or its descendant.
// After the series of dismissals is completed we run completion block in which
// we present modals on top of changeRootController (which may be the this stack VC)
[changeRootController dismissViewControllerAnimated:shouldAnimate completion:finish];
} else {
finish();
Expand Down

0 comments on commit 2022c76

Please sign in to comment.