Skip to content

Commit 9bbc70c

Browse files
RSNarafacebook-github-bot
authored andcommitted
Re-render views when direction changes
Summary: This is required for D5874536, wherein I'll be introducing direction-aware props for borders. When a view's border changes due to a direction update, only the frames of its children update. Therefore, only the children `UIView`s get a chance to be re-rendered. This is incorrect because the view that's had its borders changed also needs to re-render. So, I keep a track of the layout direction in a property on all shadow views. Then, when I update that prop within `applyLayoutNode`, I push shadow views into the `viewsWithNewFrames` set. Reviewed By: mmmulani Differential Revision: D5944488 fbshipit-source-id: 3f23e9973f3555612920703cdb6cec38e6360d2d
1 parent 53a339a commit 9bbc70c

File tree

6 files changed

+623
-435
lines changed

6 files changed

+623
-435
lines changed

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)