Browse Source

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 years ago
parent
commit
b843aaebb6

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

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

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

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

13
 
13
 
14
 + (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
14
 + (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
15
 
15
 
16
++ (UIViewController *)findViewController:(NSString *)componentId;
17
+
16
 + (RCTBridge *)getBridge;
18
 + (RCTBridge *)getBridge;
17
 
19
 
18
 @end
20
 @end

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

31
 	return [[ReactNativeNavigation sharedInstance].bridgeManager bridge];
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
 # pragma mark - instance
39
 # pragma mark - instance
36
 
40
 

+ 1
- 1
lib/src/Navigation.ts View File

15
 import { ComponentType } from 'react';
15
 import { ComponentType } from 'react';
16
 
16
 
17
 export class Navigation {
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
   public readonly store: Store;
19
   public readonly store: Store;
20
   private readonly nativeEventsReceiver: NativeEventsReceiver;
20
   private readonly nativeEventsReceiver: NativeEventsReceiver;
21
   private readonly uniqueIdProvider: UniqueIdProvider;
21
   private readonly uniqueIdProvider: UniqueIdProvider;

+ 1
- 1
lib/src/adapters/Element.tsx View File

4
 
4
 
5
 let RNNElement: React.ComponentType<any>;
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
   static propTypes = {
8
   static propTypes = {
9
     elementId: PropTypes.string.isRequired,
9
     elementId: PropTypes.string.isRequired,
10
     resizeMode: PropTypes.string
10
     resizeMode: PropTypes.string