#import "RNNReactView.h" #import "RCTHelpers.h" #import @implementation RNNReactView - (instancetype)initWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initialProperties:(NSDictionary *)initialProperties availableSize:(CGSize)availableSize reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock { self = [super initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contentDidAppear:) name:RCTContentDidAppearNotification object:nil]; _reactViewReadyBlock = reactViewReadyBlock; [bridge.uiManager setAvailableSize:availableSize forRootView:self]; return self; } - (void)contentDidAppear:(NSNotification *)notification { #ifdef DEBUG if ([((RNNReactView *)notification.object).moduleName isEqualToString:self.moduleName]) { [RCTHelpers removeYellowBox:self]; } #endif RNNReactView* appearedView = notification.object; if (_reactViewReadyBlock && [appearedView.appProperties[@"componentId"] isEqual:self.appProperties[@"componentId"]]) { _reactViewReadyBlock(); _reactViewReadyBlock = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; } } - (void)setRootViewDidChangeIntrinsicSize:(void (^)(CGSize))rootViewDidChangeIntrinsicSize { _rootViewDidChangeIntrinsicSize = rootViewDidChangeIntrinsicSize; self.delegate = self; } - (void)rootViewDidChangeIntrinsicSize:(RCTRootView *)rootView { if (_rootViewDidChangeIntrinsicSize) { _rootViewDidChangeIntrinsicSize(rootView.intrinsicContentSize); } } - (void)setAlignment:(NSString *)alignment { if ([alignment isEqualToString:@"fill"]) { self.sizeFlexibility = RCTRootViewSizeFlexibilityNone; } else { self.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight; } } @end