| 
				
			 | 
			
			
				@@ -1,28 +1,19 @@ 
			 | 
		
	
		
			
			| 
				1
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				2
			 | 
			
				1
			 | 
			
			
				 #import "ReactNativeNavigation.h" 
			 | 
		
	
		
			
			| 
				3
			 | 
			
				2
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				3
			 | 
			
			
				+#import <UIKit/UIKit.h> 
			 | 
		
	
		
			
			| 
				4
			 | 
			
				4
			 | 
			
			
				 #import <React/RCTBridge.h> 
			 | 
		
	
		
			
			| 
				5
			 | 
			
				5
			 | 
			
			
				 #import <React/RCTUIManager.h> 
			 | 
		
	
		
			
			| 
				6
			 | 
			
				6
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				7
			 | 
			
				
			 | 
			
			
				-#import "RNNEventEmitter.h" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				7
			 | 
			
			
				+#import "RNNBridgeManager.h" 
			 | 
		
	
		
			
			| 
				8
			 | 
			
				8
			 | 
			
			
				 #import "RNNSplashScreen.h" 
			 | 
		
	
		
			
			| 
				9
			 | 
			
				
			 | 
			
			
				-#import "RNNBridgeModule.h" 
			 | 
		
	
		
			
			| 
				10
			 | 
			
				
			 | 
			
			
				-#import "RNNRootViewCreator.h" 
			 | 
		
	
		
			
			| 
				11
			 | 
			
				
			 | 
			
			
				-#import "RNNReactRootViewCreator.h" 
			 | 
		
	
		
			
			| 
				12
			 | 
			
				9
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				13
			 | 
			
				
			 | 
			
			
				-@interface ReactNativeNavigation() <RCTBridgeDelegate> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				10
			 | 
			
			
				+@interface ReactNativeNavigation() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				11
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				12
			 | 
			
			
				+@property (nonatomic, strong) RNNBridgeManager *bridgeManager; 
			 | 
		
	
		
			
			| 
				14
			 | 
			
				13
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				15
			 | 
			
				14
			 | 
			
			
				 @end 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				15
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				17
			 | 
			
				
			 | 
			
			
				-@implementation ReactNativeNavigation { 
			 | 
		
	
		
			
			| 
				18
			 | 
			
				
			 | 
			
			
				-	NSURL* _jsCodeLocation; 
			 | 
		
	
		
			
			| 
				19
			 | 
			
				
			 | 
			
			
				-	NSDictionary* _launchOptions; 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				
			 | 
			
			
				-	RCTBridge* _bridge; 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				
			 | 
			
			
				-	 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				
			 | 
			
			
				-	RNNStore* _store; 
			 | 
		
	
		
			
			| 
				23
			 | 
			
				
			 | 
			
			
				-	 
			 | 
		
	
		
			
			| 
				24
			 | 
			
				
			 | 
			
			
				-	RNNCommandsHandler* _commandsHandler; 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				16
			 | 
			
			
				+@implementation ReactNativeNavigation 
			 | 
		
	
		
			
			| 
				26
			 | 
			
				17
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				27
			 | 
			
				18
			 | 
			
			
				 # pragma mark - public API 
			 | 
		
	
		
			
			| 
				28
			 | 
			
				19
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -32,7 +23,7 @@ 
			 | 
		
	
		
			
			| 
				32
			 | 
			
				23
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				33
			 | 
			
				24
			 | 
			
			
				 # pragma mark - instance 
			 | 
		
	
		
			
			| 
				34
			 | 
			
				25
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				35
			 | 
			
				
			 | 
			
			
				-+(instancetype) sharedInstance { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				26
			 | 
			
			
				++ (instancetype) sharedInstance { 
			 | 
		
	
		
			
			| 
				36
			 | 
			
				27
			 | 
			
			
				 	static ReactNativeNavigation *instance = nil; 
			 | 
		
	
		
			
			| 
				37
			 | 
			
				28
			 | 
			
			
				 	static dispatch_once_t onceToken = 0; 
			 | 
		
	
		
			
			| 
				38
			 | 
			
				29
			 | 
			
			
				 	dispatch_once(&onceToken,^{ 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -45,71 +36,8 @@ 
			 | 
		
	
		
			
			| 
				45
			 | 
			
				36
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				37
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				47
			 | 
			
				38
			 | 
			
			
				 -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions { 
			 | 
		
	
		
			
			| 
				48
			 | 
			
				
			 | 
			
			
				-	_jsCodeLocation = jsCodeLocation; 
			 | 
		
	
		
			
			| 
				49
			 | 
			
				
			 | 
			
			
				-	_launchOptions = launchOptions; 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				
			 | 
			
			
				-	_store = [RNNStore new]; 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				
			 | 
			
			
				-	 
			 | 
		
	
		
			
			| 
				
			 | 
			
				39
			 | 
			
			
				+	self.bridgeManager = [[RNNBridgeManager alloc] initWithJsCodeLocation:jsCodeLocation launchOptions:launchOptions]; 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				40
			 | 
			
			
				 	[RNNSplashScreen show]; 
			 | 
		
	
		
			
			| 
				53
			 | 
			
				
			 | 
			
			
				-	 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				
			 | 
			
			
				-	[self registerForJsEvents]; 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				
			 | 
			
			
				-	 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				
			 | 
			
			
				-	[self createBridgeLoadJsAndThenInitDependencyGraph]; 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				59
			 | 
			
				
			 | 
			
			
				-# pragma mark - RCTBridgeDelegate 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				
			 | 
			
			
				--(NSURL *)sourceURLForBridge:(RCTBridge *)bridge { 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				
			 | 
			
			
				-	return _jsCodeLocation; 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				
			 | 
			
			
				-/** 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				
			 | 
			
			
				- * here we initialize all of our dependency graph 
			 | 
		
	
		
			
			| 
				67
			 | 
			
				
			 | 
			
			
				- */ 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				
			 | 
			
			
				--(NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge { 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				
			 | 
			
			
				-	RNNEventEmitter *eventEmitter = [[RNNEventEmitter alloc] init]; 
			 | 
		
	
		
			
			| 
				70
			 | 
			
				
			 | 
			
			
				-	 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				
			 | 
			
			
				-	id<RNNRootViewCreator> rootViewCreator = [[RNNReactRootViewCreator alloc] initWithBridge:bridge]; 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				
			 | 
			
			
				-	RNNControllerFactory *controllerFactory = [[RNNControllerFactory alloc] initWithRootViewCreator:rootViewCreator store:_store eventEmitter:eventEmitter andBridge:bridge]; 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				
			 | 
			
			
				-	_commandsHandler = [[RNNCommandsHandler alloc] initWithStore:_store controllerFactory:controllerFactory]; 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				
			 | 
			
			
				-	RNNBridgeModule *bridgeModule = [[RNNBridgeModule alloc] initWithCommandsHandler:_commandsHandler]; 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				
			 | 
			
			
				-	 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				
			 | 
			
			
				-	return @[bridgeModule,eventEmitter]; 
			 | 
		
	
		
			
			| 
				77
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				78
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				79
			 | 
			
				
			 | 
			
			
				-# pragma mark - js events 
			 | 
		
	
		
			
			| 
				80
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				81
			 | 
			
				
			 | 
			
			
				--(void)onJavaScriptWillLoad { 
			 | 
		
	
		
			
			| 
				82
			 | 
			
				
			 | 
			
			
				-	[_store clean]; 
			 | 
		
	
		
			
			| 
				83
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				84
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				85
			 | 
			
				
			 | 
			
			
				--(void)onJavaScriptLoaded { 
			 | 
		
	
		
			
			| 
				86
			 | 
			
				
			 | 
			
			
				-	[_store setReadyToReceiveCommands:true]; 
			 | 
		
	
		
			
			| 
				87
			 | 
			
				
			 | 
			
			
				-	[[_bridge moduleForClass:[RNNEventEmitter class]] sendOnAppLaunched]; 
			 | 
		
	
		
			
			| 
				88
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				89
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				90
			 | 
			
				
			 | 
			
			
				--(void)onBridgeWillReload { 
			 | 
		
	
		
			
			| 
				91
			 | 
			
				
			 | 
			
			
				-	UIApplication.sharedApplication.delegate.window.rootViewController =  nil; 
			 | 
		
	
		
			
			| 
				92
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				93
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				94
			 | 
			
				
			 | 
			
			
				-# pragma mark - private 
			 | 
		
	
		
			
			| 
				95
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				96
			 | 
			
				
			 | 
			
			
				--(void)createBridgeLoadJsAndThenInitDependencyGraph { 
			 | 
		
	
		
			
			| 
				97
			 | 
			
				
			 | 
			
			
				-	_bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:_launchOptions]; 
			 | 
		
	
		
			
			| 
				98
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				99
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				100
			 | 
			
				
			 | 
			
			
				--(void)registerForJsEvents { 
			 | 
		
	
		
			
			| 
				101
			 | 
			
				
			 | 
			
			
				-	[[NSNotificationCenter defaultCenter] addObserver:self 
			 | 
		
	
		
			
			| 
				102
			 | 
			
				
			 | 
			
			
				-											 selector:@selector(onJavaScriptLoaded) 
			 | 
		
	
		
			
			| 
				103
			 | 
			
				
			 | 
			
			
				-												 name:RCTJavaScriptDidLoadNotification 
			 | 
		
	
		
			
			| 
				104
			 | 
			
				
			 | 
			
			
				-											   object:nil]; 
			 | 
		
	
		
			
			| 
				105
			 | 
			
				
			 | 
			
			
				-	[[NSNotificationCenter defaultCenter] addObserver:self 
			 | 
		
	
		
			
			| 
				106
			 | 
			
				
			 | 
			
			
				-											 selector:@selector(onJavaScriptWillLoad) 
			 | 
		
	
		
			
			| 
				107
			 | 
			
				
			 | 
			
			
				-												 name:RCTJavaScriptWillStartLoadingNotification 
			 | 
		
	
		
			
			| 
				108
			 | 
			
				
			 | 
			
			
				-											   object:nil]; 
			 | 
		
	
		
			
			| 
				109
			 | 
			
				
			 | 
			
			
				-	[[NSNotificationCenter defaultCenter] addObserver:self 
			 | 
		
	
		
			
			| 
				110
			 | 
			
				
			 | 
			
			
				-											 selector:@selector(onBridgeWillReload) 
			 | 
		
	
		
			
			| 
				111
			 | 
			
				
			 | 
			
			
				-												 name:RCTBridgeWillReloadNotification 
			 | 
		
	
		
			
			| 
				112
			 | 
			
				
			 | 
			
			
				-											   object:nil]; 
			 | 
		
	
		
			
			| 
				113
			 | 
			
				41
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				114
			 | 
			
				42
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				115
			 | 
			
				43
			 | 
			
			
				 @end 
			 |