react-native-navigation的迁移库

RNNReactRootViewCreator.m 1.2KB

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