react-native-navigation的迁移库

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #import "RNNReactView.h"
  2. #import "RCTHelpers.h"
  3. #import <React/RCTUIManager.h>
  4. @implementation RNNReactView
  5. - (instancetype)initWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initialProperties:(NSDictionary *)initialProperties reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
  6. self = [super initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
  7. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contentDidAppear:) name:RCTContentDidAppearNotification object:nil];
  8. _reactViewReadyBlock = reactViewReadyBlock;
  9. return self;
  10. }
  11. - (void)contentDidAppear:(NSNotification *)notification {
  12. #ifdef DEBUG
  13. if ([((RNNReactView *)notification.object).moduleName isEqualToString:self.moduleName]) {
  14. [RCTHelpers removeYellowBox:self];
  15. }
  16. #endif
  17. RNNReactView* appearedView = notification.object;
  18. if (_reactViewReadyBlock && [appearedView.appProperties[@"componentId"] isEqual:self.appProperties[@"componentId"]]) {
  19. _reactViewReadyBlock();
  20. _reactViewReadyBlock = nil;
  21. [[NSNotificationCenter defaultCenter] removeObserver:self];
  22. }
  23. }
  24. - (void)setRootViewDidChangeIntrinsicSize:(void (^)(CGSize))rootViewDidChangeIntrinsicSize {
  25. _rootViewDidChangeIntrinsicSize = rootViewDidChangeIntrinsicSize;
  26. self.delegate = self;
  27. }
  28. - (void)rootViewDidChangeIntrinsicSize:(RCTRootView *)rootView {
  29. if (_rootViewDidChangeIntrinsicSize) {
  30. _rootViewDidChangeIntrinsicSize(rootView.intrinsicContentSize);
  31. }
  32. }
  33. - (void)setAlignment:(NSString *)alignment {
  34. if ([alignment isEqualToString:@"fill"]) {
  35. self.sizeFlexibility = RCTRootViewSizeFlexibilityNone;
  36. } else {
  37. self.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
  38. }
  39. }
  40. @end