| 
				
			 | 
			
			
				@@ -2,9 +2,14 @@ 
			 | 
		
	
		
			
			| 
				2
			 | 
			
				2
			 | 
			
			
				 #import "RNNRootViewController.h" 
			 | 
		
	
		
			
			| 
				3
			 | 
			
				3
			 | 
			
			
				 #import "RNNAnimator.h" 
			 | 
		
	
		
			
			| 
				4
			 | 
			
				4
			 | 
			
			
				 #import "RNNErrorHandler.h" 
			 | 
		
	
		
			
			| 
				5
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				
			 | 
			
				5
			 | 
			
			
				+#import "RNNNavigationController.h" 
			 | 
		
	
		
			
			| 
				6
			 | 
			
				6
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				7
			 | 
			
				7
			 | 
			
			
				 dispatch_queue_t RCTGetUIManagerQueue(void); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				8
			 | 
			
			
				+@interface RNNNavigationStackManager() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				9
			 | 
			
			
				+@property (nonatomic, strong) RNNNavigationController* nvc; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				10
			 | 
			
			
				+@property (nonatomic, strong) RNNRootViewController* toVC; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				11
			 | 
			
			
				+@end 
			 | 
		
	
		
			
			| 
				
			 | 
			
				12
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				8
			 | 
			
				13
			 | 
			
			
				 @implementation RNNNavigationStackManager { 
			 | 
		
	
		
			
			| 
				9
			 | 
			
				14
			 | 
			
			
				 	RNNStore *_store; 
			 | 
		
	
		
			
			| 
				10
			 | 
			
				15
			 | 
			
			
				 	RNNTransitionCompletionBlock _completionBlock; 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -17,9 +22,9 @@ dispatch_queue_t RCTGetUIManagerQueue(void); 
			 | 
		
	
		
			
			| 
				17
			 | 
			
				22
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				18
			 | 
			
				23
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				19
			 | 
			
				24
			 | 
			
			
				 -(void)push:(UIViewController<RNNRootViewProtocol> *)newTop onTop:(NSString *)componentId completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection { 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				
			 | 
			
			
				-	UIViewController *vc = [_store findComponentForId:componentId]; 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				
			 | 
			
			
				-	[self preparePush:newTop onTopVC:vc completion:completion]; 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				
			 | 
			
			
				-	[self assertNavigationControllerExist:vc reject:rejection]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				25
			 | 
			
			
				+	RNNNavigationController *nvc = [self getComponentStack:componentId]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				26
			 | 
			
			
				+	[self assertNavigationControllerExist:nvc reject:rejection]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				27
			 | 
			
			
				+	[self preparePush:newTop onTopVC:nvc completion:completion]; 
			 | 
		
	
		
			
			| 
				23
			 | 
			
				28
			 | 
			
			
				 	if ([newTop isCustomViewController]) { 
			 | 
		
	
		
			
			| 
				24
			 | 
			
				29
			 | 
			
			
				 		[self pushAfterLoad:nil]; 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				30
			 | 
			
			
				 	} else { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -27,16 +32,16 @@ dispatch_queue_t RCTGetUIManagerQueue(void); 
			 | 
		
	
		
			
			| 
				27
			 | 
			
				32
			 | 
			
			
				 	} 
			 | 
		
	
		
			
			| 
				28
			 | 
			
				33
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				29
			 | 
			
				34
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				30
			 | 
			
				
			 | 
			
			
				--(void)preparePush:(UIViewController<RNNRootViewProtocol> *)newTop onTopVC:(UIViewController*)vc completion:(RNNTransitionCompletionBlock)completion { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				35
			 | 
			
			
				+-(void)preparePush:(UIViewController<RNNRootViewProtocol> *)newTop onTopVC:(RNNNavigationController*)nvc completion:(RNNTransitionCompletionBlock)completion { 
			 | 
		
	
		
			
			| 
				31
			 | 
			
				36
			 | 
			
			
				 	self.toVC = (RNNRootViewController*)newTop; 
			 | 
		
	
		
			
			| 
				32
			 | 
			
				
			 | 
			
			
				-	self.fromVC = vc; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				37
			 | 
			
			
				+	self.nvc = nvc; 
			 | 
		
	
		
			
			| 
				33
			 | 
			
				38
			 | 
			
			
				 	 
			 | 
		
	
		
			
			| 
				34
			 | 
			
				39
			 | 
			
			
				 	 
			 | 
		
	
		
			
			| 
				35
			 | 
			
				40
			 | 
			
			
				 	if (self.toVC.options.animations.push.hasCustomAnimation || self.toVC.isCustomTransitioned) { 
			 | 
		
	
		
			
			| 
				36
			 | 
			
				
			 | 
			
			
				-		vc.navigationController.delegate = newTop; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				41
			 | 
			
			
				+		nvc.delegate = newTop; 
			 | 
		
	
		
			
			| 
				37
			 | 
			
				42
			 | 
			
			
				 	} else { 
			 | 
		
	
		
			
			| 
				38
			 | 
			
				
			 | 
			
			
				-		vc.navigationController.delegate = nil; 
			 | 
		
	
		
			
			| 
				39
			 | 
			
				
			 | 
			
			
				-		self.fromVC.navigationController.interactivePopGestureRecognizer.delegate = nil; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				43
			 | 
			
			
				+		nvc.delegate = nil; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				44
			 | 
			
			
				+		nvc.interactivePopGestureRecognizer.delegate = nil; 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				45
			 | 
			
			
				 	} 
			 | 
		
	
		
			
			| 
				41
			 | 
			
				46
			 | 
			
			
				 	 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				47
			 | 
			
			
				 	_completionBlock = completion; 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -59,18 +64,19 @@ dispatch_queue_t RCTGetUIManagerQueue(void); 
			 | 
		
	
		
			
			| 
				59
			 | 
			
				64
			 | 
			
			
				 		} 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				65
			 | 
			
			
				 	}]; 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				66
			 | 
			
			
				 	 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				
			 | 
			
			
				-	[[self.fromVC navigationController] pushViewController:self.toVC animated:self.toVC.options.animations.push.enable]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				67
			 | 
			
			
				+	[self.nvc pushViewController:self.toVC animated:self.toVC.options.animations.push.enable]; 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				68
			 | 
			
			
				 	[CATransaction commit]; 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				69
			 | 
			
			
				 	 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				70
			 | 
			
			
				 	self.toVC = nil; 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				
			 | 
			
			
				-	self.fromVC.navigationController.interactivePopGestureRecognizer.delegate = nil; 
			 | 
		
	
		
			
			| 
				67
			 | 
			
				
			 | 
			
			
				-	self.fromVC = nil; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				71
			 | 
			
			
				+	self.nvc.interactivePopGestureRecognizer.delegate = nil; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				72
			 | 
			
			
				+	self.nvc = nil; 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				73
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				74
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				70
			 | 
			
				75
			 | 
			
			
				 -(void)pop:(NSString *)componentId withTransitionOptions:(RNNAnimationOptions *)transitionOptions rejection:(RCTPromiseRejectBlock)rejection { 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				76
			 | 
			
			
				 	RNNRootViewController* vc = (RNNRootViewController*)[_store findComponentForId:componentId]; 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				
			 | 
			
			
				-	[self assertNavigationControllerExist:vc reject:rejection]; 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				
			 | 
			
			
				-	UINavigationController* nvc = [vc navigationController]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				77
			 | 
			
			
				+	UINavigationController* nvc = [self getComponentStack:componentId]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				78
			 | 
			
			
				+	[self assertNavigationControllerExist:nvc reject:rejection]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				79
			 | 
			
			
				+	 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				80
			 | 
			
			
				 	if ([nvc topViewController] == vc) { 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				81
			 | 
			
			
				 		if (vc.options.animations.pop) { 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				82
			 | 
			
			
				 			nvc.delegate = vc; 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -89,28 +95,27 @@ dispatch_queue_t RCTGetUIManagerQueue(void); 
			 | 
		
	
		
			
			| 
				89
			 | 
			
				95
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				90
			 | 
			
				96
			 | 
			
			
				 -(void)popTo:(NSString*)componentId rejection:(RCTPromiseRejectBlock)rejection { 
			 | 
		
	
		
			
			| 
				91
			 | 
			
				97
			 | 
			
			
				 	RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId]; 
			 | 
		
	
		
			
			| 
				92
			 | 
			
				
			 | 
			
			
				-	[self assertNavigationControllerExist:vc reject:rejection]; 
			 | 
		
	
		
			
			| 
				93
			 | 
			
				
			 | 
			
			
				-	if (vc) { 
			 | 
		
	
		
			
			| 
				94
			 | 
			
				
			 | 
			
			
				-		UINavigationController *nvc = [vc navigationController]; 
			 | 
		
	
		
			
			| 
				95
			 | 
			
				
			 | 
			
			
				-		if(nvc) { 
			 | 
		
	
		
			
			| 
				96
			 | 
			
				
			 | 
			
			
				-			NSArray *poppedVCs = [nvc popToViewController:vc animated:vc.options.animations.pop.enable]; 
			 | 
		
	
		
			
			| 
				97
			 | 
			
				
			 | 
			
			
				-			[self removePopedViewControllers:poppedVCs]; 
			 | 
		
	
		
			
			| 
				98
			 | 
			
				
			 | 
			
			
				-		} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				98
			 | 
			
			
				+	RNNNavigationController *nvc = [self getComponentStack:componentId]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				99
			 | 
			
			
				+	[self assertNavigationControllerExist:nvc reject:rejection]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				100
			 | 
			
			
				+	 
			 | 
		
	
		
			
			| 
				
			 | 
			
				101
			 | 
			
			
				+	if (vc && nvc) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				102
			 | 
			
			
				+		NSArray *poppedVCs = [nvc popToViewController:vc animated:vc.options.animations.pop.enable]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				103
			 | 
			
			
				+		[self removePopedViewControllers:poppedVCs]; 
			 | 
		
	
		
			
			| 
				99
			 | 
			
				104
			 | 
			
			
				 	} 
			 | 
		
	
		
			
			| 
				100
			 | 
			
				105
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				101
			 | 
			
				106
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				102
			 | 
			
				107
			 | 
			
			
				 -(void)popToRoot:(NSString*)componentId rejection:(RCTPromiseRejectBlock)rejection { 
			 | 
		
	
		
			
			| 
				103
			 | 
			
				108
			 | 
			
			
				 	RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId]; 
			 | 
		
	
		
			
			| 
				104
			 | 
			
				
			 | 
			
			
				-	[self assertNavigationControllerExist:vc reject:rejection]; 
			 | 
		
	
		
			
			| 
				105
			 | 
			
				
			 | 
			
			
				-	UINavigationController* nvc = [vc navigationController]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				109
			 | 
			
			
				+	RNNNavigationController *nvc = [self getComponentStack:componentId]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				110
			 | 
			
			
				+	[self assertNavigationControllerExist:nvc reject:rejection]; 
			 | 
		
	
		
			
			| 
				106
			 | 
			
				111
			 | 
			
			
				 	NSArray* poppedVCs = [nvc popToRootViewControllerAnimated:vc.options.animations.pop.enable]; 
			 | 
		
	
		
			
			| 
				107
			 | 
			
				112
			 | 
			
			
				 	[self removePopedViewControllers:poppedVCs]; 
			 | 
		
	
		
			
			| 
				108
			 | 
			
				113
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				109
			 | 
			
				114
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				110
			 | 
			
				115
			 | 
			
			
				 -(void)setStackRoot:(UIViewController<RNNRootViewProtocol> *)newRoot fromComponent:(NSString *)componentId completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection { 
			 | 
		
	
		
			
			| 
				111
			 | 
			
				
			 | 
			
			
				-	UIViewController* vc = [_store findComponentForId:componentId]; 
			 | 
		
	
		
			
			| 
				112
			 | 
			
				
			 | 
			
			
				-	[self assertNavigationControllerExist:vc reject:rejection]; 
			 | 
		
	
		
			
			| 
				113
			 | 
			
				
			 | 
			
			
				-	UINavigationController* nvc = [vc navigationController]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				116
			 | 
			
			
				+	RNNNavigationController* nvc = [self getComponentStack:componentId]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				117
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				118
			 | 
			
			
				+	[self assertNavigationControllerExist:nvc reject:rejection]; 
			 | 
		
	
		
			
			| 
				114
			 | 
			
				119
			 | 
			
			
				 	 
			 | 
		
	
		
			
			| 
				115
			 | 
			
				120
			 | 
			
			
				 	[CATransaction begin]; 
			 | 
		
	
		
			
			| 
				116
			 | 
			
				121
			 | 
			
			
				 	[CATransaction setCompletionBlock:^{ 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -124,13 +129,22 @@ dispatch_queue_t RCTGetUIManagerQueue(void); 
			 | 
		
	
		
			
			| 
				124
			 | 
			
				129
			 | 
			
			
				 	[CATransaction commit]; 
			 | 
		
	
		
			
			| 
				125
			 | 
			
				130
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				126
			 | 
			
				131
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				127
			 | 
			
				
			 | 
			
			
				-- (void)assertNavigationControllerExist:(UIViewController *)viewController reject:(RCTPromiseRejectBlock)reject { 
			 | 
		
	
		
			
			| 
				128
			 | 
			
				
			 | 
			
			
				-	if (!viewController.navigationController) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				132
			 | 
			
			
				+- (void)assertNavigationControllerExist:(UINavigationController *)viewController reject:(RCTPromiseRejectBlock)reject { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				133
			 | 
			
			
				+	if (![viewController isKindOfClass:[UINavigationController class]]) { 
			 | 
		
	
		
			
			| 
				129
			 | 
			
				134
			 | 
			
			
				 		_completionBlock = nil; 
			 | 
		
	
		
			
			| 
				130
			 | 
			
				135
			 | 
			
			
				 		[RNNErrorHandler reject:reject withErrorCode:RNNCommandErrorCodeNoStack errorDescription:[NSString stringWithFormat:@"%@ should be called from a stack child component", [RNNErrorHandler getCallerFunctionName]]]; 
			 | 
		
	
		
			
			| 
				131
			 | 
			
				136
			 | 
			
			
				 	} 
			 | 
		
	
		
			
			| 
				132
			 | 
			
				137
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				133
			 | 
			
				138
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				139
			 | 
			
			
				+- (RNNNavigationController*)getComponentStack:(NSString *)componentId { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				140
			 | 
			
			
				+	UIViewController* component = [_store findComponentForId:componentId]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				141
			 | 
			
			
				+	if ([component isKindOfClass:[UINavigationController class]]) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				142
			 | 
			
			
				+		return (RNNNavigationController*)component; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				143
			 | 
			
			
				+	} else { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				144
			 | 
			
			
				+		return (RNNNavigationController*)component.navigationController; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				145
			 | 
			
			
				+	} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				146
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				147
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				134
			 | 
			
				148
			 | 
			
			
				 -(void)removePopedViewControllers:(NSArray*)viewControllers { 
			 | 
		
	
		
			
			| 
				135
			 | 
			
				149
			 | 
			
			
				 	for (UIViewController *popedVC in viewControllers) { 
			 | 
		
	
		
			
			| 
				136
			 | 
			
				150
			 | 
			
			
				 		[_store removeComponentByViewControllerInstance:popedVC]; 
			 |