yogevbd 6 years ago
parent
commit
f3b80b821e

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

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

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

7
 @property (nonatomic, strong) UIViewController<RNNRootViewProtocol>* toVC;
7
 @property (nonatomic, strong) UIViewController<RNNRootViewProtocol>* toVC;
8
 
8
 
9
 -(instancetype)initWithStore:(RNNStore*)store;
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
 -(void)dismissModal:(NSString*)componentId;
11
 -(void)dismissModal:(NSString*)componentId;
12
 -(void)dismissAllModals;
12
 -(void)dismissAllModals;
13
 
13
 

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

13
 	return self;
13
 	return self;
14
 }
14
 }
15
 
15
 
16
--(void)showModalAfterLoad:(NSDictionary*)notif {
16
+-(void)showModal:(BOOL)animated {
17
 	UIViewController* topVC = [self topPresentedVC];
17
 	UIViewController* topVC = [self topPresentedVC];
18
 	topVC.definesPresentationContext = YES;
18
 	topVC.definesPresentationContext = YES;
19
-	BOOL animated = true;
20
 	
19
 	
21
 	if ([topVC conformsToProtocol:@protocol(RNNRootViewProtocol)]) {
20
 	if ([topVC conformsToProtocol:@protocol(RNNRootViewProtocol)]) {
22
 		UIViewController<RNNRootViewProtocol> *navigationTopVC = (UIViewController<RNNRootViewProtocol>*)topVC;
21
 		UIViewController<RNNRootViewProtocol> *navigationTopVC = (UIViewController<RNNRootViewProtocol>*)topVC;
24
 		if (options.animations.showModal.hasCustomAnimation) {
23
 		if (options.animations.showModal.hasCustomAnimation) {
25
 			self.toVC.transitioningDelegate = navigationTopVC;
24
 			self.toVC.transitioningDelegate = navigationTopVC;
26
 		}
25
 		}
27
-		
28
-		animated = options.animations.showModal.enable;
29
 	}
26
 	}
30
-
31
-	
32
 	
27
 	
33
 	[topVC presentViewController:self.toVC animated:animated completion:^{
28
 	[topVC presentViewController:self.toVC animated:animated completion:^{
34
 		if (_completionBlock) {
29
 		if (_completionBlock) {
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
 	self.toVC = (UIViewController<RNNRootViewProtocol>*)viewController;
38
 	self.toVC = (UIViewController<RNNRootViewProtocol>*)viewController;
44
 	RNNNavigationOptions* options = self.toVC.getLeafViewController.options;
39
 	RNNNavigationOptions* options = self.toVC.getLeafViewController.options;
45
 
40
 
52
     if ([self.toVC respondsToSelector:@selector(isCustomViewController)] &&
47
     if ([self.toVC respondsToSelector:@selector(isCustomViewController)] &&
53
         [self.toVC.getLeafViewController isCustomViewController]
48
         [self.toVC.getLeafViewController isCustomViewController]
54
     ) {
49
     ) {
55
-		[self showModalAfterLoad:nil];
50
+		[self showModal:animated];
56
 	} else {
51
 	} else {
57
 		[self.toVC.getLeafViewController waitForReactViewRender:options.animations.showModal.waitForRender perform:^{
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
 - (void)popTo:(UIViewController *)viewController animated:(BOOL)animated completion:(RNNPopCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)rejection; {
29
 - (void)popTo:(UIViewController *)viewController animated:(BOOL)animated completion:(RNNPopCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)rejection; {
30
 	__block NSArray* poppedVCs;
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
 - (void)popToRoot:(UIViewController*)viewController animated:(BOOL)animated completion:(RNNPopCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)rejection {
45
 - (void)popToRoot:(UIViewController*)viewController animated:(BOOL)animated completion:(RNNPopCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)rejection {