Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

using namespace facebook::react;

inline static TextAlignment RCTResolveTextAlignment(TextAlignment textAlignment, LayoutDirection layoutDirection)
inline static TextAlignment RCTResolveTextAlignment(TextAlignment textAlignment, bool isRTL)
{
const bool isRTL = layoutDirection == LayoutDirection::RightToLeft;
switch (textAlignment) {
case TextAlignment::Natural:
return isRTL ? TextAlignment::Right : TextAlignment::Left;
case TextAlignment::Start:
return isRTL ? TextAlignment::Right : TextAlignment::Left;
case TextAlignment::End:
Expand Down Expand Up @@ -212,10 +213,10 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
// Paragraph Style
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
BOOL isParagraphStyleUsed = NO;
if (textAttributes.alignment.has_value()) {
TextAlignment textAlignment = RCTResolveTextAlignment(
textAttributes.alignment.value_or(TextAlignment::Natural),
textAttributes.layoutDirection.value_or(LayoutDirection::LeftToRight));
const bool isRTL = textAttributes.layoutDirection == LayoutDirection::RightToLeft;
if (textAttributes.alignment.has_value() || isRTL) {
TextAlignment textAlignment =
RCTResolveTextAlignment(textAttributes.alignment.value_or(TextAlignment::Natural), isRTL);

paragraphStyle.alignment = RCTNSTextAlignmentFromTextAlignment(textAlignment);
isParagraphStyleUsed = YES;
Expand Down
Loading