react-native-navigation的迁移库

RNNReactRootViewCreator.m 1.2KB

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