@@ -475,45 +475,46 @@ - (void)setModalViewControllers:(NSArray<UIViewController *> *)controllers
475
475
}
476
476
BOOL isAttached =
477
477
changeRootController.parentViewController != nil || changeRootController.presentingViewController != nil ;
478
+
478
479
if (!isAttached || changeRootIndex >= controllers.count ) {
479
480
// if change controller view is not attached, presenting modals will silently fail on iOS.
480
481
// In such a case we trigger controllers update from didMoveToWindow.
481
482
// We also don't run any present transitions if changeRootIndex is greater or equal to the size
482
483
// of new controllers array. This means that no new controllers should be presented.
483
484
afterTransitions ();
484
485
return ;
485
- } else {
486
- UIViewController *previous = changeRootController;
486
+ }
487
487
488
- for (NSUInteger i = changeRootIndex; i < controllers.count ; i++) {
489
- UIViewController *next = controllers[i];
490
- BOOL lastModal = (i == controllers.count - 1 );
488
+ UIViewController *previous = changeRootController;
491
489
492
- // Inherit UI style from its parent - solves an issue with incorrect style being applied to some UIKit views
493
- // like date picker or segmented control.
494
- next. overrideUserInterfaceStyle = self-> _controller . overrideUserInterfaceStyle ;
490
+ for ( NSUInteger i = changeRootIndex; i < controllers. count ; i++) {
491
+ UIViewController *next = controllers[i];
492
+ BOOL lastModal = (i == controllers. count - 1 ) ;
495
493
496
- BOOL shouldAnimate = lastModal && [next isKindOfClass: [RNSScreen class ]] &&
497
- ((RNSScreen *)next).screenView .stackAnimation != RNSScreenStackAnimationNone;
494
+ // Inherit UI style from its parent - solves an issue with incorrect style being applied to some UIKit views
495
+ // like date picker or segmented control.
496
+ next.overrideUserInterfaceStyle = self->_controller .overrideUserInterfaceStyle ;
498
497
499
- // if you want to present another modal quick enough after dismissing the previous one,
500
- // it will result in wrong changeRootController, see repro in
501
- // https://github.com/software-mansion/react-native-screens/issues/1299 We call `updateContainer` again in
502
- // `presentationControllerDidDismiss` to cover this case and present new controller
503
- if (previous.beingDismissed ) {
504
- return ;
505
- }
498
+ BOOL shouldAnimate = lastModal && [next isKindOfClass: [RNSScreen class ]] &&
499
+ ((RNSScreen *)next).screenView .stackAnimation != RNSScreenStackAnimationNone;
506
500
507
- [previous presentViewController: next
508
- animated: shouldAnimate
509
- completion: ^{
510
- [weakSelf.presentedModals addObject: next];
511
- if (lastModal) {
512
- afterTransitions ();
513
- };
514
- }];
515
- previous = next;
501
+ // if you want to present another modal quick enough after dismissing the previous one,
502
+ // it will result in wrong changeRootController, see repro in
503
+ // https://github.com/software-mansion/react-native-screens/issues/1299 We call `updateContainer` again in
504
+ // `presentationControllerDidDismiss` to cover this case and present new controller
505
+ if (previous.beingDismissed ) {
506
+ return ;
516
507
}
508
+
509
+ [previous presentViewController: next
510
+ animated: shouldAnimate
511
+ completion: ^{
512
+ [weakSelf.presentedModals addObject: next];
513
+ if (lastModal) {
514
+ afterTransitions ();
515
+ };
516
+ }];
517
+ previous = next;
517
518
}
518
519
};
519
520
0 commit comments