react-native-navigation的迁移库

RNNReactRootViewCreator.m 894B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #import "RNNReactRootViewCreator.h"
  2. #import <React/RCTRootView.h>
  3. @interface RNNReactRootView : RCTRootView
  4. @end
  5. @implementation RNNReactRootView
  6. @end
  7. @implementation RNNReactRootViewCreator {
  8. RCTBridge *_bridge;
  9. }
  10. -(instancetype)initWithBridge:(RCTBridge*)bridge {
  11. self = [super init];
  12. _bridge = bridge;
  13. return self;
  14. }
  15. - (UIView*)createRootView:(NSString*)name rootViewId:(NSString*)rootViewId {
  16. if (!rootViewId) {
  17. @throw [NSException exceptionWithName:@"MissingViewId" reason:@"Missing view id" userInfo:nil];
  18. }
  19. UIView *view = [[RNNReactRootView alloc] initWithBridge:_bridge
  20. moduleName:name
  21. initialProperties:@{@"componentId": rootViewId}];
  22. return view;
  23. }
  24. -(UIView*)createRootViewFromComponentOptions:(RNNComponentOptions*)componentOptions {
  25. return [self createRootView:componentOptions.name rootViewId:componentOptions.componentId];
  26. }
  27. @end