Ver código fonte

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

* Stop manually manage viewControllers store, Iterate layout instead

* Update RNNCommandsHandlerTest.m
Yogev Ben David 6 anos atrás
pai
commit
275304c88e
Nenhuma conta vinculada ao e-mail do autor do commit

+ 0
- 2
lib/ios/RNNBridgeManager.h Ver arquivo

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

+ 5
- 6
lib/ios/RNNBridgeManager.m Ver arquivo

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

+ 3
- 2
lib/ios/RNNCommandsHandler.h Ver arquivo

2
 #import <UIKit/UIKit.h>
2
 #import <UIKit/UIKit.h>
3
 
3
 
4
 #import "RNNControllerFactory.h"
4
 #import "RNNControllerFactory.h"
5
-#import "RNNStore.h"
6
 #import "RNNModalManager.h"
5
 #import "RNNModalManager.h"
7
 #import "RNNNavigationStackManager.h"
6
 #import "RNNNavigationStackManager.h"
8
 #import "RNNOverlayManager.h"
7
 #import "RNNOverlayManager.h"
9
 
8
 
10
 @interface RNNCommandsHandler : NSObject
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
 - (void)setRoot:(NSDictionary*)layout commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion;
15
 - (void)setRoot:(NSDictionary*)layout commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion;
15
 
16
 

+ 12
- 13
lib/ios/RNNCommandsHandler.m Ver arquivo

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

+ 2
- 2
lib/ios/RNNControllerFactory.h Ver arquivo

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

+ 2
- 4
lib/ios/RNNControllerFactory.m Ver arquivo

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

+ 12
- 0
lib/ios/RNNExternalComponentStore.h Ver arquivo

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 Ver arquivo

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 Ver arquivo

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 Ver arquivo

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 Ver arquivo

1
 #import <Foundation/Foundation.h>
1
 #import <Foundation/Foundation.h>
2
 #import <UIKit/UIKit.h>
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
 @protocol RNNModalManagerDelegate <NSObject>
8
 @protocol RNNModalManagerDelegate <NSObject>
6
 
9
 

+ 0
- 1
lib/ios/RNNOverlayManager.h Ver arquivo

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

+ 0
- 1
lib/ios/RNNReactComponentRegistry.h Ver arquivo

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

+ 1
- 27
lib/ios/RNNRootViewController.m Ver arquivo

15
 	
15
 	
16
 	self.animator = [[RNNAnimator alloc] initWithTransitionOptions:self.resolveOptions.customTransition];
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
 	self.navigationController.delegate = self;
18
 	self.navigationController.delegate = self;
23
 	
19
 	
24
 	return self;
20
 	return self;
84
 			}
80
 			}
85
 		}];
81
 		}];
86
 	}];
82
 	}];
87
-
83
+	
88
 	self.view = reactView;
84
 	self.view = reactView;
89
 	
85
 	
90
 	if (!wait && readyBlock) {
86
 	if (!wait && readyBlock) {
213
 	[self.eventEmitter sendOnNavigationButtonPressed:self.layoutInfo.componentId buttonId:barButtonItem.buttonId];
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
 @end
213
 @end

+ 0
- 28
lib/ios/RNNStore.h Ver arquivo

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 Ver arquivo

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 Ver arquivo

17
 
17
 
18
 @implementation RNNViewControllerPresenter
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
 - (instancetype)initWithComponentRegistry:(RNNReactComponentRegistry *)componentRegistry {
20
 - (instancetype)initWithComponentRegistry:(RNNReactComponentRegistry *)componentRegistry {
31
 	self = [self init];
21
 	self = [self init];
32
 	_componentRegistry = componentRegistry;
22
 	_componentRegistry = componentRegistry;
220
 	[_componentRegistry clearComponentsForParentId:self.bindedComponentId];
210
 	[_componentRegistry clearComponentsForParentId:self.bindedComponentId];
221
 }
211
 }
222
 
212
 
223
-- (void)cleanReactLeftovers {
224
-	_customTitleView = nil;
225
-}
226
 
213
 
227
 @end
214
 @end

+ 2
- 2
lib/ios/ReactNativeNavigation.m Ver arquivo

4
 
4
 
5
 #import "RNNBridgeManager.h"
5
 #import "RNNBridgeManager.h"
6
 #import "RNNSplashScreen.h"
6
 #import "RNNSplashScreen.h"
7
+#import "RNNLayoutManager.h"
7
 
8
 
8
 @interface ReactNativeNavigation()
9
 @interface ReactNativeNavigation()
9
 
10
 
32
 }
33
 }
33
 
34
 
34
 + (UIViewController *)findViewController:(NSString *)componentId {
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
 # pragma mark - instance
39
 # pragma mark - instance

+ 24
- 12
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj Ver arquivo

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

+ 39
- 34
lib/ios/ReactNativeNavigationTests/RNNCommandsHandlerTest.m Ver arquivo

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

+ 2
- 15
lib/ios/ReactNativeNavigationTests/RNNControllerFactoryTest.m Ver arquivo

13
 
13
 
14
 @property (nonatomic, strong) id<RNNRootViewCreator> creator;
14
 @property (nonatomic, strong) id<RNNRootViewCreator> creator;
15
 @property (nonatomic, strong) RNNControllerFactory *factory;
15
 @property (nonatomic, strong) RNNControllerFactory *factory;
16
-@property (nonatomic, strong) RNNStore *store;
16
+@property (nonatomic, strong) RNNExternalComponentStore *store;
17
 
17
 
18
 @end
18
 @end
19
 
19
 
22
 - (void)setUp {
22
 - (void)setUp {
23
 	[super setUp];
23
 	[super setUp];
24
 	self.creator = nil;
24
 	self.creator = nil;
25
-	self.store = [RNNStore new];
25
+	self.store = [RNNExternalComponentStore new];
26
 	self.factory = [[RNNControllerFactory alloc] initWithRootViewCreator:self.creator eventEmitter:nil store:self.store componentRegistry:nil andBridge:nil];
26
 	self.factory = [[RNNControllerFactory alloc] initWithRootViewCreator:self.creator eventEmitter:nil store:self.store componentRegistry:nil andBridge:nil];
27
 }
27
 }
28
 
28
 
188
 	XCTAssertTrue([right.child isMemberOfClass:[RNNRootViewController class]]);
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
 @end
191
 @end

+ 33
- 0
lib/ios/ReactNativeNavigationTests/RNNExternalComponentStoreTest.m Ver arquivo

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 Ver arquivo

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 Ver arquivo

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

+ 0
- 147
lib/ios/ReactNativeNavigationTests/RNNStoreTest.m Ver arquivo

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 Ver arquivo

17
     self.uut.layoutInfo.componentId = @"componentId";
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
 @end
21
 @end

+ 0
- 2
lib/ios/UIViewController+LayoutProtocol.h Ver arquivo

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

+ 0
- 14
lib/ios/UIViewController+LayoutProtocol.m Ver arquivo

24
 	return self;
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
 - (RNNNavigationOptions *)resolveOptions {
27
 - (RNNNavigationOptions *)resolveOptions {
33
 	return [(RNNNavigationOptions *)[self.options mergeInOptions:self.getCurrentChild.resolveOptions.copy] withDefault:self.defaultOptions];
28
 	return [(RNNNavigationOptions *)[self.options mergeInOptions:self.getCurrentChild.resolveOptions.copy] withDefault:self.defaultOptions];
34
 }
29
 }
81
 	}
76
 	}
82
 }
77
 }
83
 
78
 
84
-- (void)dealloc {
85
-	[self.store removeComponent:self.layoutInfo.componentId];
86
-}
87
-
88
-
89
 #pragma mark getters and setters to associated object
79
 #pragma mark getters and setters to associated object
90
 
80
 
91
 - (RNNNavigationOptions *)options {
81
 - (RNNNavigationOptions *)options {
128
 	objc_setAssociatedObject(self, @selector(eventEmitter), eventEmitter, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
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
 - (id<RNNRootViewCreator>)creator {
121
 - (id<RNNRootViewCreator>)creator {
136
 	return objc_getAssociatedObject(self, @selector(creator));
122
 	return objc_getAssociatedObject(self, @selector(creator));
137
 }
123
 }