Explorar el Código

Expose public method to find VC (#3339)

* Provide findViewController api method

* Fix merge changes

* Optional resizeMode

* Update Element typings
Birkir Rafn Guðjónsson hace 6 años
padre
commit
b843aaebb6

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

@@ -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 Ver fichero

@@ -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 Ver fichero

@@ -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 Ver fichero

@@ -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 Ver fichero

@@ -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 Ver fichero

@@ -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