瀏覽代碼

Expose public method to find VC (#3339)

* Provide findViewController api method

* Fix merge changes

* Optional resizeMode

* Update Element typings
Birkir Rafn Guðjónsson 6 年之前
父節點
當前提交
b843aaebb6

+ 2
- 0
lib/ios/RNNBridgeManager.h 查看文件

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

+ 1
- 0
lib/ios/RNNBridgeManager.m 查看文件

@@ -12,6 +12,7 @@
12 12
 @interface RNNBridgeManager() <RCTBridgeDelegate>
13 13
 
14 14
 @property (nonatomic, strong, readwrite) RCTBridge *bridge;
15
+@property (nonatomic, strong, readwrite) RNNStore *store;
15 16
 
16 17
 @end
17 18
 

+ 2
- 0
lib/ios/ReactNativeNavigation.h 查看文件

@@ -13,6 +13,8 @@ typedef UIViewController * (^RNNExternalViewCreator)(NSDictionary* props, RCTBri
13 13
 
14 14
 + (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
15 15
 
16
++ (UIViewController *)findViewController:(NSString *)componentId;
17
+
16 18
 + (RCTBridge *)getBridge;
17 19
 
18 20
 @end

+ 4
- 0
lib/ios/ReactNativeNavigation.m 查看文件

@@ -31,6 +31,10 @@
31 31
 	return [[ReactNativeNavigation sharedInstance].bridgeManager bridge];
32 32
 }
33 33
 
34
++ (UIViewController *)findViewController:(NSString *)componentId {
35
+    RNNStore *store = [[ReactNativeNavigation sharedInstance].bridgeManager store];
36
+    return [store findComponentForId:componentId];
37
+}
34 38
 
35 39
 # pragma mark - instance
36 40
 

+ 1
- 1
lib/src/Navigation.ts 查看文件

@@ -15,7 +15,7 @@ import { Constants } from './adapters/Constants';
15 15
 import { ComponentType } from 'react';
16 16
 
17 17
 export class Navigation {
18
-  public readonly Element: React.ComponentType<{ elementId: any; resizeMode: any; }>;
18
+  public readonly Element: React.ComponentType<{ elementId: any; resizeMode?: any; }>;
19 19
   public readonly store: Store;
20 20
   private readonly nativeEventsReceiver: NativeEventsReceiver;
21 21
   private readonly uniqueIdProvider: UniqueIdProvider;

+ 1
- 1
lib/src/adapters/Element.tsx 查看文件

@@ -4,7 +4,7 @@ import { requireNativeComponent } from 'react-native';
4 4
 
5 5
 let RNNElement: React.ComponentType<any>;
6 6
 
7
-export class Element extends React.Component<{ elementId: any; resizeMode: any; }, any> {
7
+export class Element extends React.Component<{ elementId: any; resizeMode?: any; }, any> {
8 8
   static propTypes = {
9 9
     elementId: PropTypes.string.isRequired,
10 10
     resizeMode: PropTypes.string