react-native-navigation的迁移库

RNNReactRootViewCreator.m 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 availableSize:(CGSize)availableSize 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. availableSize:availableSize
  19. reactViewReadyBlock:reactViewReadyBlock];
  20. return view;
  21. }
  22. - (UIView*)createRootViewFromComponentOptions:(RNNComponentOptions*)componentOptions {
  23. return [self createRootView:componentOptions.name.get rootViewId:componentOptions.componentId.get availableSize:CGSizeZero reactViewReadyBlock:nil];
  24. }
  25. - (UIView*)createRootViewFromComponentOptions:(RNNComponentOptions*)componentOptions reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
  26. return [self createRootView:componentOptions.name.get rootViewId:componentOptions.componentId.get availableSize:CGSizeZero reactViewReadyBlock:reactViewReadyBlock];
  27. }
  28. @end