react-native-navigation的迁移库

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