Browse Source

Stop manually manage viewControllers store, Iterate layout instead (#4991)

* Stop manually manage viewControllers store, Iterate layout instead

* Update RNNCommandsHandlerTest.m
Yogev Ben David 5 years ago
parent
commit
275304c88e
No account linked to committer's email address

+ 0
- 2
lib/ios/RNNBridgeManager.h View File

@@ -1,7 +1,6 @@
1 1
 #import <Foundation/Foundation.h>
2 2
 #import <React/RCTBridge.h>
3 3
 #import "RNNBridgeManagerDelegate.h"
4
-#import "RNNStore.h"
5 4
 
6 5
 typedef UIViewController * (^RNNExternalViewCreator)(NSDictionary* props, RCTBridge* bridge);
7 6
 
@@ -12,6 +11,5 @@ typedef UIViewController * (^RNNExternalViewCreator)(NSDictionary* props, RCTBri
12 11
 - (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
13 12
 
14 13
 @property (readonly, nonatomic, strong) RCTBridge *bridge;
15
-@property (readonly, nonatomic, strong) RNNStore *store;
16 14
 
17 15
 @end

+ 5
- 6
lib/ios/RNNBridgeManager.m View File

@@ -13,7 +13,7 @@
13 13
 @interface RNNBridgeManager() <RCTBridgeDelegate>
14 14
 
15 15
 @property (nonatomic, strong, readwrite) RCTBridge *bridge;
16
-@property (nonatomic, strong, readwrite) RNNStore *store;
16
+@property (nonatomic, strong, readwrite) RNNExternalComponentStore *store;
17 17
 @property (nonatomic, strong, readwrite) RNNReactComponentRegistry *componentRegistry;
18 18
 
19 19
 @end
@@ -25,7 +25,7 @@
25 25
 	RCTBridge* _bridge;
26 26
 	UIWindow* _mainWindow;
27 27
 	
28
-	RNNStore* _store;
28
+	RNNExternalComponentStore* _store;
29 29
 
30 30
 	RNNCommandsHandler* _commandsHandler;
31 31
 }
@@ -37,7 +37,7 @@
37 37
 		_launchOptions = launchOptions;
38 38
 		_delegate = delegate;
39 39
 		
40
-		_store = [RNNStore new];
40
+		_store = [RNNExternalComponentStore new];
41 41
 		_bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:_launchOptions];
42 42
 		
43 43
 		
@@ -82,7 +82,7 @@
82 82
 	_componentRegistry = [[RNNReactComponentRegistry alloc] initWithCreator:rootViewCreator];
83 83
 	RNNControllerFactory *controllerFactory = [[RNNControllerFactory alloc] initWithRootViewCreator:rootViewCreator eventEmitter:eventEmitter store:_store componentRegistry:_componentRegistry andBridge:bridge];
84 84
 	
85
-	_commandsHandler = [[RNNCommandsHandler alloc] initWithStore:_store controllerFactory:controllerFactory eventEmitter:eventEmitter stackManager:[RNNNavigationStackManager new] modalManager:[RNNModalManager new] overlayManager:[RNNOverlayManager new] mainWindow:_mainWindow];
85
+	_commandsHandler = [[RNNCommandsHandler alloc] initWithControllerFactory:controllerFactory eventEmitter:eventEmitter stackManager:[RNNNavigationStackManager new] modalManager:[RNNModalManager new] overlayManager:[RNNOverlayManager new] mainWindow:_mainWindow];
86 86
 	RNNBridgeModule *bridgeModule = [[RNNBridgeModule alloc] initWithCommandsHandler:_commandsHandler];
87 87
 
88 88
 	return [@[bridgeModule,eventEmitter] arrayByAddingObjectsFromArray:[self extraModulesFromDelegate]];
@@ -91,12 +91,11 @@
91 91
 # pragma mark - JavaScript & Bridge Notifications
92 92
 
93 93
 - (void)onJavaScriptWillLoad {
94
-	[_store clean];
95 94
 	[_componentRegistry clear];
96 95
 }
97 96
 
98 97
 - (void)onJavaScriptLoaded {
99
-	[_store setReadyToReceiveCommands:true];
98
+	[_commandsHandler setReadyToReceiveCommands:true];
100 99
 	[[_bridge moduleForClass:[RNNEventEmitter class]] sendOnAppLaunched];
101 100
 }
102 101
 

+ 3
- 2
lib/ios/RNNCommandsHandler.h View File

@@ -2,14 +2,15 @@
2 2
 #import <UIKit/UIKit.h>
3 3
 
4 4
 #import "RNNControllerFactory.h"
5
-#import "RNNStore.h"
6 5
 #import "RNNModalManager.h"
7 6
 #import "RNNNavigationStackManager.h"
8 7
 #import "RNNOverlayManager.h"
9 8
 
10 9
 @interface RNNCommandsHandler : NSObject
11 10
 
12
-- (instancetype)initWithStore:(RNNStore*)store controllerFactory:(RNNControllerFactory*)controllerFactory eventEmitter:(RNNEventEmitter *)eventEmitter stackManager:(RNNNavigationStackManager *)stackManager modalManager:(RNNModalManager *)modalManager overlayManager:(RNNOverlayManager *)overlayManager mainWindow:(UIWindow *)mainWindow;
11
+- (instancetype)initWithControllerFactory:(RNNControllerFactory*)controllerFactory eventEmitter:(RNNEventEmitter *)eventEmitter stackManager:(RNNNavigationStackManager *)stackManager modalManager:(RNNModalManager *)modalManager overlayManager:(RNNOverlayManager *)overlayManager mainWindow:(UIWindow *)mainWindow;
12
+
13
+@property (nonatomic) BOOL readyToReceiveCommands;
13 14
 
14 15
 - (void)setRoot:(NSDictionary*)layout commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion;
15 16
 

+ 12
- 13
lib/ios/RNNCommandsHandler.m View File

@@ -9,6 +9,7 @@
9 9
 #import "UIViewController+RNNOptions.h"
10 10
 #import "React/RCTI18nUtil.h"
11 11
 #import "UIViewController+LayoutProtocol.h"
12
+#import "RNNLayoutManager.h"
12 13
 
13 14
 static NSString* const setRoot	= @"setRoot";
14 15
 static NSString* const setStackRoot	= @"setStackRoot";
@@ -31,7 +32,6 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
31 32
 
32 33
 @implementation RNNCommandsHandler {
33 34
 	RNNControllerFactory *_controllerFactory;
34
-	RNNStore *_store;
35 35
 	RNNModalManager* _modalManager;
36 36
 	RNNOverlayManager* _overlayManager;
37 37
 	RNNNavigationStackManager* _stackManager;
@@ -39,9 +39,8 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
39 39
 	UIWindow* _mainWindow;
40 40
 }
41 41
 
42
-- (instancetype)initWithStore:(RNNStore*)store controllerFactory:(RNNControllerFactory*)controllerFactory eventEmitter:(RNNEventEmitter *)eventEmitter stackManager:(RNNNavigationStackManager *)stackManager modalManager:(RNNModalManager *)modalManager overlayManager:(RNNOverlayManager *)overlayManager mainWindow:(UIWindow *)mainWindow {
42
+- (instancetype)initWithControllerFactory:(RNNControllerFactory*)controllerFactory eventEmitter:(RNNEventEmitter *)eventEmitter stackManager:(RNNNavigationStackManager *)stackManager modalManager:(RNNModalManager *)modalManager overlayManager:(RNNOverlayManager *)overlayManager mainWindow:(UIWindow *)mainWindow {
43 43
 	self = [super init];
44
-	_store = store;
45 44
 	_controllerFactory = controllerFactory;
46 45
 	_eventEmitter = eventEmitter;
47 46
 	_modalManager = modalManager;
@@ -87,7 +86,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
87 86
 - (void)mergeOptions:(NSString*)componentId options:(NSDictionary*)mergeOptions completion:(RNNTransitionCompletionBlock)completion {
88 87
 	[self assertReady];
89 88
 	
90
-	UIViewController<RNNLayoutProtocol>* vc = (UIViewController<RNNLayoutProtocol>*)[_store findComponentForId:componentId];
89
+	UIViewController<RNNLayoutProtocol>* vc = (UIViewController<RNNLayoutProtocol>*)[RNNLayoutManager findComponentForId:componentId];
91 90
 	RNNNavigationOptions* newOptions = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
92 91
 	if ([vc conformsToProtocol:@protocol(RNNLayoutProtocol)] || [vc isKindOfClass:[RNNRootViewController class]]) {
93 92
 		[CATransaction begin];
@@ -115,10 +114,10 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
115 114
 	[self assertReady];
116 115
 	
117 116
 	UIViewController *newVc = [_controllerFactory createLayout:layout];
118
-	UIViewController *fromVC = [_store findComponentForId:componentId];
117
+	UIViewController *fromVC = [RNNLayoutManager findComponentForId:componentId];
119 118
 	
120 119
 	if ([[newVc.resolveOptions.preview.reactTag getWithDefaultValue:@(0)] floatValue] > 0) {
121
-		UIViewController* vc = [_store findComponentForId:componentId];
120
+		UIViewController* vc = [RNNLayoutManager findComponentForId:componentId];
122 121
 		
123 122
 		if([vc isKindOfClass:[RNNRootViewController class]]) {
124 123
 			RNNRootViewController* rootVc = (RNNRootViewController*)vc;
@@ -177,7 +176,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
177 176
 		[viewController renderTreeAndWait:NO perform:nil];
178 177
 	}
179 178
 	RNNNavigationOptions* options = [childViewControllers.lastObject getCurrentChild].resolveOptions;
180
-	UIViewController *fromVC = [_store findComponentForId:componentId];
179
+	UIViewController *fromVC = [RNNLayoutManager findComponentForId:componentId];
181 180
 	__weak typeof(RNNEventEmitter*) weakEventEmitter = _eventEmitter;
182 181
 	[_stackManager setStackChildren:childViewControllers fromViewController:fromVC animated:[options.animations.setStackRoot.enable getWithDefaultValue:YES] completion:^{
183 182
 		[weakEventEmitter sendOnNavigationCommandCompletion:setStackRoot commandId:commandId params:@{@"componentId": componentId}];
@@ -188,7 +187,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
188 187
 - (void)pop:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary*)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
189 188
 	[self assertReady];
190 189
 	
191
-	RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId];
190
+	RNNRootViewController *vc = (RNNRootViewController*)[RNNLayoutManager findComponentForId:componentId];
192 191
 	RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
193 192
 	[vc overrideOptions:options];
194 193
 	
@@ -214,7 +213,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
214 213
 
215 214
 - (void)popTo:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
216 215
 	[self assertReady];
217
-	RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId];
216
+	RNNRootViewController *vc = (RNNRootViewController*)[RNNLayoutManager findComponentForId:componentId];
218 217
 	RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
219 218
 	[vc overrideOptions:options];
220 219
 	
@@ -226,7 +225,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
226 225
 
227 226
 - (void)popToRoot:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
228 227
 	[self assertReady];
229
-	RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId];
228
+	RNNRootViewController *vc = (RNNRootViewController*)[RNNLayoutManager findComponentForId:componentId];
230 229
 	RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
231 230
 	[vc overrideOptions:options];
232 231
 	
@@ -261,7 +260,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
261 260
 - (void)dismissModal:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject {
262 261
 	[self assertReady];
263 262
 	
264
-	UIViewController *modalToDismiss = (UIViewController *)[_store findComponentForId:componentId];
263
+	UIViewController *modalToDismiss = (UIViewController *)[RNNLayoutManager findComponentForId:componentId];
265 264
 	
266 265
 	if (!modalToDismiss.isModal) {
267 266
 		[RNNErrorHandler reject:reject withErrorCode:1013 errorDescription:@"component is not a modal"];
@@ -310,7 +309,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
310 309
 
311 310
 - (void)dismissOverlay:(NSString*)componentId commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject {
312 311
 	[self assertReady];
313
-	UIViewController* viewController = [_store findComponentForId:componentId];
312
+	UIViewController* viewController = [RNNLayoutManager findComponentForId:componentId];
314 313
 	if (viewController) {
315 314
 		[_overlayManager dismissOverlay:viewController];
316 315
 		[_eventEmitter sendOnNavigationCommandCompletion:dismissOverlay commandId:commandId params:@{@"componentId": componentId}];
@@ -323,7 +322,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
323 322
 #pragma mark - private
324 323
 
325 324
 - (void)assertReady {
326
-	if (!_store.isReadyToReceiveCommands) {
325
+	if (!self.readyToReceiveCommands) {
327 326
 		[[NSException exceptionWithName:@"BridgeNotLoadedError"
328 327
 								 reason:@"Bridge not yet loaded! Send commands after Navigation.events().onAppLaunched() has been called."
329 328
 							   userInfo:nil]

+ 2
- 2
lib/ios/RNNControllerFactory.h View File

@@ -2,7 +2,7 @@
2 2
 #import <Foundation/Foundation.h>
3 3
 #import <UIKit/UIKit.h>
4 4
 #import "RNNRootViewCreator.h"
5
-#import "RNNStore.h"
5
+#import "RNNExternalComponentStore.h"
6 6
 #import "RNNEventEmitter.h"
7 7
 #import "RNNReactComponentRegistry.h"
8 8
 #import "RNNNavigationOptions.h"
@@ -11,7 +11,7 @@
11 11
 
12 12
 -(instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator
13 13
 						  eventEmitter:(RNNEventEmitter*)eventEmitter
14
-								 store:(RNNStore *)store
14
+								 store:(RNNExternalComponentStore *)store
15 15
 					  componentRegistry:(RNNReactComponentRegistry *)componentRegistry
16 16
 							 andBridge:(RCTBridge*)bridge;
17 17
 

+ 2
- 4
lib/ios/RNNControllerFactory.m View File

@@ -18,7 +18,7 @@
18 18
 
19 19
 @implementation RNNControllerFactory {
20 20
 	id<RNNRootViewCreator> _creator;
21
-	RNNStore *_store;
21
+	RNNExternalComponentStore *_store;
22 22
 	RCTBridge *_bridge;
23 23
 	RNNReactComponentRegistry* _componentRegistry;
24 24
 }
@@ -28,7 +28,7 @@
28 28
 
29 29
 - (instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator
30 30
 						   eventEmitter:(RNNEventEmitter*)eventEmitter
31
-								  store:(RNNStore *)store
31
+								  store:(RNNExternalComponentStore *)store
32 32
 					   componentRegistry:(RNNReactComponentRegistry *)componentRegistry
33 33
 							  andBridge:(RCTBridge *)bridge {
34 34
 	
@@ -107,8 +107,6 @@
107 107
 		@throw [NSException exceptionWithName:@"UnknownControllerType" reason:[@"Unknown controller type " stringByAppendingString:node.type] userInfo:nil];
108 108
 	}
109 109
 	
110
-	result.store = _store;
111
-	
112 110
 	return result;
113 111
 }
114 112
 

+ 12
- 0
lib/ios/RNNExternalComponentStore.h View File

@@ -0,0 +1,12 @@
1
+
2
+#import <Foundation/Foundation.h>
3
+#import <UIKit/UIKit.h>
4
+#import "ReactNativeNavigation.h"
5
+#import "RNNLayoutInfo.h"
6
+
7
+@interface RNNExternalComponentStore : NSObject
8
+
9
+- (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
10
+- (UIViewController *)getExternalComponent:(RNNLayoutInfo *)layoutInfo bridge:(RCTBridge *)bridge;
11
+
12
+@end

+ 26
- 0
lib/ios/RNNExternalComponentStore.m View File

@@ -0,0 +1,26 @@
1
+#import "RNNExternalComponentStore.h"
2
+
3
+@interface RNNExternalComponentStore ()
4
+
5
+@end
6
+
7
+@implementation RNNExternalComponentStore {
8
+	NSMutableDictionary* _externalComponentCreators;
9
+}
10
+
11
+-(instancetype)init {
12
+	self = [super init];
13
+	_externalComponentCreators = [NSMutableDictionary new];
14
+	return self;
15
+}
16
+
17
+- (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback {
18
+	[_externalComponentCreators setObject:[callback copy] forKey:name];
19
+}
20
+
21
+- (UIViewController *)getExternalComponent:(RNNLayoutInfo *)layoutInfo bridge:(RCTBridge *)bridge {
22
+	RNNExternalViewCreator creator = [_externalComponentCreators objectForKey:layoutInfo.name];
23
+	return creator(layoutInfo.props, bridge);
24
+}
25
+
26
+@end

+ 9
- 0
lib/ios/RNNLayoutManager.h View File

@@ -0,0 +1,9 @@
1
+
2
+#import <Foundation/Foundation.h>
3
+#import <UIKit/UIKit.h>
4
+
5
+@interface RNNLayoutManager : NSObject
6
+
7
++ (UIViewController *)findComponentForId:(NSString *)componentId;
8
+
9
+@end

+ 47
- 0
lib/ios/RNNLayoutManager.m View File

@@ -0,0 +1,47 @@
1
+
2
+#import "RNNLayoutManager.h"
3
+#import "RNNLayoutProtocol.h"
4
+#import "UIViewController+LayoutProtocol.h"
5
+
6
+@implementation RNNLayoutManager
7
+
8
++ (UIViewController *)findComponentForId:(NSString *)componentId {
9
+	for (UIWindow* window in UIApplication.sharedApplication.windows) {
10
+		UIViewController* result = [self findChildComponentForParent:window.rootViewController ForId:componentId];
11
+		if (result) {
12
+			return result;
13
+		}
14
+	}
15
+	
16
+	return nil;
17
+}
18
+
19
++ (UIViewController *)findChildComponentForParent:(UIViewController *)parentViewController ForId:(NSString *)componentId {
20
+	if ([parentViewController.layoutInfo.componentId isEqualToString:componentId]) {
21
+		return parentViewController;
22
+	}
23
+	
24
+	if (parentViewController.presentedViewController) {
25
+		if ([parentViewController.presentedViewController.layoutInfo.componentId isEqualToString:componentId]) {
26
+			return parentViewController.presentedViewController;
27
+		}
28
+		
29
+		UIViewController* modalResult = [self findChildComponentForParent:parentViewController.presentedViewController ForId:componentId];
30
+		if (modalResult) {
31
+			return modalResult;
32
+		}
33
+		
34
+	}
35
+	
36
+	for (UIViewController* childVC in parentViewController.childViewControllers) {
37
+		UIViewController* result = [self findChildComponentForParent:childVC ForId:componentId];
38
+		if (result) {
39
+			return result;
40
+		}
41
+	}
42
+	
43
+	return nil;
44
+}
45
+
46
+
47
+@end

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

@@ -1,6 +1,9 @@
1 1
 #import <Foundation/Foundation.h>
2 2
 #import <UIKit/UIKit.h>
3
-#import "RNNStore.h"
3
+
4
+typedef void (^RNNTransitionCompletionBlock)(void);
5
+typedef void (^RNNTransitionWithComponentIdCompletionBlock)(NSString *componentId);
6
+typedef void (^RNNTransitionRejectionBlock)(NSString *code, NSString *message, NSError *error);
4 7
 
5 8
 @protocol RNNModalManagerDelegate <NSObject>
6 9
 

+ 0
- 1
lib/ios/RNNOverlayManager.h View File

@@ -1,6 +1,5 @@
1 1
 #import <Foundation/Foundation.h>
2 2
 #import <UIKit/UIKit.h>
3
-#import "RNNStore.h"
4 3
 #import "RNNOverlayWindow.h"
5 4
 
6 5
 @interface RNNOverlayManager : NSObject

+ 0
- 1
lib/ios/RNNReactComponentRegistry.h View File

@@ -1,7 +1,6 @@
1 1
 #import <Foundation/Foundation.h>
2 2
 #import "RNNReactView.h"
3 3
 #import "RNNComponentOptions.h"
4
-#import "RNNStore.h"
5 4
 #import "RNNRootViewCreator.h"
6 5
 
7 6
 @interface RNNReactComponentRegistry : NSObject

+ 1
- 27
lib/ios/RNNRootViewController.m View File

@@ -15,10 +15,6 @@
15 15
 	
16 16
 	self.animator = [[RNNAnimator alloc] initWithTransitionOptions:self.resolveOptions.customTransition];
17 17
 	
18
-	[[NSNotificationCenter defaultCenter] addObserver:self
19
-											 selector:@selector(onJsReload)
20
-												 name:RCTJavaScriptWillStartLoadingNotification
21
-											   object:nil];
22 18
 	self.navigationController.delegate = self;
23 19
 	
24 20
 	return self;
@@ -84,7 +80,7 @@
84 80
 			}
85 81
 		}];
86 82
 	}];
87
-
83
+	
88 84
 	self.view = reactView;
89 85
 	
90 86
 	if (!wait && readyBlock) {
@@ -213,27 +209,5 @@
213 209
 	[self.eventEmitter sendOnNavigationButtonPressed:self.layoutInfo.componentId buttonId:barButtonItem.buttonId];
214 210
 }
215 211
 
216
-/**
217
- *	fix for #877, #878
218
- */
219
--(void)onJsReload {
220
-	[self cleanReactLeftovers];
221
-}
222
-
223
-/**
224
- * fix for #880
225
- */
226
--(void)dealloc {
227
-	[self cleanReactLeftovers];
228
-}
229
-
230
--(void)cleanReactLeftovers {
231
-	[[NSNotificationCenter defaultCenter] removeObserver:self];
232
-	[[NSNotificationCenter defaultCenter] removeObserver:self.view];
233
-	self.view = nil;
234
-	self.navigationItem.titleView = nil;
235
-	self.navigationItem.rightBarButtonItems = nil;
236
-	self.navigationItem.leftBarButtonItems = nil;
237
-}
238 212
 
239 213
 @end

+ 0
- 28
lib/ios/RNNStore.h View File

@@ -1,28 +0,0 @@
1
-
2
-#import <Foundation/Foundation.h>
3
-#import <UIKit/UIKit.h>
4
-#import "ReactNativeNavigation.h"
5
-#import "RNNLayoutInfo.h"
6
-
7
-typedef void (^RNNTransitionCompletionBlock)(void);
8
-typedef void (^RNNTransitionWithComponentIdCompletionBlock)(NSString *componentId);
9
-typedef void (^RNNTransitionRejectionBlock)(NSString *code, NSString *message, NSError *error);
10
-
11
-@interface RNNStore : NSObject
12
-
13
-- (UIViewController*)findComponentForId:(NSString*)componentId;
14
-- (void)setComponent:(UIViewController*)viewController componentId:(NSString*)componentId;
15
-- (void)removeComponent:(NSString*)componentId;
16
-- (void)removeAllComponents;
17
-- (void)removeAllComponentsFromWindow:(UIWindow *)window;
18
-- (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
19
-- (UIViewController *)getExternalComponent:(RNNLayoutInfo *)layoutInfo bridge:(RCTBridge *)bridge;
20
-
21
-- (NSString*)componentKeyForInstance:(UIViewController*)instance;
22
-
23
-- (void)setReadyToReceiveCommands:(BOOL)isReady;
24
-- (BOOL)isReadyToReceiveCommands;
25
-
26
-- (void)clean;
27
-
28
-@end

+ 0
- 92
lib/ios/RNNStore.m View File

@@ -1,92 +0,0 @@
1
-#import "RNNStore.h"
2
-
3
-@interface RNNStore ()
4
-
5
-@end
6
-
7
-@implementation RNNStore {
8
-	NSMapTable* _componentStore;
9
-	NSMutableDictionary* _externalComponentCreators;
10
-	BOOL _isReadyToReceiveCommands;
11
-}
12
-
13
--(instancetype)init {
14
-	self = [super init];
15
-	_isReadyToReceiveCommands = false;
16
-	_componentStore = [NSMapTable strongToWeakObjectsMapTable];
17
-	_externalComponentCreators = [NSMutableDictionary new];
18
-	return self;
19
-}
20
-
21
--(UIViewController *)findComponentForId:(NSString *)componentId {
22
-	return [_componentStore objectForKey:componentId];
23
-}
24
-
25
-- (void)setComponent:(UIViewController*)viewController componentId:(NSString*)componentId {
26
-	UIViewController *existingVewController = [self findComponentForId:componentId];
27
-	if (existingVewController) {
28
-		@throw [NSException exceptionWithName:@"MultipleComponentId" reason:[@"Component id already exists " stringByAppendingString:componentId] userInfo:nil];
29
-	}
30
-	
31
-	[_componentStore setObject:viewController forKey:componentId];
32
-}
33
-
34
-- (void)removeComponent:(NSString*)componentId {
35
-	[_componentStore removeObjectForKey:componentId];
36
-}
37
-
38
-- (void)removeAllComponents {
39
-	[_componentStore removeAllObjects];
40
-}
41
-
42
-- (void)removeAllComponentsFromWindow:(UIWindow *)window {
43
-	for (NSString *key in [self componentsForWindow:window]) {
44
-		[_componentStore removeObjectForKey:key];
45
-	}
46
-}
47
-
48
-- (NSArray *)componentsForWindow:(UIWindow *)window {
49
-	NSMutableArray* keyWindowComponents = [NSMutableArray new];
50
-	for (NSString* key in _componentStore) {
51
-		UIViewController *component = [_componentStore objectForKey:key];
52
-		if (component.view.window == window) {
53
-			[keyWindowComponents addObject:key];
54
-		}
55
-	}
56
-	
57
-	return keyWindowComponents;
58
-}
59
-
60
--(void)setReadyToReceiveCommands:(BOOL)isReady {
61
-	_isReadyToReceiveCommands = isReady;
62
-}
63
-
64
--(BOOL)isReadyToReceiveCommands {
65
-	return _isReadyToReceiveCommands;
66
-}
67
-
68
--(void)clean {
69
-	_isReadyToReceiveCommands = false;
70
-	[self removeAllComponents];
71
-}
72
-
73
--(NSString*)componentKeyForInstance:(UIViewController*)instance {
74
-	for (NSString *key in _componentStore) {
75
-		UIViewController *value = [_componentStore objectForKey:key];
76
-		if (value == instance) {
77
-			return key;
78
-		}
79
-	}
80
-	return nil;
81
-}
82
-
83
-- (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback {
84
-	[_externalComponentCreators setObject:[callback copy] forKey:name];
85
-}
86
-
87
-- (UIViewController *)getExternalComponent:(RNNLayoutInfo *)layoutInfo bridge:(RCTBridge *)bridge {
88
-	RNNExternalViewCreator creator = [_externalComponentCreators objectForKey:layoutInfo.name];
89
-	return creator(layoutInfo.props, bridge);
90
-}
91
-
92
-@end

+ 0
- 13
lib/ios/RNNViewControllerPresenter.m View File

@@ -17,16 +17,6 @@
17 17
 
18 18
 @implementation RNNViewControllerPresenter
19 19
 
20
-- (instancetype)init {
21
-	self = [super init];
22
-	[[NSNotificationCenter defaultCenter] addObserver:self
23
-											 selector:@selector(cleanReactLeftovers)
24
-												 name:RCTJavaScriptWillStartLoadingNotification
25
-											   object:nil];
26
-	
27
-	return self;
28
-}
29
-
30 20
 - (instancetype)initWithComponentRegistry:(RNNReactComponentRegistry *)componentRegistry {
31 21
 	self = [self init];
32 22
 	_componentRegistry = componentRegistry;
@@ -220,8 +210,5 @@
220 210
 	[_componentRegistry clearComponentsForParentId:self.bindedComponentId];
221 211
 }
222 212
 
223
-- (void)cleanReactLeftovers {
224
-	_customTitleView = nil;
225
-}
226 213
 
227 214
 @end

+ 2
- 2
lib/ios/ReactNativeNavigation.m View File

@@ -4,6 +4,7 @@
4 4
 
5 5
 #import "RNNBridgeManager.h"
6 6
 #import "RNNSplashScreen.h"
7
+#import "RNNLayoutManager.h"
7 8
 
8 9
 @interface ReactNativeNavigation()
9 10
 
@@ -32,8 +33,7 @@
32 33
 }
33 34
 
34 35
 + (UIViewController *)findViewController:(NSString *)componentId {
35
-    RNNStore *store = [[ReactNativeNavigation sharedInstance].bridgeManager store];
36
-    return [store findComponentForId:componentId];
36
+    return [RNNLayoutManager findComponentForId:componentId];
37 37
 }
38 38
 
39 39
 # pragma mark - instance

+ 24
- 12
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj View File

@@ -53,8 +53,6 @@
53 53
 		263905D71E4C94970023D7D3 /* RNNSideMenuController.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905D51E4C94970023D7D3 /* RNNSideMenuController.m */; };
54 54
 		263905E61E4CAC950023D7D3 /* RNNSideMenuChildVC.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905E41E4CAC950023D7D3 /* RNNSideMenuChildVC.h */; };
55 55
 		263905E71E4CAC950023D7D3 /* RNNSideMenuChildVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905E51E4CAC950023D7D3 /* RNNSideMenuChildVC.m */; };
56
-		268692821E5054F800E2C612 /* RNNStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 268692801E5054F800E2C612 /* RNNStore.h */; };
57
-		268692831E5054F800E2C612 /* RNNStore.m in Sources */ = {isa = PBXBuildFile; fileRef = 268692811E5054F800E2C612 /* RNNStore.m */; };
58 56
 		26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */ = {isa = PBXBuildFile; fileRef = 26916C961E4B9E7700D13680 /* RNNReactRootViewCreator.h */; };
59 57
 		26916C991E4B9E7700D13680 /* RNNReactRootViewCreator.m in Sources */ = {isa = PBXBuildFile; fileRef = 26916C971E4B9E7700D13680 /* RNNReactRootViewCreator.m */; };
60 58
 		2DCD9195200014A900EDC75D /* RNNBridgeManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DCD9193200014A900EDC75D /* RNNBridgeManager.h */; };
@@ -141,6 +139,10 @@
141 139
 		50451D0D2042F70900695F00 /* RNNTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 50451D0B2042F70900695F00 /* RNNTransition.h */; };
142 140
 		50451D0E2042F70900695F00 /* RNNTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = 50451D0C2042F70900695F00 /* RNNTransition.m */; };
143 141
 		504753782109C13C00FFFBE6 /* RNNOverlayManagerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 504753772109C13C00FFFBE6 /* RNNOverlayManagerTest.m */; };
142
+		5047E4F022674AD400908DD3 /* RNNLayoutManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 5047E4EE22674AD400908DD3 /* RNNLayoutManager.h */; };
143
+		5047E4F122674AD400908DD3 /* RNNLayoutManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5047E4EF22674AD400908DD3 /* RNNLayoutManager.m */; };
144
+		5047E4F42267568800908DD3 /* RNNExternalComponentStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 5047E4F22267568500908DD3 /* RNNExternalComponentStore.h */; };
145
+		5047E4F52267568800908DD3 /* RNNExternalComponentStore.m in Sources */ = {isa = PBXBuildFile; fileRef = 5047E4F32267568700908DD3 /* RNNExternalComponentStore.m */; };
144 146
 		5048862D20BE976D000908DE /* RNNLayoutOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 5048862B20BE976D000908DE /* RNNLayoutOptions.h */; };
145 147
 		5048862E20BE976D000908DE /* RNNLayoutOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 5048862C20BE976D000908DE /* RNNLayoutOptions.m */; };
146 148
 		50495939216E5750006D2B81 /* Bool.h in Headers */ = {isa = PBXBuildFile; fileRef = 50495937216E5750006D2B81 /* Bool.h */; };
@@ -174,6 +176,7 @@
174 176
 		50570B272061473D006A1B5C /* RNNTitleOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50570B252061473D006A1B5C /* RNNTitleOptions.m */; };
175 177
 		50570BEA2063E09B006A1B5C /* RNNTitleViewHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 50570BE82063E09B006A1B5C /* RNNTitleViewHelper.h */; };
176 178
 		50570BEB2063E09B006A1B5C /* RNNTitleViewHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 50570BE92063E09B006A1B5C /* RNNTitleViewHelper.m */; };
179
+		505963F722676A0000EBB63C /* RNNLayoutManagerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 505963F622676A0000EBB63C /* RNNLayoutManagerTest.m */; };
177 180
 		505EDD32214E4BE80071C7DE /* RNNNavigationControllerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 505EDD31214E4BE80071C7DE /* RNNNavigationControllerTest.m */; };
178 181
 		505EDD34214E7B7B0071C7DE /* RNNLeafProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 505EDD33214E7A6A0071C7DE /* RNNLeafProtocol.h */; };
179 182
 		505EDD3C214FA8000071C7DE /* RNNViewControllerPresenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 505EDD3A214FA8000071C7DE /* RNNViewControllerPresenter.h */; };
@@ -258,7 +261,7 @@
258 261
 		7B4928091E70415400555040 /* RNNCommandsHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B4928071E70415400555040 /* RNNCommandsHandler.m */; };
259 262
 		7B49FEC01E95090800DEB3EA /* libReactNativeNavigation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D8AFADBD1BEE6F3F00A4592D /* libReactNativeNavigation.a */; };
260 263
 		7B49FECB1E95098500DEB3EA /* RNNControllerFactoryTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B49FEC61E95098500DEB3EA /* RNNControllerFactoryTest.m */; };
261
-		7B49FECC1E95098500DEB3EA /* RNNStoreTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B49FEC71E95098500DEB3EA /* RNNStoreTest.m */; };
264
+		7B49FECC1E95098500DEB3EA /* RNNExternalComponentStoreTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B49FEC71E95098500DEB3EA /* RNNExternalComponentStoreTest.m */; };
262 265
 		7B49FECD1E95098500DEB3EA /* RNNModalManagerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B49FEC81E95098500DEB3EA /* RNNModalManagerTest.m */; };
263 266
 		7B49FECE1E95098500DEB3EA /* RNNCommandsHandlerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B49FEC91E95098500DEB3EA /* RNNCommandsHandlerTest.m */; };
264 267
 		7B49FECF1E95098500DEB3EA /* RNNNavigationStackManagerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B49FECA1E95098500DEB3EA /* RNNNavigationStackManagerTest.m */; };
@@ -391,8 +394,6 @@
391 394
 		263905D51E4C94970023D7D3 /* RNNSideMenuController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNSideMenuController.m; sourceTree = "<group>"; };
392 395
 		263905E41E4CAC950023D7D3 /* RNNSideMenuChildVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNSideMenuChildVC.h; sourceTree = "<group>"; };
393 396
 		263905E51E4CAC950023D7D3 /* RNNSideMenuChildVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNSideMenuChildVC.m; sourceTree = "<group>"; };
394
-		268692801E5054F800E2C612 /* RNNStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNStore.h; sourceTree = "<group>"; };
395
-		268692811E5054F800E2C612 /* RNNStore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNStore.m; sourceTree = "<group>"; };
396 397
 		26916C941E4B9CCC00D13680 /* RNNRootViewCreator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNRootViewCreator.h; sourceTree = "<group>"; };
397 398
 		26916C961E4B9E7700D13680 /* RNNReactRootViewCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNReactRootViewCreator.h; sourceTree = "<group>"; };
398 399
 		26916C971E4B9E7700D13680 /* RNNReactRootViewCreator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNReactRootViewCreator.m; sourceTree = "<group>"; };
@@ -481,6 +482,10 @@
481 482
 		50451D0B2042F70900695F00 /* RNNTransition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNTransition.h; sourceTree = "<group>"; };
482 483
 		50451D0C2042F70900695F00 /* RNNTransition.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTransition.m; sourceTree = "<group>"; };
483 484
 		504753772109C13C00FFFBE6 /* RNNOverlayManagerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNOverlayManagerTest.m; sourceTree = "<group>"; };
485
+		5047E4EE22674AD400908DD3 /* RNNLayoutManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNLayoutManager.h; sourceTree = "<group>"; };
486
+		5047E4EF22674AD400908DD3 /* RNNLayoutManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNLayoutManager.m; sourceTree = "<group>"; };
487
+		5047E4F22267568500908DD3 /* RNNExternalComponentStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNExternalComponentStore.h; sourceTree = "<group>"; };
488
+		5047E4F32267568700908DD3 /* RNNExternalComponentStore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNExternalComponentStore.m; sourceTree = "<group>"; };
484 489
 		5048862B20BE976D000908DE /* RNNLayoutOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNLayoutOptions.h; sourceTree = "<group>"; };
485 490
 		5048862C20BE976D000908DE /* RNNLayoutOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNLayoutOptions.m; sourceTree = "<group>"; };
486 491
 		50495937216E5750006D2B81 /* Bool.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Bool.h; sourceTree = "<group>"; };
@@ -513,6 +518,7 @@
513 518
 		50570B252061473D006A1B5C /* RNNTitleOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTitleOptions.m; sourceTree = "<group>"; };
514 519
 		50570BE82063E09B006A1B5C /* RNNTitleViewHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNTitleViewHelper.h; sourceTree = "<group>"; };
515 520
 		50570BE92063E09B006A1B5C /* RNNTitleViewHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTitleViewHelper.m; sourceTree = "<group>"; };
521
+		505963F622676A0000EBB63C /* RNNLayoutManagerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNLayoutManagerTest.m; sourceTree = "<group>"; };
516 522
 		505EDD31214E4BE80071C7DE /* RNNNavigationControllerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNNavigationControllerTest.m; sourceTree = "<group>"; };
517 523
 		505EDD33214E7A6A0071C7DE /* RNNLeafProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNLeafProtocol.h; sourceTree = "<group>"; };
518 524
 		505EDD3A214FA8000071C7DE /* RNNViewControllerPresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNViewControllerPresenter.h; sourceTree = "<group>"; };
@@ -596,7 +602,7 @@
596 602
 		7B49FEBB1E95090800DEB3EA /* ReactNativeNavigationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ReactNativeNavigationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
597 603
 		7B49FEBF1E95090800DEB3EA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
598 604
 		7B49FEC61E95098500DEB3EA /* RNNControllerFactoryTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNControllerFactoryTest.m; sourceTree = "<group>"; };
599
-		7B49FEC71E95098500DEB3EA /* RNNStoreTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNStoreTest.m; sourceTree = "<group>"; };
605
+		7B49FEC71E95098500DEB3EA /* RNNExternalComponentStoreTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNExternalComponentStoreTest.m; sourceTree = "<group>"; };
600 606
 		7B49FEC81E95098500DEB3EA /* RNNModalManagerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNModalManagerTest.m; sourceTree = "<group>"; };
601 607
 		7B49FEC91E95098500DEB3EA /* RNNCommandsHandlerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNCommandsHandlerTest.m; sourceTree = "<group>"; };
602 608
 		7B49FECA1E95098500DEB3EA /* RNNNavigationStackManagerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNNavigationStackManagerTest.m; sourceTree = "<group>"; };
@@ -1004,6 +1010,8 @@
1004 1010
 				50D031332005149000386B3D /* RNNOverlayManager.m */,
1005 1011
 				5050465221F8F4490035497A /* RNNReactComponentRegistry.h */,
1006 1012
 				5050465321F8F4490035497A /* RNNReactComponentRegistry.m */,
1013
+				5047E4EE22674AD400908DD3 /* RNNLayoutManager.h */,
1014
+				5047E4EF22674AD400908DD3 /* RNNLayoutManager.m */,
1007 1015
 			);
1008 1016
 			name = Managers;
1009 1017
 			sourceTree = "<group>";
@@ -1052,7 +1060,7 @@
1052 1060
 			isa = PBXGroup;
1053 1061
 			children = (
1054 1062
 				7B49FEC61E95098500DEB3EA /* RNNControllerFactoryTest.m */,
1055
-				7B49FEC71E95098500DEB3EA /* RNNStoreTest.m */,
1063
+				7B49FEC71E95098500DEB3EA /* RNNExternalComponentStoreTest.m */,
1056 1064
 				7B49FEC81E95098500DEB3EA /* RNNModalManagerTest.m */,
1057 1065
 				7B49FEC91E95098500DEB3EA /* RNNCommandsHandlerTest.m */,
1058 1066
 				7B49FECA1E95098500DEB3EA /* RNNNavigationStackManagerTest.m */,
@@ -1077,6 +1085,7 @@
1077 1085
 				5038A376216CF252009280BC /* UITabBarController+RNNOptionsTest.m */,
1078 1086
 				509B247F217873FF00C83C23 /* UINavigationController+RNNOptionsTest.m */,
1079 1087
 				50AB0B1E22562FA10039DAED /* UIViewController+LayoutProtocolTest.m */,
1088
+				505963F622676A0000EBB63C /* RNNLayoutManagerTest.m */,
1080 1089
 			);
1081 1090
 			path = ReactNativeNavigationTests;
1082 1091
 			sourceTree = "<group>";
@@ -1122,8 +1131,8 @@
1122 1131
 				7BA500741E2544B9001B9E1B /* ReactNativeNavigation.m */,
1123 1132
 				2DCD9193200014A900EDC75D /* RNNBridgeManager.h */,
1124 1133
 				2DCD9194200014A900EDC75D /* RNNBridgeManager.m */,
1125
-				268692801E5054F800E2C612 /* RNNStore.h */,
1126
-				268692811E5054F800E2C612 /* RNNStore.m */,
1134
+				5047E4F22267568500908DD3 /* RNNExternalComponentStore.h */,
1135
+				5047E4F32267568700908DD3 /* RNNExternalComponentStore.m */,
1127 1136
 				7B4928061E70415400555040 /* RNNCommandsHandler.h */,
1128 1137
 				7B4928071E70415400555040 /* RNNCommandsHandler.m */,
1129 1138
 				502CB43920CBCA140019B2FE /* RNNBridgeManagerDelegate.h */,
@@ -1274,6 +1283,7 @@
1274 1283
 				263905E61E4CAC950023D7D3 /* RNNSideMenuChildVC.h in Headers */,
1275 1284
 				263905C41E4C6F440023D7D3 /* SidebarFacebookAnimation.h in Headers */,
1276 1285
 				50F5DFC51F407AA0001A00BC /* RNNNavigationController.h in Headers */,
1286
+				5047E4F42267568800908DD3 /* RNNExternalComponentStore.h in Headers */,
1277 1287
 				21B85E5F1F44482A00B314B5 /* RNNNavigationButtons.h in Headers */,
1278 1288
 				7BEF0D181E437684003E96B0 /* RNNRootViewController.h in Headers */,
1279 1289
 				7B1126A61E2D2B6C00F9B03B /* RNNBridgeModule.h in Headers */,
@@ -1291,7 +1301,6 @@
1291 1301
 				5049593E216F5D73006D2B81 /* BoolParser.h in Headers */,
1292 1302
 				50C4A496206BDDBB00DB292E /* RNNSubtitleOptions.h in Headers */,
1293 1303
 				5039559B2174867000B0A663 /* DoubleParser.h in Headers */,
1294
-				268692821E5054F800E2C612 /* RNNStore.h in Headers */,
1295 1304
 				E8AEDB3C1F55A1C2000F5A6A /* RNNElementView.h in Headers */,
1296 1305
 				E8E518321F83B3E0000467AC /* RNNUtils.h in Headers */,
1297 1306
 				50E5F791223FA04C002AFEAD /* RNNAnimationConfigurationOptions.h in Headers */,
@@ -1326,6 +1335,7 @@
1326 1335
 				2DCD9195200014A900EDC75D /* RNNBridgeManager.h in Headers */,
1327 1336
 				7B1126A91E2D2B6C00F9B03B /* RNNControllerFactory.h in Headers */,
1328 1337
 				501E0217213E7EA3003365C5 /* RNNReactView.h in Headers */,
1338
+				5047E4F022674AD400908DD3 /* RNNLayoutManager.h in Headers */,
1329 1339
 				263905D61E4C94970023D7D3 /* RNNSideMenuController.h in Headers */,
1330 1340
 				503955972174864E00B0A663 /* NullDouble.h in Headers */,
1331 1341
 				263905C81E4C6F440023D7D3 /* SidebarFlipboardAnimation.h in Headers */,
@@ -1444,6 +1454,7 @@
1444 1454
 				504753782109C13C00FFFBE6 /* RNNOverlayManagerTest.m in Sources */,
1445 1455
 				502F0E182179C39900367CC3 /* RNNTabBarPresenterTest.m in Sources */,
1446 1456
 				506F630F216A5AD700AD0D0A /* RNNViewControllerPresenterTest.m in Sources */,
1457
+				505963F722676A0000EBB63C /* RNNLayoutManagerTest.m in Sources */,
1447 1458
 				7B49FECE1E95098500DEB3EA /* RNNCommandsHandlerTest.m in Sources */,
1448 1459
 				5038A379216D01F6009280BC /* RNNBottomTabOptionsTest.m in Sources */,
1449 1460
 				E83BAD681F2734B500A9F3DD /* RNNNavigationOptionsTest.m in Sources */,
@@ -1460,7 +1471,7 @@
1460 1471
 				E83BAD791F27416B00A9F3DD /* RNNRootViewControllerTest.m in Sources */,
1461 1472
 				50CE8503217C6C9B00084EBF /* RNNSideMenuPresenterTest.m in Sources */,
1462 1473
 				E8DA243D1F973C1900CD552B /* RNNTransitionStateHolderTest.m in Sources */,
1463
-				7B49FECC1E95098500DEB3EA /* RNNStoreTest.m in Sources */,
1474
+				7B49FECC1E95098500DEB3EA /* RNNExternalComponentStoreTest.m in Sources */,
1464 1475
 			);
1465 1476
 			runOnlyForDeploymentPostprocessing = 0;
1466 1477
 		};
@@ -1494,6 +1505,7 @@
1494 1505
 				E8DA24411F97459B00CD552B /* RNNElementFinder.m in Sources */,
1495 1506
 				50570B272061473D006A1B5C /* RNNTitleOptions.m in Sources */,
1496 1507
 				263905BF1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.m in Sources */,
1508
+				5047E4F122674AD400908DD3 /* RNNLayoutManager.m in Sources */,
1497 1509
 				5012241F217366D4000F5F98 /* ColorParser.m in Sources */,
1498 1510
 				651E1F8D21FD642100DFEA19 /* RNNSplitViewControllerPresenter.m in Sources */,
1499 1511
 				501E0218213E7EA3003365C5 /* RNNReactView.m in Sources */,
@@ -1579,13 +1591,13 @@
1579 1591
 				5038A3BE216E1490009280BC /* RNNTabBarItemCreator.m in Sources */,
1580 1592
 				E8367B811F7A8A4700675C05 /* VICMAImageView.m in Sources */,
1581 1593
 				5049594B216F5FE6006D2B81 /* NullText.m in Sources */,
1594
+				5047E4F52267568800908DD3 /* RNNExternalComponentStore.m in Sources */,
1582 1595
 				A7626C011FC5796200492FB8 /* RNNBottomTabsOptions.m in Sources */,
1583 1596
 				5012241721736667000F5F98 /* Color.m in Sources */,
1584 1597
 				263905AF1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m in Sources */,
1585 1598
 				E8AEDB4B1F5C0BAF000F5A6A /* RNNInteractivePopAnimator.m in Sources */,
1586 1599
 				7B4928091E70415400555040 /* RNNCommandsHandler.m in Sources */,
1587 1600
 				50887C1620ECC5C200D06111 /* RNNButtonOptions.m in Sources */,
1588
-				268692831E5054F800E2C612 /* RNNStore.m in Sources */,
1589 1601
 				7BC9346E1E26886E00EFA125 /* RNNControllerFactory.m in Sources */,
1590 1602
 				507F43F91FF525B500D9425B /* RNNSegmentedControl.m in Sources */,
1591 1603
 				5038A3B2216DF41B009280BC /* UIViewController+RNNOptions.m in Sources */,

+ 39
- 34
lib/ios/ReactNativeNavigationTests/RNNCommandsHandlerTest.m View File

@@ -7,6 +7,7 @@
7 7
 #import "RNNNavigationController.h"
8 8
 #import "RNNErrorHandler.h"
9 9
 #import <OCMock/OCMock.h>
10
+#import "RNNLayoutManager.h"
10 11
 
11 12
 @interface MockUIApplication : NSObject
12 13
 
@@ -40,7 +41,6 @@
40 41
 
41 42
 @interface RNNCommandsHandlerTest : XCTestCase
42 43
 
43
-@property (nonatomic, strong) id store;
44 44
 @property (nonatomic, strong) RNNCommandsHandler* uut;
45 45
 @property (nonatomic, strong) RNNRootViewController* vc1;
46 46
 @property (nonatomic, strong) RNNRootViewController* vc2;
@@ -59,31 +59,26 @@
59 59
 - (void)setUp {
60 60
 	[super setUp];
61 61
 	self.mainWindow = [OCMockObject partialMockForObject:[UIWindow new]];
62
-	self.store = [OCMockObject partialMockForObject:[[RNNStore alloc] init]];
63 62
 	self.eventEmmiter = [OCMockObject partialMockForObject:[RNNEventEmitter new]];
64 63
 	self.overlayManager = [OCMockObject partialMockForObject:[RNNOverlayManager new]];
65
-	self.controllerFactory = [OCMockObject partialMockForObject:[[RNNControllerFactory alloc] initWithRootViewCreator:nil eventEmitter:self.eventEmmiter store:self.store componentRegistry:nil andBridge:nil]];
66
-	self.uut = [[RNNCommandsHandler alloc] initWithStore:self.store controllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:[RNNModalManager new] overlayManager:self.overlayManager mainWindow:_mainWindow];
64
+	self.controllerFactory = [OCMockObject partialMockForObject:[[RNNControllerFactory alloc] initWithRootViewCreator:nil eventEmitter:self.eventEmmiter store:nil componentRegistry:nil andBridge:nil]];
65
+	self.uut = [[RNNCommandsHandler alloc] initWithControllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:[RNNModalManager new] overlayManager:self.overlayManager mainWindow:_mainWindow];
67 66
 	self.vc1 = [RNNRootViewController new];
68 67
 	self.vc2 = [RNNRootViewController new];
69 68
 	self.vc3 = [RNNRootViewController new];
70 69
 	_nvc = [[MockUINavigationController alloc] init];
71 70
 	[_nvc setViewControllers:@[self.vc1, self.vc2, self.vc3]];
72
-	[self.store setComponent:self.vc1 componentId:@"vc1"];
73
-	[self.store setComponent:self.vc2 componentId:@"vc2"];
74
-	[self.store setComponent:self.vc3 componentId:@"vc3"];
75 71
 	OCMStub([self.sharedApplication keyWindow]).andReturn(self.mainWindow);
76 72
 }
77 73
 
78 74
 
79 75
 - (void)testAssertReadyForEachMethodThrowsExceptoins {
80 76
 	NSArray* methods = [self getPublicMethodNamesForObject:self.uut];
81
-	[self.store setReadyToReceiveCommands:false];
77
+	[self.uut setReadyToReceiveCommands:false];
82 78
 	for (NSString* methodName in methods) {
83 79
 		SEL s = NSSelectorFromString(methodName);
84 80
 		IMP imp = [self.uut methodForSelector:s];
85 81
 		void (*func)(id, SEL, id, id, id, id, id) = (void *)imp;
86
-		
87 82
 		XCTAssertThrowsSpecificNamed(func(self.uut,s, nil, nil, nil, nil, nil), NSException, @"BridgeNotLoadedError");
88 83
 	}
89 84
 }
@@ -91,9 +86,10 @@
91 86
 -(NSArray*) getPublicMethodNamesForObject:(NSObject*)obj{
92 87
 	NSMutableArray* skipMethods = [NSMutableArray new];
93 88
 	
94
-	[skipMethods addObject:@"initWithStore:controllerFactory:eventEmitter:stackManager:modalManager:overlayManager:mainWindow:"];
89
+	[skipMethods addObject:@"initWithControllerFactory:eventEmitter:stackManager:modalManager:overlayManager:mainWindow:"];
95 90
 	[skipMethods addObject:@"assertReady"];
96
-	[skipMethods addObject:@"removePopedViewControllers:"];
91
+	[skipMethods addObject:@"setReadyToReceiveCommands:"];
92
+	[skipMethods addObject:@"readyToReceiveCommands"];
97 93
 	[skipMethods addObject:@".cxx_destruct"];
98 94
 	[skipMethods addObject:@"dismissedModal:"];
99 95
 	[skipMethods addObject:@"dismissedMultipleModals:"];
@@ -132,8 +128,7 @@
132 128
 	[vc viewWillAppear:false];
133 129
 	XCTAssertTrue([vc.navigationItem.title isEqual:@"the title"]);
134 130
 
135
-	[self.store setReadyToReceiveCommands:true];
136
-	[self.store setComponent:vc componentId:@"componentId"];
131
+	[self.uut setReadyToReceiveCommands:true];
137 132
 
138 133
 	NSDictionary* dictFromJs = @{@"topBar": @{@"background" : @{@"color" : @(0xFFFF0000)}}};
139 134
 	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
@@ -155,8 +150,7 @@
155 150
 	[vc viewWillAppear:false];
156 151
 	XCTAssertTrue([vc.navigationItem.title isEqual:@"the title"]);
157 152
 	
158
-	[self.store setReadyToReceiveCommands:true];
159
-	[self.store setComponent:vc componentId:@"componentId"];
153
+	[self.uut setReadyToReceiveCommands:true];
160 154
 	
161 155
 	NSDictionary* dictFromJs = @{@"topBar": @{@"title" : @{@"text" : @"new title"}}};
162 156
 	
@@ -166,7 +160,7 @@
166 160
 }
167 161
 
168 162
 - (void)testShowOverlay_createLayout {
169
-	[self.store setReadyToReceiveCommands:true];
163
+	[self.uut setReadyToReceiveCommands:true];
170 164
 	OCMStub([self.overlayManager showOverlayWindow:[OCMArg any]]);
171 165
 	NSDictionary* layout = @{};
172 166
 	
@@ -176,7 +170,7 @@
176 170
 }
177 171
 
178 172
 - (void)testShowOverlay_saveToStore {
179
-	[self.store setReadyToReceiveCommands:true];
173
+	[self.uut setReadyToReceiveCommands:true];
180 174
 	OCMStub([self.overlayManager showOverlayWindow:[OCMArg any]]);
181 175
 	OCMStub([self.controllerFactory createLayout:[OCMArg any]]);
182 176
 	
@@ -186,7 +180,7 @@
186 180
 }
187 181
 
188 182
 - (void)testShowOverlay_withCreatedLayout {
189
-	[self.store setReadyToReceiveCommands:true];
183
+	[self.uut setReadyToReceiveCommands:true];
190 184
 	UIViewController* layoutVC = [RNNRootViewController new];
191 185
 	OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(layoutVC);
192 186
 	
@@ -196,7 +190,7 @@
196 190
 }
197 191
 
198 192
 - (void)testShowOverlay_invokeNavigationCommandEventWithLayout {
199
-	[self.store setReadyToReceiveCommands:true];
193
+	[self.uut setReadyToReceiveCommands:true];
200 194
 	OCMStub([self.overlayManager showOverlayWindow:[OCMArg any]]);
201 195
 	id mockedVC = [OCMockObject partialMockForObject:self.vc1];	
202 196
 	OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(mockedVC);
@@ -208,27 +202,30 @@
208 202
 	[self.eventEmmiter verify];
209 203
 }
210 204
 
211
-- (void)testDismissOverlay_findComponentFromStore {
212
-	[self.store setReadyToReceiveCommands:true];
205
+- (void)testDismissOverlay_findComponentFromLayoutManager {
206
+	[self.uut setReadyToReceiveCommands:true];
213 207
 	NSString* componentId = @"componentId";
214
-	[[self.store expect] findComponentForId:componentId];
208
+	id classMock = OCMClassMock([RNNLayoutManager class]);
209
+	[[classMock expect] findComponentForId:componentId];
215 210
 	[self.uut dismissOverlay:componentId commandId:@"" completion:^{} rejection:^(NSString *code, NSString *message, NSError *error) {}];
216
-	[self.store verify];
211
+	[classMock verify];
217 212
 }
218 213
 
219 214
 - (void)testDismissOverlay_dismissReturnedViewController {
220
-	[self.store setReadyToReceiveCommands:true];
215
+	[self.uut setReadyToReceiveCommands:true];
221 216
 	NSString* componentId = @"componentId";
222 217
 	UIViewController* returnedView = [UIViewController new];
223
-	OCMStub([self.store findComponentForId:componentId]).andReturn(returnedView);
224
-	
218
+
219
+	id classMock = OCMClassMock([RNNLayoutManager class]);
220
+	OCMStub(ClassMethod([classMock findComponentForId:componentId])).andReturn(returnedView);
221
+
225 222
 	[[self.overlayManager expect] dismissOverlay:returnedView];
226 223
 	[self.uut dismissOverlay:componentId commandId:@"" completion:^{} rejection:^(NSString *code, NSString *message, NSError *error) {}];
227 224
 	[self.overlayManager verify];
228 225
 }
229 226
 
230 227
 - (void)testDismissOverlay_handleErrorIfNoOverlayExists {
231
-	[self.store setReadyToReceiveCommands:true];
228
+	[self.uut setReadyToReceiveCommands:true];
232 229
 	NSString* componentId = @"componentId";
233 230
 	id errorHandlerMockClass = [OCMockObject mockForClass:[RNNErrorHandler class]];
234 231
 	
@@ -238,9 +235,11 @@
238 235
 }
239 236
 
240 237
 - (void)testDismissOverlay_invokeNavigationCommandEvent {
241
-	[self.store setReadyToReceiveCommands:true];
238
+	[self.uut setReadyToReceiveCommands:true];
242 239
 	NSString* componentId = @"componentId";
243
-	OCMStub([self.store findComponentForId:componentId]).andReturn([UIViewController new]);
240
+	
241
+	id classMock = OCMClassMock([RNNLayoutManager class]);
242
+	OCMStub(ClassMethod([classMock findComponentForId:componentId])).andReturn([UIViewController new]);
244 243
 	
245 244
 	[[self.eventEmmiter expect] sendOnNavigationCommandCompletion:@"dismissOverlay" commandId:[OCMArg any] params:[OCMArg any]];
246 245
 	[self.uut dismissOverlay:componentId commandId:@"" completion:^{
@@ -251,7 +250,7 @@
251 250
 }
252 251
 
253 252
 - (void)testSetRoot_setRootViewControllerOnMainWindow {
254
-	[self.store setReadyToReceiveCommands:true];
253
+	[self.uut setReadyToReceiveCommands:true];
255 254
 	OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(self.vc1);
256 255
 	
257 256
 	[[self.mainWindow expect] setRootViewController:self.vc1];
@@ -261,20 +260,26 @@
261 260
 
262 261
 - (void)testSetStackRoot_resetStackWithSingleComponent {
263 262
 	OCMStub([self.controllerFactory createChildrenLayout:[OCMArg any]]).andReturn(@[self.vc2]);
264
-	[self.store setReadyToReceiveCommands:true];
263
+	[self.uut setReadyToReceiveCommands:true];
264
+	id classMock = OCMClassMock([RNNLayoutManager class]);
265
+	OCMStub(ClassMethod([classMock findComponentForId:@"vc1"])).andReturn(_nvc);
266
+	
265 267
 	[self.uut setStackRoot:@"vc1" commandId:@"" children:nil completion:^{
266 268
 		
267 269
 	} rejection:^(NSString *code, NSString *message, NSError *error) {
268 270
 		
269 271
 	}];
272
+	
270 273
 	XCTAssertEqual(_nvc.viewControllers.firstObject, self.vc2);
271 274
 	XCTAssertEqual(_nvc.viewControllers.count, 1);
272 275
 }
273 276
 
274 277
 - (void)testSetStackRoot_setMultipleChildren {
275 278
 	NSArray* newViewControllers = @[_vc1, _vc3];
279
+	id classMock = OCMClassMock([RNNLayoutManager class]);
280
+	OCMStub(ClassMethod([classMock findComponentForId:@"vc1"])).andReturn(_nvc);
276 281
 	OCMStub([self.controllerFactory createChildrenLayout:[OCMArg any]]).andReturn(newViewControllers);
277
-	[self.store setReadyToReceiveCommands:true];
282
+	[self.uut setReadyToReceiveCommands:true];
278 283
 	[self.uut setStackRoot:@"vc1" commandId:@"" children:nil completion:^{
279 284
 		
280 285
 	} rejection:^(NSString *code, NSString *message, NSError *error) {
@@ -284,7 +289,7 @@
284 289
 }
285 290
 
286 291
 - (void)testSetRoot_waitForRenderTrue {
287
-	[self.store setReadyToReceiveCommands:true];
292
+	[self.uut setReadyToReceiveCommands:true];
288 293
 	self.vc1.options = [[RNNNavigationOptions alloc] initEmptyOptions];
289 294
 	self.vc1.options.animations.setRoot.waitForRender = [[Bool alloc] initWithBOOL:YES];
290 295
 	
@@ -297,7 +302,7 @@
297 302
 }
298 303
 
299 304
 - (void)testSetRoot_waitForRenderFalse {
300
-	[self.store setReadyToReceiveCommands:true];
305
+	[self.uut setReadyToReceiveCommands:true];
301 306
 	self.vc1.options = [[RNNNavigationOptions alloc] initEmptyOptions];
302 307
 	self.vc1.options.animations.setRoot.waitForRender = [[Bool alloc] initWithBOOL:NO];
303 308
 	

+ 2
- 15
lib/ios/ReactNativeNavigationTests/RNNControllerFactoryTest.m View File

@@ -13,7 +13,7 @@
13 13
 
14 14
 @property (nonatomic, strong) id<RNNRootViewCreator> creator;
15 15
 @property (nonatomic, strong) RNNControllerFactory *factory;
16
-@property (nonatomic, strong) RNNStore *store;
16
+@property (nonatomic, strong) RNNExternalComponentStore *store;
17 17
 
18 18
 @end
19 19
 
@@ -22,7 +22,7 @@
22 22
 - (void)setUp {
23 23
 	[super setUp];
24 24
 	self.creator = nil;
25
-	self.store = [RNNStore new];
25
+	self.store = [RNNExternalComponentStore new];
26 26
 	self.factory = [[RNNControllerFactory alloc] initWithRootViewCreator:self.creator eventEmitter:nil store:self.store componentRegistry:nil andBridge:nil];
27 27
 }
28 28
 
@@ -188,17 +188,4 @@
188 188
 	XCTAssertTrue([right.child isMemberOfClass:[RNNRootViewController class]]);
189 189
 }
190 190
 
191
-- (void)testCreateLayout_addComponentToStore {
192
-	NSString *componentId = @"cntId";
193
-	NSDictionary* layout = @{@"id": componentId,
194
-							 @"type": @"Component",
195
-							 @"data": @{},
196
-							 @"children": @[]};
197
-	UIViewController *ans = [self.factory createLayout:layout];
198
-	
199
-	UIViewController *storeAns = [self.store findComponentForId:componentId];
200
-	XCTAssertEqualObjects(ans, storeAns);
201
-}
202
-
203
-
204 191
 @end

+ 33
- 0
lib/ios/ReactNativeNavigationTests/RNNExternalComponentStoreTest.m View File

@@ -0,0 +1,33 @@
1
+
2
+#import <XCTest/XCTest.h>
3
+#import <OCMock/OCMock.h>
4
+#import "RNNExternalComponentStore.h"
5
+
6
+@interface RNNExternalComponentStoreTest : XCTestCase
7
+
8
+@property (nonatomic, strong) RNNExternalComponentStore *store;
9
+
10
+@end
11
+
12
+@implementation RNNExternalComponentStoreTest
13
+
14
+- (void)setUp {
15
+	[super setUp];
16
+	
17
+	self.store = [RNNExternalComponentStore new];
18
+}
19
+
20
+- (void)testGetExternalComponentShouldRetrunSavedComponent {
21
+	UIViewController* testVC = [UIViewController new];
22
+	RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] init];
23
+	layoutInfo.name = @"extId1";
24
+	[self.store registerExternalComponent:layoutInfo.name callback:^UIViewController *(NSDictionary *props, RCTBridge *bridge) {
25
+		return testVC;
26
+	}];
27
+	
28
+	UIViewController* savedComponent = [self.store getExternalComponent:layoutInfo bridge:nil];
29
+	XCTAssertEqual(testVC, savedComponent);
30
+}
31
+
32
+
33
+@end

+ 88
- 0
lib/ios/ReactNativeNavigationTests/RNNLayoutManagerTest.m View File

@@ -0,0 +1,88 @@
1
+
2
+#import <XCTest/XCTest.h>
3
+#import <OCMock/OCMock.h>
4
+#import "RNNLayoutManager.h"
5
+#import "UIViewController+LayoutProtocol.m"
6
+
7
+@interface RNNLayoutManagerTest : XCTestCase
8
+
9
+@property (nonatomic, strong) UIViewController* vc1;
10
+@property (nonatomic, strong) UIViewController* vc2;
11
+@property (nonatomic, strong) UIViewController* vc3;
12
+
13
+@property (nonatomic, strong) UIWindow* firstWindow;
14
+@property (nonatomic, strong) UIWindow* secondWindow;
15
+
16
+@end
17
+
18
+@implementation RNNLayoutManagerTest
19
+
20
+- (void)setUp {
21
+	_vc1 = [self createMockViewControllerWithComponentId:@"vc1"];
22
+	_vc2 = [self createMockViewControllerWithComponentId:@"vc2"];
23
+	_vc3 = [self createMockViewControllerWithComponentId:@"vc3"];
24
+	
25
+	_firstWindow = [[UIWindow alloc] init];
26
+	_secondWindow = [[UIWindow alloc] init];
27
+	NSArray* windows = @[_firstWindow, _secondWindow];
28
+	
29
+	UIApplication* sharedApplication = [OCMockObject mockForClass:[UIApplication class]];
30
+	id mockedApplicationClass = OCMClassMock([UIApplication class]);
31
+	OCMStub(ClassMethod([mockedApplicationClass sharedApplication])).andReturn(sharedApplication);
32
+	OCMStub([sharedApplication windows]).andReturn(windows);
33
+}
34
+
35
+- (void)testFindComponentForIdShouldReturnVCInFirstWindowRoot {
36
+	_firstWindow.rootViewController = _vc1;
37
+	UIViewController *resultVC = [RNNLayoutManager findComponentForId:@"vc1"];
38
+	XCTAssertEqual(resultVC, _vc1);
39
+}
40
+
41
+- (void)testFindComponentForIdShouldReturnVCFromSecondWindowRoot {
42
+	_secondWindow.rootViewController = _vc1;
43
+	UIViewController *resultVC = [RNNLayoutManager findComponentForId:@"vc1"];
44
+	XCTAssertEqual(resultVC, _vc1);
45
+}
46
+
47
+- (void)testFindComponentShouldReturnModalFromFirstWindow {
48
+	UIViewController* modal = _vc1;
49
+	OCMStub([_vc2 presentedViewController]).andReturn(modal);
50
+	_firstWindow.rootViewController = _vc2;
51
+	UIViewController *resultVC = [RNNLayoutManager findComponentForId:@"vc1"];
52
+	XCTAssertEqual(resultVC, modal);
53
+}
54
+
55
+- (void)testFindComponentShouldReturnModalFromSecondWindow {
56
+	UIViewController* modal = _vc1;
57
+	OCMStub([_vc2 presentedViewController]).andReturn(modal);
58
+	_secondWindow.rootViewController = _vc2;
59
+	UIViewController *resultVC = [RNNLayoutManager findComponentForId:@"vc1"];
60
+	XCTAssertEqual(resultVC, modal);
61
+}
62
+
63
+- (void)testFindComponentShouldReturnNilForUndefindComponent {
64
+	_firstWindow.rootViewController = _vc1;
65
+	UIViewController *resultVC = [RNNLayoutManager findComponentForId:@"vvc"];
66
+	XCTAssertNil(resultVC);
67
+}
68
+
69
+- (void)testFindComponentShouldFindRootViewControllerChildViewController {
70
+	UINavigationController* nvc = [[UINavigationController alloc] init];
71
+	[nvc setViewControllers:@[_vc1, _vc2, _vc3]];
72
+	_secondWindow.rootViewController = nvc;
73
+
74
+	UIViewController *resultVC = [RNNLayoutManager findComponentForId:@"vc3"];
75
+	XCTAssertEqual(resultVC, _vc3);
76
+}
77
+
78
+- (UIViewController *)createMockViewControllerWithComponentId:(NSString *)componentId {
79
+	RNNLayoutInfo* layoutInfo = [RNNLayoutInfo new];
80
+	layoutInfo.componentId = componentId;
81
+	
82
+	UIViewController* vc = [OCMockObject partialMockForObject:[UIViewController new]];
83
+	OCMStub([vc layoutInfo]).andReturn(layoutInfo);
84
+	
85
+	return vc;
86
+}
87
+
88
+@end

+ 0
- 1
lib/ios/ReactNativeNavigationTests/RNNNavigationStackManagerTest.m View File

@@ -1,5 +1,4 @@
1 1
 #import <XCTest/XCTest.h>
2
-#import "RNNStore.h"
3 2
 #import "RNNNavigationStackManager.h"
4 3
 #import "RNNRootViewController.h"
5 4
 #import "RNNNavigationController.h"

+ 0
- 147
lib/ios/ReactNativeNavigationTests/RNNStoreTest.m View File

@@ -1,147 +0,0 @@
1
-
2
-#import <XCTest/XCTest.h>
3
-#import <OCMock/OCMock.h>
4
-#import "RNNStore.h"
5
-
6
-@interface RNNStoreTest : XCTestCase
7
-
8
-@property (nonatomic, strong) RNNStore *store;
9
-
10
-@end
11
-
12
-@implementation RNNStoreTest
13
-
14
-- (void)setUp {
15
-	[super setUp];
16
-	
17
-	self.store = [RNNStore new];
18
-}
19
-
20
-
21
-- (void)testFindComponentForId_setAndGetsimpleComponentId {
22
-	NSString *componentId1 = @"cntId1";
23
-	NSString *componentId2 = @"cntId2";
24
-	
25
-	UIViewController *vc1 = [UIViewController new];
26
-	UIViewController *vc2 = [UIViewController new];
27
-	
28
-	[self.store setComponent:vc1 componentId:componentId1];
29
-	[self.store setComponent:vc2 componentId:componentId2];
30
-	
31
-	UIViewController *ans = [self.store findComponentForId:componentId1];
32
-	
33
-	XCTAssertEqualObjects(vc1, ans);
34
-	XCTAssertNotEqualObjects(vc2, ans);
35
-}
36
-
37
-- (void)testSetComponent_setNilComponentId {
38
-	NSString *componentId1 = nil;
39
-	UIViewController *vc1 = [UIViewController new];
40
-	[self.store setComponent:vc1 componentId:componentId1];
41
-	XCTAssertNil([self.store findComponentForId:componentId1]);
42
-	
43
-}
44
-
45
-- (void)testSetComponent_setDoubleComponentId {
46
-	NSString *componentId1 = @"cntId1";
47
-	
48
-	UIViewController *vc1 = [UIViewController new];
49
-	UIViewController *vc2 = [UIViewController new];
50
-	
51
-	[self.store setComponent:vc1 componentId:componentId1];
52
-	
53
-	UIViewController *ans = [self.store findComponentForId:componentId1];
54
-	XCTAssertEqualObjects(vc1, ans);
55
-	XCTAssertThrows([self.store setComponent:vc2 componentId:componentId1]);
56
-}
57
-
58
-- (void)testRemoveComponent_removeExistComponent {
59
-	NSString *componentId1 = @"cntId1";
60
-	UIViewController *vc1 = [UIViewController new];
61
-	
62
-	[self.store setComponent:vc1 componentId:componentId1];
63
-	
64
-	UIViewController *ans = [self.store findComponentForId:componentId1];
65
-	XCTAssertEqualObjects(vc1, ans);
66
-	
67
-	[self.store removeComponent:componentId1];
68
-	XCTAssertNil([self.store findComponentForId:componentId1]);
69
-}
70
-
71
-- (void)testPopWillRemoveVcFromStore {
72
-	NSString *vcId = @"cnt_vc_2";
73
-	
74
-	[self setComponentAndRelease:vcId];
75
-	
76
-	
77
-	XCTAssertNil([self.store findComponentForId:vcId]);
78
-}
79
-
80
-- (void)testRemoveAllComponentsFromWindowShouldRemoveComponentsInWindow {
81
-	UIViewController* overlayVC = [self createMockedViewControllerWithWindow:[UIWindow new]];
82
-	
83
-	NSString* overlayId = @"overlayId";
84
-	[self.store setComponent:overlayVC componentId:overlayId];
85
-	[self.store removeAllComponentsFromWindow:overlayVC.view.window];
86
-	XCTAssertNil([self.store findComponentForId:overlayId]);
87
-}
88
-
89
-- (void)testRemoveAllComponentsFromWindowShouldNotRemoveComponentsInOtherWindows {
90
-	UIViewController* overlayVC = [self createMockedViewControllerWithWindow:[UIWindow new]];
91
-	UIViewController* componentVC = [self createMockedViewControllerWithWindow:[UIWindow new]];
92
-	
93
-	NSString* componentId = @"componentId";
94
-	NSString* overlayId = @"overlayId";
95
-	[self.store setComponent:overlayVC componentId:overlayId];
96
-	[self.store setComponent:componentVC componentId:componentId];
97
-	
98
-	[self.store removeAllComponentsFromWindow:componentVC.view.window];
99
-	XCTAssertNil([self.store findComponentForId:componentId]);
100
-	XCTAssertNotNil([self.store findComponentForId:overlayId]);
101
-}
102
-
103
-- (void)testGetExternalComponentShouldRetrunSavedComponent {
104
-	UIViewController* testVC = [UIViewController new];
105
-	RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] init];
106
-	layoutInfo.name = @"extId1";
107
-	[self.store registerExternalComponent:layoutInfo.name callback:^UIViewController *(NSDictionary *props, RCTBridge *bridge) {
108
-		return testVC;
109
-	}];
110
-	
111
-	UIViewController* savedComponent = [self.store getExternalComponent:layoutInfo bridge:nil];
112
-	XCTAssertEqual(testVC, savedComponent);
113
-}
114
-
115
-- (void)testComponentKeyForInstance_UknownComponentShouldReturnNil {
116
-	id result = [self.store componentKeyForInstance:[UIViewController new]];
117
-	XCTAssertNil(result);
118
-}
119
-
120
-- (void)testCleanStore {
121
-	[self.store clean];
122
-	XCTAssertFalse(self.store.isReadyToReceiveCommands);
123
-}
124
-
125
-#pragma mark - private
126
-
127
-
128
--(void)setComponentAndRelease:(NSString*)vcId {
129
-	@autoreleasepool {
130
-		UIViewController *vc2 = [UIViewController new];
131
-		[self.store setComponent:vc2 componentId:vcId];
132
-		
133
-		XCTAssertNotNil([self.store findComponentForId:vcId]);
134
-	}
135
-}
136
-
137
-- (UIViewController *)createMockedViewControllerWithWindow:(UIWindow *)window {
138
-	UIWindow* overlayWindow = [UIWindow new];
139
-	id mockedViewController = [OCMockObject partialMockForObject:[UIViewController new]];
140
-	id mockedView = [OCMockObject partialMockForObject:[UIView new]];
141
-	OCMStub([mockedView window]).andReturn(overlayWindow);
142
-	OCMStub([mockedViewController view]).andReturn(mockedView);
143
-	return mockedViewController;
144
-}
145
-
146
-
147
-@end

+ 0
- 14
lib/ios/ReactNativeNavigationTests/UIViewController+LayoutProtocolTest.m View File

@@ -17,19 +17,5 @@
17 17
     self.uut.layoutInfo.componentId = @"componentId";
18 18
 }
19 19
 
20
-- (void)testSetStoreShouldSaveComponent {
21
-    RNNStore* store = [[RNNStore alloc] init];
22
-    [self.uut setStore:store];
23
-    XCTAssertNotNil([store findComponentForId:self.uut.layoutInfo.componentId]);
24
-}
25
-
26
-- (void)testDeallocShouldRemoveComponentFromStore {
27
-    RNNStore* store = [[RNNStore alloc] init];
28
-    [self.uut setStore:store];
29
-    XCTAssertNotNil([store findComponentForId:self.uut.layoutInfo.componentId]);
30
-    self.uut = nil;
31
-    XCTAssertNil([store findComponentForId:self.uut.layoutInfo.componentId]);
32
-}
33
-
34 20
 
35 21
 @end

+ 0
- 2
lib/ios/UIViewController+LayoutProtocol.h View File

@@ -1,7 +1,6 @@
1 1
 #import <UIKit/UIKit.h>
2 2
 #import "RNNEventEmitter.h"
3 3
 #import "RNNLayoutProtocol.h"
4
-#import "RNNStore.h"
5 4
 
6 5
 typedef void (^RNNReactViewReadyCompletionBlock)(void);
7 6
 
@@ -24,7 +23,6 @@ typedef void (^RNNReactViewReadyCompletionBlock)(void);
24 23
 @property (nonatomic, strong) RNNNavigationOptions* options;
25 24
 @property (nonatomic, strong) RNNNavigationOptions* defaultOptions;
26 25
 @property (nonatomic, strong) RNNEventEmitter* eventEmitter;
27
-@property (nonatomic, strong) RNNStore* store;
28 26
 @property (nonatomic) id<RNNRootViewCreator> creator;
29 27
 
30 28
 @end

+ 0
- 14
lib/ios/UIViewController+LayoutProtocol.m View File

@@ -24,11 +24,6 @@
24 24
 	return self;
25 25
 }
26 26
 
27
-- (void)setStore:(RNNStore *)store {
28
-	objc_setAssociatedObject(self, @selector(store), store, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
29
-	[self.store setComponent:self componentId:self.layoutInfo.componentId];
30
-}
31
-
32 27
 - (RNNNavigationOptions *)resolveOptions {
33 28
 	return [(RNNNavigationOptions *)[self.options mergeInOptions:self.getCurrentChild.resolveOptions.copy] withDefault:self.defaultOptions];
34 29
 }
@@ -81,11 +76,6 @@
81 76
 	}
82 77
 }
83 78
 
84
-- (void)dealloc {
85
-	[self.store removeComponent:self.layoutInfo.componentId];
86
-}
87
-
88
-
89 79
 #pragma mark getters and setters to associated object
90 80
 
91 81
 - (RNNNavigationOptions *)options {
@@ -128,10 +118,6 @@
128 118
 	objc_setAssociatedObject(self, @selector(eventEmitter), eventEmitter, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
129 119
 }
130 120
 
131
-- (RNNStore *)store {
132
-	return objc_getAssociatedObject(self, @selector(store));
133
-}
134
-
135 121
 - (id<RNNRootViewCreator>)creator {
136 122
 	return objc_getAssociatedObject(self, @selector(creator));
137 123
 }