|
@@ -2,7 +2,6 @@
|
2
|
2
|
#import "RNNRootViewController.h"
|
3
|
3
|
|
4
|
4
|
@implementation RNNModalManager {
|
5
|
|
- RNNTransitionWithComponentIdCompletionBlock _completionBlock;
|
6
|
5
|
NSMutableArray* _pendingModalIdsToDismiss;
|
7
|
6
|
NSMutableArray* _presentedModals;
|
8
|
7
|
}
|
|
@@ -16,51 +15,31 @@
|
16
|
15
|
return self;
|
17
|
16
|
}
|
18
|
17
|
|
19
|
|
--(void)showModal:(BOOL)animated {
|
|
18
|
+-(void)showModal:(UIViewController *)viewController animated:(BOOL)animated completion:(RNNTransitionWithComponentIdCompletionBlock)completion {
|
|
19
|
+ [self showModal:viewController animated:animated hasCustomAnimation:NO completion:completion];
|
|
20
|
+}
|
|
21
|
+
|
|
22
|
+-(void)showModal:(UIViewController *)viewController animated:(BOOL)animated hasCustomAnimation:(BOOL)hasCustomAnimation completion:(RNNTransitionWithComponentIdCompletionBlock)completion {
|
|
23
|
+ if (!viewController) {
|
|
24
|
+ @throw [NSException exceptionWithName:@"ShowUnknownModal" reason:@"showModal called with nil viewController" userInfo:nil];
|
|
25
|
+ }
|
|
26
|
+
|
20
|
27
|
UIViewController* topVC = [self topPresentedVC];
|
21
|
28
|
topVC.definesPresentationContext = YES;
|
22
|
29
|
|
23
|
|
- if ([topVC conformsToProtocol:@protocol(RNNRootViewProtocol)]) {
|
24
|
|
- UIViewController<RNNRootViewProtocol> *navigationTopVC = (UIViewController<RNNRootViewProtocol>*)topVC;
|
25
|
|
- RNNNavigationOptions* options = navigationTopVC.getLeafViewController.options;
|
26
|
|
- if (options.animations.showModal.hasCustomAnimation) {
|
27
|
|
- self.toVC.transitioningDelegate = navigationTopVC;
|
28
|
|
- }
|
|
30
|
+ if (hasCustomAnimation) {
|
|
31
|
+ viewController.transitioningDelegate = (UIViewController<UIViewControllerTransitioningDelegate>*)topVC;
|
29
|
32
|
}
|
30
|
33
|
|
31
|
|
- [topVC presentViewController:self.toVC animated:animated completion:^{
|
32
|
|
- if (_completionBlock) {
|
33
|
|
- _completionBlock(self.toVC.getLeafViewController.componentId);
|
34
|
|
- _completionBlock = nil;
|
|
34
|
+ [topVC presentViewController:viewController animated:animated completion:^{
|
|
35
|
+ if (completion) {
|
|
36
|
+ completion(nil);
|
35
|
37
|
}
|
36
|
38
|
|
37
|
|
- [_presentedModals addObject:self.toVC.navigationController ? self.toVC.navigationController : self.toVC];
|
38
|
|
-
|
39
|
|
- self.toVC = nil;
|
|
39
|
+ [_presentedModals addObject:viewController.navigationController ? viewController.navigationController : viewController];
|
40
|
40
|
}];
|
41
|
41
|
}
|
42
|
42
|
|
43
|
|
--(void)showModal:(UIViewController *)viewController animated:(BOOL)animated completion:(RNNTransitionWithComponentIdCompletionBlock)completion {
|
44
|
|
- self.toVC = (UIViewController<RNNRootViewProtocol>*)viewController;
|
45
|
|
- RNNNavigationOptions* options = self.toVC.getLeafViewController.options;
|
46
|
|
-
|
47
|
|
- _completionBlock = completion;
|
48
|
|
-
|
49
|
|
- if ([self.toVC respondsToSelector:@selector(applyModalOptions)]) {
|
50
|
|
- [self.toVC.getLeafViewController applyModalOptions];
|
51
|
|
- }
|
52
|
|
-
|
53
|
|
- if ([self.toVC respondsToSelector:@selector(isCustomViewController)] &&
|
54
|
|
- [self.toVC.getLeafViewController isCustomViewController]
|
55
|
|
- ) {
|
56
|
|
- [self showModal:animated];
|
57
|
|
- } else {
|
58
|
|
- [self.toVC.getLeafViewController waitForReactViewRender:options.animations.showModal.waitForRender perform:^{
|
59
|
|
- [self showModal:animated];
|
60
|
|
- }];
|
61
|
|
- }
|
62
|
|
-}
|
63
|
|
-
|
64
|
43
|
- (void)dismissModal:(UIViewController *)viewController completion:(RNNTransitionCompletionBlock)completion {
|
65
|
44
|
if (viewController) {
|
66
|
45
|
[_pendingModalIdsToDismiss addObject:viewController];
|