diff --git a/React/Base/RCTRootContentView.h b/React/Base/RCTRootContentView.h index 5092b5d3e..f405a8550 100644 --- a/React/Base/RCTRootContentView.h +++ b/React/Base/RCTRootContentView.h @@ -22,6 +22,7 @@ @property (nonatomic, readonly, strong) RCTTouchHandler *touchHandler; @property (nonatomic, assign) BOOL passThroughTouches; @property (nonatomic, assign) RCTRootViewSizeFlexibility sizeFlexibility; +@property (nonatomic, readonly) CGSize availableSize; - (instancetype)initWithFrame:(CGRect)frame bridge:(RCTBridge *)bridge diff --git a/React/Base/RCTRootContentView.m b/React/Base/RCTRootContentView.m index 995a71f70..f4fb62b53 100644 --- a/React/Base/RCTRootContentView.m +++ b/React/Base/RCTRootContentView.m @@ -72,20 +72,22 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder:(nonnull NSCoder *)aDecoder) [self setNeedsLayout]; } +- (CGSize)availableSize +{ + CGSize size = self.bounds.size; + return CGSizeMake( + _sizeFlexibility & RCTRootViewSizeFlexibilityWidth ? INFINITY : size.width, + _sizeFlexibility & RCTRootViewSizeFlexibilityHeight ? INFINITY : size.height + ); +} + - (void)updateAvailableSize { if (!self.reactTag || !_bridge.isValid) { return; } - CGSize size = self.bounds.size; - CGSize availableSize = - CGSizeMake( - _sizeFlexibility & RCTRootViewSizeFlexibilityWidth ? INFINITY : size.width, - _sizeFlexibility & RCTRootViewSizeFlexibilityHeight ? INFINITY : size.height - ); - - [_bridge.uiManager setAvailableSize:availableSize forRootView:self]; + [_bridge.uiManager setAvailableSize:self.availableSize forRootView:self]; } - (void)setBackgroundColor:(UIColor *)backgroundColor diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index bc36c8e40..b672cafbe 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -27,6 +27,7 @@ #import "RCTModuleData.h" #import "RCTModuleMethod.h" #import "RCTProfile.h" +#import "RCTRootContentView.h" #import "RCTRootShadowView.h" #import "RCTRootViewInternal.h" #import "RCTScrollableProtocol.h" @@ -381,7 +382,7 @@ dispatch_queue_t RCTGetUIManagerQueue(void) return RCTGetUIManagerQueue(); } -- (void)registerRootView:(UIView *)rootView +- (void)registerRootView:(RCTRootContentView *)rootView { RCTAssertMainQueue(); @@ -393,6 +394,8 @@ dispatch_queue_t RCTGetUIManagerQueue(void) RCTAssert(existingView == nil || existingView == rootView, @"Expect all root views to have unique tag. Added %@ twice", reactTag); + CGSize availableSize = rootView.availableSize; + // Register view _viewRegistry[reactTag] = rootView; @@ -403,6 +406,7 @@ dispatch_queue_t RCTGetUIManagerQueue(void) } RCTRootShadowView *shadowView = [RCTRootShadowView new]; + shadowView.availableSize = availableSize; shadowView.reactTag = reactTag; shadowView.backgroundColor = rootView.backgroundColor; shadowView.viewName = NSStringFromClass([rootView class]); diff --git a/React/Views/RCTRootShadowView.m b/React/Views/RCTRootShadowView.m index 2a134a7fe..15b5b6f7c 100644 --- a/React/Views/RCTRootShadowView.m +++ b/React/Views/RCTRootShadowView.m @@ -13,10 +13,6 @@ @implementation RCTRootShadowView -/** - * Init the RCTRootShadowView with RTL status. - * Returns a RTL CSS layout if isRTL is true (Default is LTR CSS layout). - */ - (instancetype)init { self = [super init];