Skip to content

Commit 992ade1

Browse files
RSNarafacebook-github-bot
authored andcommitted
Re-render views when direction changes
Reviewed By: shergin Differential Revision: D5959573 fbshipit-source-id: 36b2cde921362a934a2c88a3ed05be5082ed08bf
1 parent bbcfcdb commit 992ade1

6 files changed

Lines changed: 618 additions & 442 deletions

File tree

Libraries/Text/RCTShadowText.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ @implementation RCTShadowText
3838
CGFloat _cachedTextStorageWidthMode;
3939
NSAttributedString *_cachedAttributedString;
4040
CGFloat _effectiveLetterSpacing;
41-
UIUserInterfaceLayoutDirection _cachedEffectiveLayoutDirection;
41+
UIUserInterfaceLayoutDirection _cachedLayoutDirection;
4242
}
4343

4444
static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode)
@@ -72,7 +72,7 @@ - (instancetype)init
7272
_fontSizeMultiplier = 1.0;
7373
_textAlign = NSTextAlignmentNatural;
7474
_writingDirection = NSWritingDirectionNatural;
75-
_cachedEffectiveLayoutDirection = UIUserInterfaceLayoutDirectionLeftToRight;
75+
_cachedLayoutDirection = UIUserInterfaceLayoutDirectionLeftToRight;
7676

7777
YGNodeSetMeasureFunc(self.yogaNode, RCTMeasure);
7878

@@ -198,7 +198,7 @@ - (NSTextStorage *)buildTextStorageForWidth:(CGFloat)width widthMode:(YGMeasureM
198198
_cachedTextStorage &&
199199
(width == _cachedTextStorageWidth || (isnan(width) && isnan(_cachedTextStorageWidth))) &&
200200
widthMode == _cachedTextStorageWidthMode &&
201-
_cachedEffectiveLayoutDirection == self.effectiveLayoutDirection
201+
_cachedLayoutDirection == self.layoutDirection
202202
) {
203203
return _cachedTextStorage;
204204
}
@@ -272,12 +272,12 @@ - (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily
272272
if (
273273
![self isTextDirty] &&
274274
_cachedAttributedString &&
275-
_cachedEffectiveLayoutDirection == self.effectiveLayoutDirection
275+
_cachedLayoutDirection == self.layoutDirection
276276
) {
277277
return _cachedAttributedString;
278278
}
279279

280-
_cachedEffectiveLayoutDirection = self.effectiveLayoutDirection;
280+
_cachedLayoutDirection = self.layoutDirection;
281281

282282
if (_fontSize && !isnan(_fontSize)) {
283283
fontSize = @(_fontSize);
@@ -419,7 +419,7 @@ - (void)_setParagraphStyleOnAttributedString:(NSMutableAttributedString *)attrib
419419
// Text alignment
420420
NSTextAlignment textAlign = _textAlign;
421421
if (textAlign == NSTextAlignmentRight || textAlign == NSTextAlignmentLeft) {
422-
if (_cachedEffectiveLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) {
422+
if (_cachedLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) {
423423
if (textAlign == NSTextAlignmentRight) {
424424
textAlign = NSTextAlignmentLeft;
425425
} else {

0 commit comments

Comments
 (0)