mirror of
https://github.com/status-im/react-native.git
synced 2025-02-24 15:18:10 +00:00
Setting availableSize
for RCTRootShadowView
on earlier stage
Summary: Moving setting `availableSize` for `RCTRootShadowView` on earlier stage allows to prevent situations where `availableSize` is not specified yet, but Yoga layout is already happening. Because `availableSize` equals {infinity, infinity} by default (in this case), Yoga returns a lot of nodes with infinit metrics, which confises UIKit. Reviewed By: mmmulani Differential Revision: D4672170 fbshipit-source-id: f9d8c84799dcbdb6b9230ddef6284d84df268833
This commit is contained in:
parent
1269f1ef4e
commit
264d60b979
@ -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
|
||||
|
@ -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
|
||||
|
@ -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]);
|
||||
|
@ -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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user