Browse Source

pass bridge to external component creator

yogevbd 6 years ago
parent
commit
29bf1b6ed7

+ 1
- 1
lib/ios/RNNControllerFactory.m View File

106
 	NSString* name = node.data[@"name"];
106
 	NSString* name = node.data[@"name"];
107
 	NSDictionary* props = node.data[@"passProps"];
107
 	NSDictionary* props = node.data[@"passProps"];
108
 	
108
 	
109
-	UIViewController* externalVC = [_store getExternalComponent:name props:props];
109
+	UIViewController* externalVC = [_store getExternalComponent:name props:props bridge:_bridge];
110
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:_defaultOptionsDict];
110
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:_defaultOptionsDict];
111
 	[options mergeWith:node.data[@"options"]];
111
 	[options mergeWith:node.data[@"options"]];
112
 	
112
 	

+ 1
- 1
lib/ios/RNNStore.h View File

14
 -(void) removeComponentByViewControllerInstance:(UIViewController*)componentInstance;
14
 -(void) removeComponentByViewControllerInstance:(UIViewController*)componentInstance;
15
 
15
 
16
 - (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
16
 - (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
17
-- (UIViewController *)getExternalComponent:(NSString *)name props:(NSDictionary*)props;
17
+- (UIViewController *)getExternalComponent:(NSString *)name props:(NSDictionary*)props bridge:(RCTBridge*)bridge;
18
 
18
 
19
 -(NSString*)componentKeyForInstance:(UIViewController*)instance;
19
 -(NSString*)componentKeyForInstance:(UIViewController*)instance;
20
 
20
 

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

77
 	[_externalComponentCreators setObject:[callback copy] forKey:name];
77
 	[_externalComponentCreators setObject:[callback copy] forKey:name];
78
 }
78
 }
79
 
79
 
80
-- (UIViewController *)getExternalComponent:(NSString *)name props:(NSDictionary*)props {
80
+- (UIViewController *)getExternalComponent:(NSString *)name props:(NSDictionary*)props bridge:(RCTBridge *)bridge {
81
 	RNNExternalViewCreator creator = [_externalComponentCreators objectForKey:name];
81
 	RNNExternalViewCreator creator = [_externalComponentCreators objectForKey:name];
82
-	return creator(props);
82
+	return creator(props, bridge);
83
 }
83
 }
84
 
84
 
85
 @end
85
 @end

+ 2
- 1
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
 
4
 
4
-typedef UIViewController * (^RNNExternalViewCreator)(NSDictionary* props);
5
+typedef UIViewController * (^RNNExternalViewCreator)(NSDictionary* props, RCTBridge* bridge);
5
 
6
 
6
 @interface ReactNativeNavigation : NSObject
7
 @interface ReactNativeNavigation : NSObject
7
 
8
 

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

1
 #import "ReactNativeNavigation.h"
1
 #import "ReactNativeNavigation.h"
2
 
2
 
3
-#import <React/RCTBridge.h>
4
 #import <React/RCTUIManager.h>
3
 #import <React/RCTUIManager.h>
5
 
4
 
6
 #import "RNNBridgeManager.h"
5
 #import "RNNBridgeManager.h"

+ 1
- 1
playground/ios/playground/AppDelegate.m View File

22
 	NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
22
 	NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
23
 	[ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];
23
 	[ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];
24
 	
24
 	
25
-	[ReactNativeNavigation registerExternalComponent:@"RNNCustomComponent" callback:^UIViewController *(NSDictionary *props) {
25
+	[ReactNativeNavigation registerExternalComponent:@"RNNCustomComponent" callback:^UIViewController *(NSDictionary *props, RCTBridge *bridge) {
26
 		return [[RNNCustomViewController alloc] initWithProps:props];
26
 		return [[RNNCustomViewController alloc] initWithProps:props];
27
 	}];
27
 	}];
28
 	
28