Yogev B 6 years ago
parent
commit
e6a43036fc
No account linked to committer's email address

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

1
 #import <Foundation/Foundation.h>
1
 #import <Foundation/Foundation.h>
2
 #import <React/RCTBridge.h>
2
 #import <React/RCTBridge.h>
3
-#import "ReactNativeNavigation.h"
3
+#import "RNNBridgeManagerDelegate.h"
4
+
5
+typedef UIViewController * (^RNNExternalViewCreator)(NSDictionary* props, RCTBridge* bridge);
4
 
6
 
5
 @interface RNNBridgeManager : NSObject <RCTBridgeDelegate>
7
 @interface RNNBridgeManager : NSObject <RCTBridgeDelegate>
6
 
8
 
7
-- (instancetype)initWithJsCodeLocation:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions;
9
+- (instancetype)initWithJsCodeLocation:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions bridgeManagerDelegate:(id<RNNBridgeManagerDelegate>)delegate;
8
 
10
 
9
 - (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
11
 - (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
10
 
12
 

+ 12
- 2
lib/ios/RNNBridgeManager.m View File

18
 @implementation RNNBridgeManager {
18
 @implementation RNNBridgeManager {
19
 	NSURL* _jsCodeLocation;
19
 	NSURL* _jsCodeLocation;
20
 	NSDictionary* _launchOptions;
20
 	NSDictionary* _launchOptions;
21
+	id<RNNBridgeManagerDelegate> _delegate;
21
 	RCTBridge* _bridge;
22
 	RCTBridge* _bridge;
22
 
23
 
23
 	RNNStore* _store;
24
 	RNNStore* _store;
25
 	RNNCommandsHandler* _commandsHandler;
26
 	RNNCommandsHandler* _commandsHandler;
26
 }
27
 }
27
 
28
 
28
-- (instancetype)initWithJsCodeLocation:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions {
29
+- (instancetype)initWithJsCodeLocation:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions bridgeManagerDelegate:(id<RNNBridgeManagerDelegate>)delegate {
29
 	if (self = [super init]) {
30
 	if (self = [super init]) {
30
 		_jsCodeLocation = jsCodeLocation;
31
 		_jsCodeLocation = jsCodeLocation;
31
 		_launchOptions = launchOptions;
32
 		_launchOptions = launchOptions;
33
+		_delegate = delegate;
32
 		
34
 		
33
 		_store = [RNNStore new];
35
 		_store = [RNNStore new];
34
 		_bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:_launchOptions];
36
 		_bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:_launchOptions];
53
 	[_store registerExternalComponent:name callback:callback];
55
 	[_store registerExternalComponent:name callback:callback];
54
 }
56
 }
55
 
57
 
58
+- (NSArray *)extraModulesFromDelegate {
59
+	if ([_delegate respondsToSelector:@selector(extraModulesForBridge:)]) {
60
+		return [_delegate extraModulesForBridge:_bridge];
61
+	}
62
+	
63
+	return nil;
64
+}
65
+
56
 # pragma mark - RCTBridgeDelegate
66
 # pragma mark - RCTBridgeDelegate
57
 
67
 
58
 - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
68
 - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
67
 	_commandsHandler = [[RNNCommandsHandler alloc] initWithStore:_store controllerFactory:controllerFactory eventEmitter:eventEmitter];
77
 	_commandsHandler = [[RNNCommandsHandler alloc] initWithStore:_store controllerFactory:controllerFactory eventEmitter:eventEmitter];
68
 	RNNBridgeModule *bridgeModule = [[RNNBridgeModule alloc] initWithCommandsHandler:_commandsHandler];
78
 	RNNBridgeModule *bridgeModule = [[RNNBridgeModule alloc] initWithCommandsHandler:_commandsHandler];
69
 
79
 
70
-	return @[bridgeModule,eventEmitter];
80
+	return [@[bridgeModule,eventEmitter] arrayByAddingObjectsFromArray:[self extraModulesFromDelegate]];
71
 }
81
 }
72
 
82
 
73
 # pragma mark - JavaScript & Bridge Notifications
83
 # pragma mark - JavaScript & Bridge Notifications

+ 5
- 0
lib/ios/RNNBridgeManagerDelegate.h View File

1
+@protocol RNNBridgeManagerDelegate <NSObject>
2
+
3
+- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge;
4
+
5
+@end

+ 3
- 0
lib/ios/ReactNativeNavigation.h View File

1
 #import <Foundation/Foundation.h>
1
 #import <Foundation/Foundation.h>
2
 #import <UIKit/UIKit.h>
2
 #import <UIKit/UIKit.h>
3
 #import <React/RCTBridge.h>
3
 #import <React/RCTBridge.h>
4
+#import "RNNBridgeManagerDelegate.h"
4
 
5
 
5
 typedef UIViewController * (^RNNExternalViewCreator)(NSDictionary* props, RCTBridge* bridge);
6
 typedef UIViewController * (^RNNExternalViewCreator)(NSDictionary* props, RCTBridge* bridge);
6
 
7
 
8
 
9
 
9
 + (void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions;
10
 + (void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions;
10
 
11
 
12
++ (void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions bridgeManagerDelegate:(id<RNNBridgeManagerDelegate>)delegate;
13
+
11
 + (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
14
 + (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
12
 
15
 
13
 + (RCTBridge *)getBridge;
16
 + (RCTBridge *)getBridge;

+ 9
- 1
lib/ios/ReactNativeNavigation.m View File

19
 	[[ReactNativeNavigation sharedInstance] bootstrap:jsCodeLocation launchOptions:launchOptions];
19
 	[[ReactNativeNavigation sharedInstance] bootstrap:jsCodeLocation launchOptions:launchOptions];
20
 }
20
 }
21
 
21
 
22
++(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions bridgeManagerDelegate:(id<RNNBridgeManagerDelegate>)delegate {
23
+	[[ReactNativeNavigation sharedInstance] bootstrap:jsCodeLocation launchOptions:launchOptions bridgeManagerDelegate:delegate];
24
+}
25
+
22
 + (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback {
26
 + (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback {
23
 	[[ReactNativeNavigation sharedInstance].bridgeManager registerExternalComponent:name callback:callback];
27
 	[[ReactNativeNavigation sharedInstance].bridgeManager registerExternalComponent:name callback:callback];
24
 }
28
 }
43
 }
47
 }
44
 
48
 
45
 -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions {
49
 -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions {
46
-	self.bridgeManager = [[RNNBridgeManager alloc] initWithJsCodeLocation:jsCodeLocation launchOptions:launchOptions];
50
+	[self bootstrap:jsCodeLocation launchOptions:launchOptions bridgeManagerDelegate:nil];
51
+}
52
+
53
+-(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions bridgeManagerDelegate:(id<RNNBridgeManagerDelegate>)delegate {
54
+	self.bridgeManager = [[RNNBridgeManager alloc] initWithJsCodeLocation:jsCodeLocation launchOptions:launchOptions bridgeManagerDelegate:delegate];
47
 	[RNNSplashScreen show];
55
 	[RNNSplashScreen show];
48
 }
56
 }
49
 
57
 

+ 4
- 0
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj View File

65
 		5016E8F020209690009D4F7C /* RNNCustomTitleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5016E8EE2020968F009D4F7C /* RNNCustomTitleView.m */; };
65
 		5016E8F020209690009D4F7C /* RNNCustomTitleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5016E8EE2020968F009D4F7C /* RNNCustomTitleView.m */; };
66
 		50175CD1207A2AA1004FE91B /* RNNComponentOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 50175CCF207A2AA1004FE91B /* RNNComponentOptions.h */; };
66
 		50175CD1207A2AA1004FE91B /* RNNComponentOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 50175CCF207A2AA1004FE91B /* RNNComponentOptions.h */; };
67
 		50175CD2207A2AA1004FE91B /* RNNComponentOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50175CD0207A2AA1004FE91B /* RNNComponentOptions.m */; };
67
 		50175CD2207A2AA1004FE91B /* RNNComponentOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50175CD0207A2AA1004FE91B /* RNNComponentOptions.m */; };
68
+		502CB43A20CBCA180019B2FE /* RNNBridgeManagerDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 502CB43920CBCA140019B2FE /* RNNBridgeManagerDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
68
 		50415CBA20553B8E00BB682E /* RNNScreenTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 50415CB820553B8E00BB682E /* RNNScreenTransition.h */; };
69
 		50415CBA20553B8E00BB682E /* RNNScreenTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 50415CB820553B8E00BB682E /* RNNScreenTransition.h */; };
69
 		50415CBB20553B8E00BB682E /* RNNScreenTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = 50415CB920553B8E00BB682E /* RNNScreenTransition.m */; };
70
 		50415CBB20553B8E00BB682E /* RNNScreenTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = 50415CB920553B8E00BB682E /* RNNScreenTransition.m */; };
70
 		50451D052042DAEB00695F00 /* RNNPushAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 50451D032042DAEB00695F00 /* RNNPushAnimation.h */; };
71
 		50451D052042DAEB00695F00 /* RNNPushAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 50451D032042DAEB00695F00 /* RNNPushAnimation.h */; };
270
 		5016E8EE2020968F009D4F7C /* RNNCustomTitleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNCustomTitleView.m; sourceTree = "<group>"; };
271
 		5016E8EE2020968F009D4F7C /* RNNCustomTitleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNCustomTitleView.m; sourceTree = "<group>"; };
271
 		50175CCF207A2AA1004FE91B /* RNNComponentOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNComponentOptions.h; sourceTree = "<group>"; };
272
 		50175CCF207A2AA1004FE91B /* RNNComponentOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNComponentOptions.h; sourceTree = "<group>"; };
272
 		50175CD0207A2AA1004FE91B /* RNNComponentOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNComponentOptions.m; sourceTree = "<group>"; };
273
 		50175CD0207A2AA1004FE91B /* RNNComponentOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNComponentOptions.m; sourceTree = "<group>"; };
274
+		502CB43920CBCA140019B2FE /* RNNBridgeManagerDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNBridgeManagerDelegate.h; sourceTree = "<group>"; };
273
 		50415CB820553B8E00BB682E /* RNNScreenTransition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNScreenTransition.h; sourceTree = "<group>"; };
275
 		50415CB820553B8E00BB682E /* RNNScreenTransition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNScreenTransition.h; sourceTree = "<group>"; };
274
 		50415CB920553B8E00BB682E /* RNNScreenTransition.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNScreenTransition.m; sourceTree = "<group>"; };
276
 		50415CB920553B8E00BB682E /* RNNScreenTransition.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNScreenTransition.m; sourceTree = "<group>"; };
275
 		50451D032042DAEB00695F00 /* RNNPushAnimation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNPushAnimation.h; sourceTree = "<group>"; };
277
 		50451D032042DAEB00695F00 /* RNNPushAnimation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNPushAnimation.h; sourceTree = "<group>"; };
692
 				268692811E5054F800E2C612 /* RNNStore.m */,
694
 				268692811E5054F800E2C612 /* RNNStore.m */,
693
 				7B4928061E70415400555040 /* RNNCommandsHandler.h */,
695
 				7B4928061E70415400555040 /* RNNCommandsHandler.h */,
694
 				7B4928071E70415400555040 /* RNNCommandsHandler.m */,
696
 				7B4928071E70415400555040 /* RNNCommandsHandler.m */,
697
+				502CB43920CBCA140019B2FE /* RNNBridgeManagerDelegate.h */,
695
 				7BD721F31E2D3AA100724059 /* Bridge */,
698
 				7BD721F31E2D3AA100724059 /* Bridge */,
696
 				7B1E4C4B1E2D173700C3A525 /* Controllers */,
699
 				7B1E4C4B1E2D173700C3A525 /* Controllers */,
697
 				263905881E4C6F440023D7D3 /* RNNSideMenu */,
700
 				263905881E4C6F440023D7D3 /* RNNSideMenu */,
825
 				504AFE641FFE53070076E904 /* RNNOptions.h in Headers */,
828
 				504AFE641FFE53070076E904 /* RNNOptions.h in Headers */,
826
 				263905B91E4C6F440023D7D3 /* RCCDrawerController.h in Headers */,
829
 				263905B91E4C6F440023D7D3 /* RCCDrawerController.h in Headers */,
827
 				263905B31E4C6F440023D7D3 /* MMDrawerVisualState.h in Headers */,
830
 				263905B31E4C6F440023D7D3 /* MMDrawerVisualState.h in Headers */,
831
+				502CB43A20CBCA180019B2FE /* RNNBridgeManagerDelegate.h in Headers */,
828
 				50451D092042E20600695F00 /* RNNTransitionsOptions.h in Headers */,
832
 				50451D092042E20600695F00 /* RNNTransitionsOptions.h in Headers */,
829
 				5048862D20BE976D000908DE /* RNNLayoutOptions.h in Headers */,
833
 				5048862D20BE976D000908DE /* RNNLayoutOptions.h in Headers */,
830
 				E8A5CD621F49114F00E89D0D /* RNNElement.h in Headers */,
834
 				E8A5CD621F49114F00E89D0D /* RNNElement.h in Headers */,