Browse Source

ios fixed invalid bridge

Daniel Zlotin 7 years ago
parent
commit
8b8d914a06

+ 20
- 19
ios/RNN.m View File

9
 
9
 
10
 @interface RNN() <RCTBridgeDelegate>
10
 @interface RNN() <RCTBridgeDelegate>
11
 
11
 
12
-
13
-
14
 @end
12
 @end
15
 
13
 
16
 @implementation RNN {
14
 @implementation RNN {
17
 	NSURL *_jsCodeLocation;
15
 	NSURL *_jsCodeLocation;
18
 	RCTBridge *_bridge;
16
 	RCTBridge *_bridge;
19
-	RNNEventEmitter *_eventEmitter;
20
 	RNNStore *_store;
17
 	RNNStore *_store;
21
 }
18
 }
22
 
19
 
37
 
34
 
38
 -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions {
35
 -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions {
39
 	_jsCodeLocation = jsCodeLocation;
36
 	_jsCodeLocation = jsCodeLocation;
40
-	_eventEmitter = [RNNEventEmitter new];
41
 	
37
 	
42
 	UIApplication.sharedApplication.delegate.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
38
 	UIApplication.sharedApplication.delegate.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
43
 	UIApplication.sharedApplication.delegate.window.backgroundColor = [UIColor whiteColor];
39
 	UIApplication.sharedApplication.delegate.window.backgroundColor = [UIColor whiteColor];
56
 	return _jsCodeLocation;
52
 	return _jsCodeLocation;
57
 }
53
 }
58
 
54
 
55
+-(void)onJavaScriptWillLoad {
56
+	_store = [RNNStore new];
57
+	[self resetRootViewControllerOnlyOnJSDevReload];
58
+}
59
+
59
 -(NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge {
60
 -(NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge {
61
+	RNNEventEmitter *eventEmitter = [[RNNEventEmitter alloc] init];
60
 	
62
 	
61
-	RNNControllerFactory *controllerFactory = [[RNNControllerFactory alloc] initWithRootViewCreator:[RNNReactRootViewCreator new] store:_store];
63
+	RNNControllerFactory *controllerFactory = [[RNNControllerFactory alloc] initWithRootViewCreator:[[RNNReactRootViewCreator alloc]initWithBridge:bridge] store:_store eventEmitter:eventEmitter];
62
 	RNNCommandsHandler *commandsHandler = [[RNNCommandsHandler alloc]initWithStore:_store controllerFactory:controllerFactory];
64
 	RNNCommandsHandler *commandsHandler = [[RNNCommandsHandler alloc]initWithStore:_store controllerFactory:controllerFactory];
63
 	
65
 	
64
 	RNNBridgeModule *bridgeModule = [[RNNBridgeModule alloc] initWithCommandsHandler:commandsHandler];
66
 	RNNBridgeModule *bridgeModule = [[RNNBridgeModule alloc] initWithCommandsHandler:commandsHandler];
65
-	RNNEventEmitter *eventEmitter = [[RNNEventEmitter alloc] initWithBridge:bridge];
66
 	
67
 	
67
 	return @[bridgeModule,eventEmitter];
68
 	return @[bridgeModule,eventEmitter];
68
 }
69
 }
69
 
70
 
70
-# pragma mark - private
71
-
72
--(void)registerForJsEvents {
73
-	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJavaScriptLoaded) name:RCTJavaScriptDidLoadNotification object:_bridge];
74
-	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJavaScriptWillLoad) name:RCTJavaScriptWillStartLoadingNotification	object:_bridge];
71
+-(void)onJavaScriptLoaded {
72
+	_store.isReadyToReceiveCommands = YES;
73
+	[[_bridge moduleForClass:[RNNEventEmitter class]] sendOnAppLaunched];
75
 }
74
 }
76
 
75
 
76
+# pragma mark - private
77
 
77
 
78
--(void)onJavaScriptWillLoad {
79
-	_store = [RNNStore new];
80
-	[self resetRootViewControllerOnlyOnJSDevReload];
81
-}
82
-
83
--(void)onJavaScriptLoaded {
84
-	_store.isReadyToReceiveCommands = true;
85
-	[_eventEmitter sendOnAppLaunched];
78
+-(void)registerForJsEvents {
79
+	[[NSNotificationCenter defaultCenter] addObserver:self
80
+											 selector:@selector(onJavaScriptLoaded)
81
+												 name:RCTJavaScriptDidLoadNotification
82
+											   object:nil];
83
+	[[NSNotificationCenter defaultCenter] addObserver:self
84
+											 selector:@selector(onJavaScriptWillLoad)
85
+												 name:RCTJavaScriptWillStartLoadingNotification
86
+											   object:nil];
86
 }
87
 }
87
 
88
 
88
 -(void)resetRootViewControllerOnlyOnJSDevReload {
89
 -(void)resetRootViewControllerOnlyOnJSDevReload {

+ 0
- 1
ios/RNNBridgeModule.h View File

1
 #import <Foundation/Foundation.h>
1
 #import <Foundation/Foundation.h>
2
 #import <UIKit/UIKit.h>
2
 #import <UIKit/UIKit.h>
3
-
4
 #import <React/RCTBridgeModule.h>
3
 #import <React/RCTBridgeModule.h>
5
 
4
 
6
 #import "RNNCommandsHandler.h"
5
 #import "RNNCommandsHandler.h"

+ 10
- 12
ios/RNNBridgeModule.m View File

1
 #import "RNNBridgeModule.h"
1
 #import "RNNBridgeModule.h"
2
 
2
 
3
-@interface RNNBridgeModule ()
4
-@property RNNCommandsHandler* commandsHandler;
5
-@end
6
-
7
-@implementation RNNBridgeModule
3
+@implementation RNNBridgeModule {
4
+	RNNCommandsHandler* _commandsHandler;
5
+}
8
 
6
 
9
 RCT_EXPORT_MODULE();
7
 RCT_EXPORT_MODULE();
10
 
8
 
14
 
12
 
15
 -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler {
13
 -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler {
16
 	self = [super init];
14
 	self = [super init];
17
-	self.commandsHandler = commandsHandler;
15
+	_commandsHandler = commandsHandler;
18
 	return self;
16
 	return self;
19
 }
17
 }
20
 
18
 
21
 #pragma mark - JS interface
19
 #pragma mark - JS interface
22
 
20
 
23
 RCT_EXPORT_METHOD(setRoot:(NSDictionary*)layout) {
21
 RCT_EXPORT_METHOD(setRoot:(NSDictionary*)layout) {
24
-	[self.commandsHandler setRoot:layout];
22
+	[_commandsHandler setRoot:layout];
25
 }
23
 }
26
 
24
 
27
 RCT_EXPORT_METHOD(push:(NSString*)containerId layout:(NSDictionary*)layout) {
25
 RCT_EXPORT_METHOD(push:(NSString*)containerId layout:(NSDictionary*)layout) {
28
-	[self.commandsHandler push:containerId layout:layout];
26
+	[_commandsHandler push:containerId layout:layout];
29
 }
27
 }
30
 
28
 
31
 RCT_EXPORT_METHOD(pop:(NSString*)containerId) {
29
 RCT_EXPORT_METHOD(pop:(NSString*)containerId) {
32
-	[self.commandsHandler pop:containerId];
30
+	[_commandsHandler pop:containerId];
33
 }
31
 }
34
 
32
 
35
 RCT_EXPORT_METHOD(showModal:(NSDictionary*)layout) {
33
 RCT_EXPORT_METHOD(showModal:(NSDictionary*)layout) {
36
-	[self.commandsHandler showModal:layout];
34
+	[_commandsHandler showModal:layout];
37
 }
35
 }
38
 
36
 
39
 RCT_EXPORT_METHOD(dismissModal:(NSString*)containerId) {
37
 RCT_EXPORT_METHOD(dismissModal:(NSString*)containerId) {
40
-	[self.commandsHandler dismissModal:containerId];
38
+	[_commandsHandler dismissModal:containerId];
41
 }
39
 }
42
 
40
 
43
 RCT_EXPORT_METHOD(dismissAllModals) {
41
 RCT_EXPORT_METHOD(dismissAllModals) {
44
-	[self.commandsHandler dismissAllModals];
42
+	[_commandsHandler dismissAllModals];
45
 }
43
 }
46
 
44
 
47
 @end
45
 @end

+ 18
- 20
ios/RNNCommandsHandler.m View File

4
 #import "RNNModalManager.h"
4
 #import "RNNModalManager.h"
5
 #import "RNNNavigationStackManager.h"
5
 #import "RNNNavigationStackManager.h"
6
 
6
 
7
-@interface RNNCommandsHandler ()
8
-@property RNNControllerFactory *controllerFactory;
9
-@property RNNStore *store;
10
-@end
11
-
12
-@implementation RNNCommandsHandler
7
+@implementation RNNCommandsHandler {
8
+	RNNControllerFactory *_controllerFactory;
9
+	RNNStore *_store;
10
+}
13
 
11
 
14
 -(instancetype) initWithStore:(RNNStore*)store controllerFactory:(RNNControllerFactory*)controllerFactory {
12
 -(instancetype) initWithStore:(RNNStore*)store controllerFactory:(RNNControllerFactory*)controllerFactory {
15
 	self = [super init];
13
 	self = [super init];
16
-	self.store = store;
17
-	self.controllerFactory = controllerFactory;
14
+	_store = store;
15
+	_controllerFactory = controllerFactory;
18
 	return self;
16
 	return self;
19
 }
17
 }
20
 
18
 
22
 
20
 
23
 -(void) setRoot:(NSDictionary*)layout {
21
 -(void) setRoot:(NSDictionary*)layout {
24
 	[self assertReady];
22
 	[self assertReady];
25
-	UIViewController *vc = [self.controllerFactory createLayoutAndSaveToStore:layout];
23
+	UIViewController *vc = [_controllerFactory createLayoutAndSaveToStore:layout];
26
 	
24
 	
27
 	UIApplication.sharedApplication.delegate.window.rootViewController = vc;
25
 	UIApplication.sharedApplication.delegate.window.rootViewController = vc;
28
 	[UIApplication.sharedApplication.delegate.window makeKeyAndVisible];
26
 	[UIApplication.sharedApplication.delegate.window makeKeyAndVisible];
31
 -(void) push:(NSString*)containerId layout:(NSDictionary*)layout {
29
 -(void) push:(NSString*)containerId layout:(NSDictionary*)layout {
32
 	[self assertReady];
30
 	[self assertReady];
33
 	
31
 	
34
-	UIViewController *newVc = [self.controllerFactory createLayoutAndSaveToStore:layout];
32
+	UIViewController *newVc = [_controllerFactory createLayoutAndSaveToStore:layout];
35
 	
33
 	
36
 	// find on who to push
34
 	// find on who to push
37
-	UIViewController *vc = [self.store findContainerForId:containerId];
35
+	UIViewController *vc = [_store findContainerForId:containerId];
38
 	
36
 	
39
 	// do the actual pushing
37
 	// do the actual pushing
40
-	[[[RNNNavigationStackManager alloc] initWithStore:self.store] push:newVc onTop:vc animated:YES];
38
+	[[[RNNNavigationStackManager alloc] initWithStore:_store] push:newVc onTop:vc animated:YES];
41
 }
39
 }
42
 
40
 
43
 -(void) pop:(NSString*)containerId {
41
 -(void) pop:(NSString*)containerId {
44
 	[self assertReady];
42
 	[self assertReady];
45
 	
43
 	
46
 	// find who to pop
44
 	// find who to pop
47
-	UIViewController *vc = [self.store findContainerForId:containerId];
45
+	UIViewController *vc = [_store findContainerForId:containerId];
48
 	
46
 	
49
 	// do the popping
47
 	// do the popping
50
-	[[[RNNNavigationStackManager alloc] initWithStore:self.store] pop:vc animated:YES];
51
-	[self.store removeContainer:containerId];
48
+	[[[RNNNavigationStackManager alloc] initWithStore:_store] pop:vc animated:YES];
49
+	[_store removeContainer:containerId];
52
 }
50
 }
53
 
51
 
54
 -(void) showModal:(NSDictionary*)layout {
52
 -(void) showModal:(NSDictionary*)layout {
55
 	[self assertReady];
53
 	[self assertReady];
56
 	
54
 	
57
-	UIViewController *newVc = [self.controllerFactory createLayoutAndSaveToStore:layout];
58
-	[[[RNNModalManager alloc] initWithStore:self.store] showModal:newVc];
55
+	UIViewController *newVc = [_controllerFactory createLayoutAndSaveToStore:layout];
56
+	[[[RNNModalManager alloc] initWithStore:_store] showModal:newVc];
59
 }
57
 }
60
 
58
 
61
 -(void) dismissModal:(NSString*)containerId {
59
 -(void) dismissModal:(NSString*)containerId {
62
 	[self assertReady];
60
 	[self assertReady];
63
-	[[[RNNModalManager alloc] initWithStore:self.store] dismissModal:containerId];
61
+	[[[RNNModalManager alloc] initWithStore:_store] dismissModal:containerId];
64
 }
62
 }
65
 
63
 
66
 -(void) dismissAllModals {
64
 -(void) dismissAllModals {
67
 	[self assertReady];
65
 	[self assertReady];
68
-	[[[RNNModalManager alloc] initWithStore:self.store] dismissAllModals];
66
+	[[[RNNModalManager alloc] initWithStore:_store] dismissAllModals];
69
 }
67
 }
70
 
68
 
71
 #pragma mark - private
69
 #pragma mark - private
72
 
70
 
73
 -(void) assertReady {
71
 -(void) assertReady {
74
-	if (!self.store.isReadyToReceiveCommands) {
72
+	if (!_store.isReadyToReceiveCommands) {
75
 		@throw [NSException exceptionWithName:@"BridgeNotLoadedError" reason:@"Bridge not yet loaded! Send commands after Navigation.events().onAppLaunched() has been called." userInfo:nil];
73
 		@throw [NSException exceptionWithName:@"BridgeNotLoadedError" reason:@"Bridge not yet loaded! Send commands after Navigation.events().onAppLaunched() has been called." userInfo:nil];
76
 	}
74
 	}
77
 }
75
 }

+ 4
- 4
ios/RNNControllerFactory.h View File

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 "RNNRootViewController.h"
6
-#import "RNNSideMenuController.h"
7
-#import "RNNSideMenuChildVC.h"
8
 #import "RNNStore.h"
5
 #import "RNNStore.h"
6
+#import "RNNEventEmitter.h"
9
 
7
 
10
 @interface RNNControllerFactory : NSObject
8
 @interface RNNControllerFactory : NSObject
11
 
9
 
12
--(instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator store:(RNNStore*)store;
10
+-(instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator
11
+								 store:(RNNStore*)store
12
+						  eventEmitter:(RNNEventEmitter*)eventEmitter;
13
 
13
 
14
 -(UIViewController*)createLayoutAndSaveToStore:(NSDictionary*)layout;
14
 -(UIViewController*)createLayoutAndSaveToStore:(NSDictionary*)layout;
15
 
15
 

+ 16
- 14
ios/RNNControllerFactory.m View File

1
 
1
 
2
 #import "RNNControllerFactory.h"
2
 #import "RNNControllerFactory.h"
3
 #import "RNNLayoutNode.h"
3
 #import "RNNLayoutNode.h"
4
+#import "RNNRootViewController.h"
5
+#import "RNNSideMenuController.h"
6
+#import "RNNSideMenuChildVC.h"
4
 
7
 
5
 
8
 
6
-
7
-@interface RNNControllerFactory ()
8
-
9
-@property (nonatomic, strong) id<RNNRootViewCreator> creator;
10
-@property (nonatomic, strong) RNNStore *store;
11
-
12
-@end
13
-
14
-@implementation RNNControllerFactory
9
+@implementation RNNControllerFactory {
10
+	id<RNNRootViewCreator> _creator;
11
+	RNNStore *_store;
12
+	RNNEventEmitter *_eventEmitter;
13
+}
15
 
14
 
16
 # pragma mark public
15
 # pragma mark public
17
 
16
 
18
 
17
 
19
-- (instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator store:(RNNStore *)store {
18
+- (instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator
19
+								  store:(RNNStore *)store
20
+						   eventEmitter:(RNNEventEmitter*)eventEmitter {
20
 	
21
 	
21
 	self = [super init];
22
 	self = [super init];
22
-	self.creator = creator;
23
-	self.store = store;
23
+	_creator = creator;
24
+	_store = store;
25
+	_eventEmitter = eventEmitter;
24
 	
26
 	
25
 	return self;
27
 	return self;
26
 }
28
 }
67
 		@throw [NSException exceptionWithName:@"UnknownControllerType" reason:[@"Unknown controller type " stringByAppendingString:node.type] userInfo:nil];
69
 		@throw [NSException exceptionWithName:@"UnknownControllerType" reason:[@"Unknown controller type " stringByAppendingString:node.type] userInfo:nil];
68
 	}
70
 	}
69
 
71
 
70
-	[self.store setContainer:result containerId:node.nodeId];
72
+	[_store setContainer:result containerId:node.nodeId];
71
 	
73
 	
72
 	return result;
74
 	return result;
73
 }
75
 }
74
 
76
 
75
 - (RNNRootViewController*)createContainer:(RNNLayoutNode*)node {
77
 - (RNNRootViewController*)createContainer:(RNNLayoutNode*)node {
76
-	return [[RNNRootViewController alloc] initWithNode:node rootViewCreator:self.creator];
78
+	return [[RNNRootViewController alloc] initWithNode:node rootViewCreator:_creator eventEmitter:_eventEmitter];
77
 }
79
 }
78
 
80
 
79
 - (UINavigationController*)createContainerStack:(RNNLayoutNode*)node {
81
 - (UINavigationController*)createContainerStack:(RNNLayoutNode*)node {

+ 0
- 2
ios/RNNEventEmitter.h View File

6
 
6
 
7
 @interface RNNEventEmitter : RCTEventEmitter <RCTBridgeModule>
7
 @interface RNNEventEmitter : RCTEventEmitter <RCTBridgeModule>
8
 
8
 
9
--(instancetype)initWithBridge:(RCTBridge*)bridge;
10
-
11
 -(void)sendOnAppLaunched;
9
 -(void)sendOnAppLaunched;
12
 
10
 
13
 -(void)sendContainerStart:(NSString*)containerId;
11
 -(void)sendContainerStart:(NSString*)containerId;

+ 7
- 21
ios/RNNEventEmitter.m View File

1
 #import "RNNEventEmitter.h"
1
 #import "RNNEventEmitter.h"
2
 
2
 
3
-@implementation RNNEventEmitter {
4
-	RCTBridge *_bridge;
5
-}
3
+@implementation RNNEventEmitter
6
 
4
 
7
 RCT_EXPORT_MODULE();
5
 RCT_EXPORT_MODULE();
8
 
6
 
10
 static NSString* const containerStart	= @"RNN.containerStart";
8
 static NSString* const containerStart	= @"RNN.containerStart";
11
 static NSString* const containerStop	= @"RNN.containerStop";
9
 static NSString* const containerStop	= @"RNN.containerStop";
12
 
10
 
13
--(instancetype)initWithBridge:(RCTBridge*)bridge {
14
-	self = [super init];
15
-	
16
-	_bridge = bridge;
17
-	
18
-	return self;
19
-}
20
 
11
 
21
--(NSArray<NSString *> *)supportedEvents
22
-{
12
+-(NSArray<NSString *> *)supportedEvents {
23
 	return @[onAppLaunched, containerStart, containerStop];
13
 	return @[onAppLaunched, containerStart, containerStop];
24
 }
14
 }
25
 
15
 
26
 # pragma mark public
16
 # pragma mark public
27
 
17
 
28
--(void)sendOnAppLaunched
29
-{
18
+-(void)sendOnAppLaunched {
30
 	[self send:onAppLaunched body:nil];
19
 	[self send:onAppLaunched body:nil];
31
 }
20
 }
32
 
21
 
33
--(void)sendContainerStart:(NSString *)containerId
34
-{
22
+-(void)sendContainerStart:(NSString *)containerId {
35
 	[self send:containerStart body:containerId];
23
 	[self send:containerStart body:containerId];
36
 }
24
 }
37
 
25
 
38
--(void)sendContainerStop:(NSString *)containerId
39
-{
26
+-(void)sendContainerStop:(NSString *)containerId {
40
 	[self send:containerStop body:containerId];
27
 	[self send:containerStop body:containerId];
41
 }
28
 }
42
 
29
 
43
 # pragma mark private
30
 # pragma mark private
44
 
31
 
45
--(void)send:(NSString *)eventName body:(id)body
46
-{
47
-	[[_bridge moduleForClass:[RNNEventEmitter class]] sendEventWithName:eventName body:body];
32
+-(void)send:(NSString *)eventName body:(id)body {
33
+	[self sendEventWithName:eventName body:body];
48
 }
34
 }
49
 
35
 
50
 @end
36
 @end

+ 9
- 13
ios/RNNModalManager.m View File

1
 #import "RNNModalManager.h"
1
 #import "RNNModalManager.h"
2
 
2
 
3
-@interface RNNModalManager ()
4
-
5
-@property RNNStore *store;
6
-
7
-@end
8
-
9
-@implementation RNNModalManager
3
+@implementation RNNModalManager {
4
+	RNNStore *_store;
5
+}
10
 
6
 
11
 
7
 
12
 -(instancetype)initWithStore:(RNNStore*)store {
8
 -(instancetype)initWithStore:(RNNStore*)store {
13
 	self = [super init];
9
 	self = [super init];
14
-	self.store = store;
10
+	_store = store;
15
 	return self;
11
 	return self;
16
 }
12
 }
17
 
13
 
21
 }
17
 }
22
 
18
 
23
 -(void)dismissModal:(NSString *)containerId {
19
 -(void)dismissModal:(NSString *)containerId {
24
-	[self.store.modalsToDismissArray addObject:containerId];
20
+	[_store.modalsToDismissArray addObject:containerId];
25
 	[self removePendingNextModalIfOnTop];
21
 	[self removePendingNextModalIfOnTop];
26
 }
22
 }
27
 
23
 
28
 -(void)dismissAllModals {
24
 -(void)dismissAllModals {
29
 	UIViewController *root = UIApplication.sharedApplication.delegate.window.rootViewController;
25
 	UIViewController *root = UIApplication.sharedApplication.delegate.window.rootViewController;
30
 	[root dismissViewControllerAnimated:YES completion:nil];
26
 	[root dismissViewControllerAnimated:YES completion:nil];
31
-	[self.store.modalsToDismissArray removeAllObjects];
27
+	[_store.modalsToDismissArray removeAllObjects];
32
 }
28
 }
33
 
29
 
34
 
30
 
36
 
32
 
37
 
33
 
38
 -(void)removePendingNextModalIfOnTop {
34
 -(void)removePendingNextModalIfOnTop {
39
-	NSString *containerId = [self.store.modalsToDismissArray lastObject];
35
+	NSString *containerId = [_store.modalsToDismissArray lastObject];
40
 	
36
 	
41
-	UIViewController *modalToDismiss = [self.store findContainerForId:containerId];
37
+	UIViewController *modalToDismiss = [_store findContainerForId:containerId];
42
 	
38
 	
43
 	if(!modalToDismiss) {
39
 	if(!modalToDismiss) {
44
 		return;
40
 		return;
46
 	
42
 	
47
 	if (modalToDismiss == [self topPresentedVC]) {
43
 	if (modalToDismiss == [self topPresentedVC]) {
48
 		[modalToDismiss dismissViewControllerAnimated:YES completion:^{
44
 		[modalToDismiss dismissViewControllerAnimated:YES completion:^{
49
-			[self.store.modalsToDismissArray removeObject:containerId];
45
+			[_store.modalsToDismissArray removeObject:containerId];
50
 			[self removePendingNextModalIfOnTop];
46
 			[self removePendingNextModalIfOnTop];
51
 		}];
47
 		}];
52
 	}
48
 	}

+ 4
- 9
ios/RNNNavigationStackManager.m View File

1
 #import "RNNNavigationStackManager.h"
1
 #import "RNNNavigationStackManager.h"
2
 
2
 
3
-@interface RNNNavigationStackManager ()
4
-
5
-@property RNNStore *store;
6
-
7
-@end
8
-
9
-
10
-@implementation RNNNavigationStackManager
3
+@implementation RNNNavigationStackManager {
4
+	RNNStore *_store;
5
+}
11
 
6
 
12
 
7
 
13
 -(instancetype)initWithStore:(RNNStore*)store {
8
 -(instancetype)initWithStore:(RNNStore*)store {
14
 	self = [super init];
9
 	self = [super init];
15
-	self.store = store;
10
+	_store = store;
16
 	return self;
11
 	return self;
17
 }
12
 }
18
 
13
 

+ 2
- 0
ios/RNNReactRootViewCreator.h View File

5
 
5
 
6
 @interface RNNReactRootViewCreator : NSObject <RNNRootViewCreator>
6
 @interface RNNReactRootViewCreator : NSObject <RNNRootViewCreator>
7
 
7
 
8
+-(instancetype)initWithBridge:(RCTBridge*)bridge;
9
+
8
 @end
10
 @end

+ 5
- 9
ios/RNNReactRootViewCreator.m View File

3
 #import "RNN.h"
3
 #import "RNN.h"
4
 #import <React/RCTRootView.h>
4
 #import <React/RCTRootView.h>
5
 
5
 
6
-@interface RNNReactRootViewCreator ()
7
-
8
-@property RCTBridge *bridge;
9
-
10
-@end
11
-
12
-@implementation RNNReactRootViewCreator
6
+@implementation RNNReactRootViewCreator {
7
+	RCTBridge *_bridge;
8
+}
13
 
9
 
14
 -(instancetype)initWithBridge:(RCTBridge*)bridge {
10
 -(instancetype)initWithBridge:(RCTBridge*)bridge {
15
 	self = [super init];
11
 	self = [super init];
16
 	
12
 	
17
-	self.bridge = bridge;
13
+	_bridge = bridge;
18
 	
14
 	
19
 	return self;
15
 	return self;
20
 	
16
 	
25
 		@throw [NSException exceptionWithName:@"MissingViewId" reason:@"Missing view id" userInfo:nil];
21
 		@throw [NSException exceptionWithName:@"MissingViewId" reason:@"Missing view id" userInfo:nil];
26
 	}
22
 	}
27
 	
23
 	
28
-	UIView *view = [[RCTRootView alloc] initWithBridge:self.bridge
24
+	UIView *view = [[RCTRootView alloc] initWithBridge:_bridge
29
 										 moduleName:name
25
 										 moduleName:name
30
 								  initialProperties:@{@"id": rootViewId}];
26
 								  initialProperties:@{@"id": rootViewId}];
31
 	return view;
27
 	return view;

+ 2
- 3
ios/RNNStore.h View File

2
 #import <Foundation/Foundation.h>
2
 #import <Foundation/Foundation.h>
3
 #import <UIKit/UIKit.h>
3
 #import <UIKit/UIKit.h>
4
 
4
 
5
-
6
 @interface RNNStore : NSObject
5
 @interface RNNStore : NSObject
7
 
6
 
8
-@property NSMutableArray *modalsToDismissArray;
9
-@property BOOL isReadyToReceiveCommands;
7
+@property (nonatomic, strong) NSMutableArray *modalsToDismissArray;
8
+@property (atomic) BOOL isReadyToReceiveCommands;
10
 
9
 
11
 - (UIViewController*)findContainerForId:(NSString*)containerId;
10
 - (UIViewController*)findContainerForId:(NSString*)containerId;
12
 - (void)setContainer:(UIViewController*)viewController containerId:(NSString*)containerId;
11
 - (void)setContainer:(UIViewController*)viewController containerId:(NSString*)containerId;

+ 7
- 9
ios/RNNStore.m View File

3
 
3
 
4
 @interface RNNStore ()
4
 @interface RNNStore ()
5
 
5
 
6
-@property NSMapTable *containerStore;
7
-
8
 @end
6
 @end
9
 
7
 
10
-@implementation RNNStore
11
-
8
+@implementation RNNStore {
9
+	NSMapTable* _containerStore;
10
+}
12
 
11
 
13
 -(instancetype)init {
12
 -(instancetype)init {
14
 	self = [super init];
13
 	self = [super init];
15
-	self.containerStore = [NSMapTable strongToWeakObjectsMapTable];
14
+	_containerStore = [NSMapTable strongToWeakObjectsMapTable];
16
 	self.modalsToDismissArray = [NSMutableArray new];
15
 	self.modalsToDismissArray = [NSMutableArray new];
17
 	return self;
16
 	return self;
18
 }
17
 }
19
 
18
 
20
-
21
 -(UIViewController *)findContainerForId:(NSString *)containerId {
19
 -(UIViewController *)findContainerForId:(NSString *)containerId {
22
-	return [self.containerStore objectForKey:containerId];
20
+	return [_containerStore objectForKey:containerId];
23
 }
21
 }
24
 
22
 
25
 - (void)setContainer:(UIViewController*)viewController containerId:(NSString*)containerId {
23
 - (void)setContainer:(UIViewController*)viewController containerId:(NSString*)containerId {
28
 		@throw [NSException exceptionWithName:@"MultipleContainerId" reason:[@"Container id already exists " stringByAppendingString:containerId] userInfo:nil];
26
 		@throw [NSException exceptionWithName:@"MultipleContainerId" reason:[@"Container id already exists " stringByAppendingString:containerId] userInfo:nil];
29
 	}
27
 	}
30
 	
28
 	
31
-	[self.containerStore setObject:viewController forKey:containerId];
29
+	[_containerStore setObject:viewController forKey:containerId];
32
 }
30
 }
33
 
31
 
34
 - (void)removeContainer:(NSString*)containerId {
32
 - (void)removeContainer:(NSString*)containerId {
35
-	[self.containerStore removeObjectForKey:containerId];
33
+	[_containerStore removeObjectForKey:containerId];
36
 }
34
 }
37
 
35
 
38
 
36
 

+ 4
- 8
playground/ios/playgroundTests/RNNControllerFactoryTest.m View File

1
-//
2
-//  RNNControllerFactoryTest.m
3
-//  playground
4
-//
5
-//  Created by Ran Greenberg on 08/02/2017.
6
-//  Copyright © 2017 Wix. All rights reserved.
7
-//
8
 
1
 
9
 #import <XCTest/XCTest.h>
2
 #import <XCTest/XCTest.h>
10
 #import "RNNControllerFactory.h"
3
 #import "RNNControllerFactory.h"
4
+#import "RNNRootViewController.h"
5
+#import "RNNSideMenuController.h"
6
+#import "RNNSideMenuChildVC.h"
11
 
7
 
12
 
8
 
13
 @interface RNNControllerFactoryTest : XCTestCase
9
 @interface RNNControllerFactoryTest : XCTestCase
24
 	[super setUp];
20
 	[super setUp];
25
 	self.creator = nil;
21
 	self.creator = nil;
26
 	self.store = [RNNStore new];
22
 	self.store = [RNNStore new];
27
-	self.factory = [[RNNControllerFactory alloc] initWithRootViewCreator:self.creator store:self.store];
23
+	self.factory = [[RNNControllerFactory alloc] initWithRootViewCreator:self.creator store:self.store eventEmitter:nil];
28
 }
24
 }
29
 
25
 
30
 - (void)tearDown {
26
 - (void)tearDown {