yogevbd 6 years ago
parent
commit
f3b80b821e

+ 3
- 5
lib/ios/RNNCommandsHandler.m View File

@@ -178,14 +178,12 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
178 178
 -(void) popTo:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
179 179
 	[self assertReady];
180 180
 	RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId];
181
-
181
+	
182 182
 	[_stackManager popTo:vc animated:vc.options.animations.pop.enable completion:^(NSArray *poppedViewControllers) {
183 183
 		[_eventEmitter sendOnNavigationCommandCompletion:popTo params:@{@"componentId": componentId}];
184 184
 		[self removePopedViewControllers:poppedViewControllers];
185 185
 		completion();
186
-	} rejection:^(NSString *code, NSString *message, NSError *error) {
187
-		
188
-	}];
186
+	} rejection:rejection];
189 187
 }
190 188
 
191 189
 -(void) popToRoot:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
@@ -211,7 +209,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
211 209
 	[self assertReady];
212 210
 
213 211
 	UIViewController<RNNRootViewProtocol> *newVc = [_controllerFactory createLayoutAndSaveToStore:layout];
214
-	[_modalManager showModal:newVc completion:^{
212
+	[_modalManager showModal:newVc animated:newVc.getLeafViewController.options.animations.showModal.enable completion:^{
215 213
 		[_eventEmitter sendOnNavigationCommandCompletion:showModal params:@{@"layout": layout}];
216 214
 		completion();
217 215
 	}];

+ 1
- 1
lib/ios/RNNModalManager.h View File

@@ -7,7 +7,7 @@
7 7
 @property (nonatomic, strong) UIViewController<RNNRootViewProtocol>* toVC;
8 8
 
9 9
 -(instancetype)initWithStore:(RNNStore*)store;
10
--(void)showModal:(UIViewController*)viewController completion:(RNNTransitionCompletionBlock)completion;
10
+-(void)showModal:(UIViewController*)viewController animated:(BOOL)animated completion:(RNNTransitionCompletionBlock)completion;
11 11
 -(void)dismissModal:(NSString*)componentId;
12 12
 -(void)dismissAllModals;
13 13
 

+ 4
- 9
lib/ios/RNNModalManager.m View File

@@ -13,10 +13,9 @@
13 13
 	return self;
14 14
 }
15 15
 
16
--(void)showModalAfterLoad:(NSDictionary*)notif {
16
+-(void)showModal:(BOOL)animated {
17 17
 	UIViewController* topVC = [self topPresentedVC];
18 18
 	topVC.definesPresentationContext = YES;
19
-	BOOL animated = true;
20 19
 	
21 20
 	if ([topVC conformsToProtocol:@protocol(RNNRootViewProtocol)]) {
22 21
 		UIViewController<RNNRootViewProtocol> *navigationTopVC = (UIViewController<RNNRootViewProtocol>*)topVC;
@@ -24,11 +23,7 @@
24 23
 		if (options.animations.showModal.hasCustomAnimation) {
25 24
 			self.toVC.transitioningDelegate = navigationTopVC;
26 25
 		}
27
-		
28
-		animated = options.animations.showModal.enable;
29 26
 	}
30
-
31
-	
32 27
 	
33 28
 	[topVC presentViewController:self.toVC animated:animated completion:^{
34 29
 		if (_completionBlock) {
@@ -39,7 +34,7 @@
39 34
 	}];
40 35
 }
41 36
 
42
--(void)showModal:(UIViewController *)viewController completion:(RNNTransitionCompletionBlock)completion {
37
+-(void)showModal:(UIViewController *)viewController animated:(BOOL)animated completion:(RNNTransitionCompletionBlock)completion {
43 38
 	self.toVC = (UIViewController<RNNRootViewProtocol>*)viewController;
44 39
 	RNNNavigationOptions* options = self.toVC.getLeafViewController.options;
45 40
 
@@ -52,10 +47,10 @@
52 47
     if ([self.toVC respondsToSelector:@selector(isCustomViewController)] &&
53 48
         [self.toVC.getLeafViewController isCustomViewController]
54 49
     ) {
55
-		[self showModalAfterLoad:nil];
50
+		[self showModal:animated];
56 51
 	} else {
57 52
 		[self.toVC.getLeafViewController waitForReactViewRender:options.animations.showModal.waitForRender perform:^{
58
-			[self showModalAfterLoad:nil];
53
+			[self showModal:animated];
59 54
 		}];
60 55
 	}
61 56
 }

+ 11
- 7
lib/ios/RNNNavigationStackManager.m View File

@@ -29,13 +29,17 @@ typedef void (^RNNAnimationBlock)(void);
29 29
 - (void)popTo:(UIViewController *)viewController animated:(BOOL)animated completion:(RNNPopCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)rejection; {
30 30
 	__block NSArray* poppedVCs;
31 31
 	
32
-	[self performAnimationBlock:^{
33
-		poppedVCs = [viewController.navigationController popToViewController:viewController animated:animated];
34
-	} completion:^{
35
-		if (completion) {
36
-			completion(poppedVCs);
37
-		}
38
-	}];
32
+	if ([viewController.navigationController.childViewControllers containsObject:viewController]) {
33
+		[self performAnimationBlock:^{
34
+			poppedVCs = [viewController.navigationController popToViewController:viewController animated:animated];
35
+		} completion:^{
36
+			if (completion) {
37
+				completion(poppedVCs);
38
+			}
39
+		}];
40
+	} else {
41
+		[RNNErrorHandler reject:rejection withErrorCode:1011 errorDescription:@"component not found in stack"];
42
+	}
39 43
 }
40 44
 
41 45
 - (void)popToRoot:(UIViewController*)viewController animated:(BOOL)animated completion:(RNNPopCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)rejection {