Revert D5944488: [RN][iOS]: Re-render views when direction changes
Differential Revision: D5944488 fbshipit-source-id: 79e695dcc0ea7d09544ace1525828333a5818c5a
This commit is contained in:
Родитель
9bbc70c442
Коммит
abed3cf6c4
|
@ -38,7 +38,7 @@ static CGFloat const kAutoSizeGranularity = 0.001f;
|
||||||
CGFloat _cachedTextStorageWidthMode;
|
CGFloat _cachedTextStorageWidthMode;
|
||||||
NSAttributedString *_cachedAttributedString;
|
NSAttributedString *_cachedAttributedString;
|
||||||
CGFloat _effectiveLetterSpacing;
|
CGFloat _effectiveLetterSpacing;
|
||||||
UIUserInterfaceLayoutDirection _cachedLayoutDirection;
|
UIUserInterfaceLayoutDirection _cachedEffectiveLayoutDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode)
|
static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode)
|
||||||
|
@ -72,7 +72,7 @@ static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, f
|
||||||
_fontSizeMultiplier = 1.0;
|
_fontSizeMultiplier = 1.0;
|
||||||
_textAlign = NSTextAlignmentNatural;
|
_textAlign = NSTextAlignmentNatural;
|
||||||
_writingDirection = NSWritingDirectionNatural;
|
_writingDirection = NSWritingDirectionNatural;
|
||||||
_cachedLayoutDirection = UIUserInterfaceLayoutDirectionLeftToRight;
|
_cachedEffectiveLayoutDirection = UIUserInterfaceLayoutDirectionLeftToRight;
|
||||||
|
|
||||||
YGNodeSetMeasureFunc(self.yogaNode, RCTMeasure);
|
YGNodeSetMeasureFunc(self.yogaNode, RCTMeasure);
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, f
|
||||||
_cachedTextStorage &&
|
_cachedTextStorage &&
|
||||||
(width == _cachedTextStorageWidth || (isnan(width) && isnan(_cachedTextStorageWidth))) &&
|
(width == _cachedTextStorageWidth || (isnan(width) && isnan(_cachedTextStorageWidth))) &&
|
||||||
widthMode == _cachedTextStorageWidthMode &&
|
widthMode == _cachedTextStorageWidthMode &&
|
||||||
_cachedLayoutDirection == self.layoutDirection
|
_cachedEffectiveLayoutDirection == self.effectiveLayoutDirection
|
||||||
) {
|
) {
|
||||||
return _cachedTextStorage;
|
return _cachedTextStorage;
|
||||||
}
|
}
|
||||||
|
@ -272,12 +272,12 @@ static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, f
|
||||||
if (
|
if (
|
||||||
![self isTextDirty] &&
|
![self isTextDirty] &&
|
||||||
_cachedAttributedString &&
|
_cachedAttributedString &&
|
||||||
_cachedLayoutDirection == self.layoutDirection
|
_cachedEffectiveLayoutDirection == self.effectiveLayoutDirection
|
||||||
) {
|
) {
|
||||||
return _cachedAttributedString;
|
return _cachedAttributedString;
|
||||||
}
|
}
|
||||||
|
|
||||||
_cachedLayoutDirection = self.layoutDirection;
|
_cachedEffectiveLayoutDirection = self.effectiveLayoutDirection;
|
||||||
|
|
||||||
if (_fontSize && !isnan(_fontSize)) {
|
if (_fontSize && !isnan(_fontSize)) {
|
||||||
fontSize = @(_fontSize);
|
fontSize = @(_fontSize);
|
||||||
|
@ -419,7 +419,7 @@ static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, f
|
||||||
// Text alignment
|
// Text alignment
|
||||||
NSTextAlignment textAlign = _textAlign;
|
NSTextAlignment textAlign = _textAlign;
|
||||||
if (textAlign == NSTextAlignmentRight || textAlign == NSTextAlignmentLeft) {
|
if (textAlign == NSTextAlignmentRight || textAlign == NSTextAlignmentLeft) {
|
||||||
if (_cachedLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) {
|
if (_cachedEffectiveLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) {
|
||||||
if (textAlign == NSTextAlignmentRight) {
|
if (textAlign == NSTextAlignmentRight) {
|
||||||
textAlign = NSTextAlignmentLeft;
|
textAlign = NSTextAlignmentLeft;
|
||||||
} else {
|
} else {
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -494,7 +494,7 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
|
||||||
reactTags[index] = shadowView.reactTag;
|
reactTags[index] = shadowView.reactTag;
|
||||||
frameDataArray[index++] = (RCTFrameData){
|
frameDataArray[index++] = (RCTFrameData){
|
||||||
shadowView.frame,
|
shadowView.frame,
|
||||||
shadowView.layoutDirection,
|
shadowView.effectiveLayoutDirection,
|
||||||
shadowView.isNewView,
|
shadowView.isNewView,
|
||||||
shadowView.superview.isNewView,
|
shadowView.superview.isNewView,
|
||||||
shadowView.isHidden,
|
shadowView.isHidden,
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
absolutePosition:(CGPoint)absolutePosition
|
absolutePosition:(CGPoint)absolutePosition
|
||||||
{
|
{
|
||||||
// Call super method if LTR layout is enforced.
|
// Call super method if LTR layout is enforced.
|
||||||
if (self.layoutDirection == UIUserInterfaceLayoutDirectionLeftToRight) {
|
if (self.effectiveLayoutDirection == UIUserInterfaceLayoutDirectionLeftToRight) {
|
||||||
[super applyLayoutNode:node
|
[super applyLayoutNode:node
|
||||||
viewsWithNewFrame:viewsWithNewFrame
|
viewsWithNewFrame:viewsWithNewFrame
|
||||||
absolutePosition:absolutePosition];
|
absolutePosition:absolutePosition];
|
||||||
|
|
|
@ -84,10 +84,9 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
|
||||||
@property (nonatomic, assign, getter=isHidden) BOOL hidden;
|
@property (nonatomic, assign, getter=isHidden) BOOL hidden;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layout direction for the view as computed in applyLayoutNode.
|
* Computed layout direction for the view backed to Yoga node value.
|
||||||
*/
|
*/
|
||||||
|
@property (nonatomic, assign, readonly) UIUserInterfaceLayoutDirection effectiveLayoutDirection;
|
||||||
@property (nonatomic, assign, readonly) UIUserInterfaceLayoutDirection layoutDirection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Position and dimensions.
|
* Position and dimensions.
|
||||||
|
@ -188,11 +187,6 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, assign) CGSize intrinsicContentSize;
|
@property (nonatomic, assign) CGSize intrinsicContentSize;
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the layout direction stored in the Yoga node that backs this view.
|
|
||||||
*/
|
|
||||||
- (UIUserInterfaceLayoutDirection)getLayoutDirectionFromYogaNode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate property changes that need to be propagated to the view.
|
* Calculate property changes that need to be propagated to the view.
|
||||||
* The applierBlocks set contains RCTApplierBlock functions that must be applied
|
* The applierBlocks set contains RCTApplierBlock functions that must be applied
|
||||||
|
|
|
@ -204,11 +204,8 @@ static void RCTProcessMetaPropsBorder(const YGValue metaProps[META_PROP_COUNT],
|
||||||
RCTRoundPixelValue(absoluteBottomRight.y - absoluteTopLeft.y)
|
RCTRoundPixelValue(absoluteBottomRight.y - absoluteTopLeft.y)
|
||||||
}};
|
}};
|
||||||
|
|
||||||
UIUserInterfaceLayoutDirection updatedLayoutDirection = [self getLayoutDirectionFromYogaNode];
|
if (!CGRectEqualToRect(frame, _frame)) {
|
||||||
|
|
||||||
if (!CGRectEqualToRect(frame, _frame) || _layoutDirection != updatedLayoutDirection) {
|
|
||||||
_frame = frame;
|
_frame = frame;
|
||||||
_layoutDirection = updatedLayoutDirection;
|
|
||||||
[viewsWithNewFrame addObject:self];
|
[viewsWithNewFrame addObject:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +493,7 @@ static void RCTProcessMetaPropsBorder(const YGValue metaProps[META_PROP_COUNT],
|
||||||
|
|
||||||
// Layout Direction
|
// Layout Direction
|
||||||
|
|
||||||
- (UIUserInterfaceLayoutDirection)getLayoutDirectionFromYogaNode {
|
- (UIUserInterfaceLayoutDirection)effectiveLayoutDirection {
|
||||||
// Even if `YGNodeLayoutGetDirection` can return `YGDirectionInherit` here, it actually means
|
// Even if `YGNodeLayoutGetDirection` can return `YGDirectionInherit` here, it actually means
|
||||||
// that Yoga will use LTR layout for the view (even if layout process is not finished yet).
|
// that Yoga will use LTR layout for the view (even if layout process is not finished yet).
|
||||||
return YGNodeLayoutGetDirection(_yogaNode) == YGDirectionRTL ? UIUserInterfaceLayoutDirectionRightToLeft : UIUserInterfaceLayoutDirectionLeftToRight;
|
return YGNodeLayoutGetDirection(_yogaNode) == YGDirectionRTL ? UIUserInterfaceLayoutDirectionRightToLeft : UIUserInterfaceLayoutDirectionLeftToRight;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче