Skip to content

Commit

Permalink
passing textAlignVert from js NestedText to Java
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact committed Dec 22, 2022
1 parent 6716e0f commit 7d147de
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class TextAttributeProps {
public static final short TA_KEY_IS_HIGHLIGHTED = 20;
public static final short TA_KEY_LAYOUT_DIRECTION = 21;
public static final short TA_KEY_ACCESSIBILITY_ROLE = 22;
public static final short TA_KEY_VERTICAL_ALIGN = 23;
public static final short TA_KEY_ALIGN_VERTICAL = 24;

public static final int UNSET = -1;

Expand Down Expand Up @@ -208,8 +208,8 @@ public static TextAttributeProps fromMapBuffer(MapBuffer props) {
case TA_KEY_ACCESSIBILITY_ROLE:
result.setAccessibilityRole(entry.getStringValue());
break;
case TA_KEY_VERTICAL_ALIGN:
result.setVerticalAlign(entry.getStringValue());
case TA_KEY_ALIGN_VERTICAL:
result.setTextAlignVertical(entry.getStringValue());
break;
}
}
Expand Down Expand Up @@ -615,9 +615,9 @@ private void setAccessibilityRole(@Nullable String accessibilityRole) {
}
}

private void setVerticalAlign(@Nullable String verticalAlign) {
FLog.w("React::", "verticalAlign: " + (verticalAlign));
private void setTextAlignVertical(@Nullable String verticalAlign) {
if (verticalAlign != null) {
FLog.w("React::", "verticalAlign: " + (verticalAlign));
mVerticalAlign = verticalAlign;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private static void buildSpannableFromFragment(
ops.add(new SetSpanOperation(start, end, new ReactSuperscriptSpan()));
}
if (textAttributes.mIsAccessibilityLink) {
ops.add(new SetSpanOperation(start, end, new ReactClickableSpan(reactTag)));
ops.add(new SetSpanOperation(start, end, new ReactSuperscriptSpan()));
}
if (textAttributes.mIsColorSet) {
ops.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void TextAttributes::apply(TextAttributes textAttributes) {
accessibilityRole = textAttributes.accessibilityRole.has_value()
? textAttributes.accessibilityRole
: accessibilityRole;
textVerticalAlign = !textAttributes.textVerticalAlign.empty() ? textAttributes.textVerticalAlign : textVerticalAlign;
textAlignVertical = !textAttributes.textAlignVertical.empty() ? textAttributes.textAlignVertical : textAlignVertical;
}

#pragma mark - Operators
Expand All @@ -127,7 +127,7 @@ bool TextAttributes::operator==(const TextAttributes &rhs) const {
isHighlighted,
layoutDirection,
accessibilityRole,
textVerticalAlign,
textAlignVertical,
textTransform) ==
std::tie(
rhs.foregroundColor,
Expand All @@ -149,7 +149,7 @@ bool TextAttributes::operator==(const TextAttributes &rhs) const {
rhs.isHighlighted,
rhs.layoutDirection,
rhs.accessibilityRole,
rhs.textVerticalAlign,
rhs.textAlignVertical,
rhs.textTransform) &&
floatEquality(opacity, rhs.opacity) &&
floatEquality(fontSize, rhs.fontSize) &&
Expand Down Expand Up @@ -218,7 +218,7 @@ SharedDebugStringConvertibleList TextAttributes::getDebugProps() const {
debugStringConvertibleItem("isHighlighted", isHighlighted),
debugStringConvertibleItem("layoutDirection", layoutDirection),
debugStringConvertibleItem("accessibilityRole", accessibilityRole),
debugStringConvertibleItem("textVerticalAlign", textVerticalAlign),
debugStringConvertibleItem("textAlignVertical", textAlignVertical),
};
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class TextAttributes : public DebugStringConvertible {
// construction.
std::optional<LayoutDirection> layoutDirection{};
std::optional<AccessibilityRole> accessibilityRole{};
std::string textVerticalAlign{""};
std::string textAlignVertical{};

#pragma mark - Operations

Expand Down
8 changes: 4 additions & 4 deletions ReactCommon/react/renderer/attributedstring/conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1036,9 +1036,9 @@ inline folly::dynamic toDynamic(const TextAttributes &textAttributes) {
_textAttributes(
"accessibilityRole", toString(*textAttributes.accessibilityRole));
}
if (!textAttributes.textVerticalAlign.empty()) {
if (!textAttributes.textAlignVertical.empty()) {
_textAttributes(
"textVerticalAlign", textAttributes.textVerticalAlign);
"textAlignVertical", textAttributes.textAlignVertical);
}
return _textAttributes;
}
Expand Down Expand Up @@ -1261,9 +1261,9 @@ inline MapBuffer toMapBuffer(const TextAttributes &textAttributes) {
builder.putString(
TA_KEY_ACCESSIBILITY_ROLE, toString(*textAttributes.accessibilityRole));
}
if (textAttributes.textVerticalAlign.empty()) {
if (!textAttributes.textAlignVertical.empty()) {
builder.putString(
TA_KEY_VERTICAL_ALIGN, textAttributes.textVerticalAlign);
TA_KEY_VERTICAL_ALIGN, textAttributes.textAlignVertical);
}
return builder.build();
}
Expand Down
10 changes: 5 additions & 5 deletions ReactCommon/react/renderer/components/text/BaseTextProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ static TextAttributes convertRawProp(
sourceTextAttributes.backgroundColor,
defaultTextAttributes.backgroundColor);

textAttributes.textVerticalAlign = convertRawProp(
textAttributes.textAlignVertical = convertRawProp(
context,
rawProps,
"textVerticalAlign",
sourceTextAttributes.textVerticalAlign,
defaultTextAttributes.textVerticalAlign);
"textAlignVertical",
sourceTextAttributes.textAlignVertical,
defaultTextAttributes.textAlignVertical);

return textAttributes;
}
Expand Down Expand Up @@ -305,7 +305,7 @@ void BaseTextProps::setProp(
REBUILD_FIELD_SWITCH_CASE(
defaults, value, textAttributes, backgroundColor, "backgroundColor");
REBUILD_FIELD_SWITCH_CASE(
defaults, value, textAttributes, backgroundColor, "textVerticalAlign");
defaults, value, textAttributes, backgroundColor, "textAlignVertical");
}
}

Expand Down
10 changes: 5 additions & 5 deletions ReactCommon/react/renderer/components/view/ViewProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ ViewProps::ViewProps(
"backgroundColor",
sourceProps.backgroundColor,
{})),
textVerticalAlign(
textAlignVertical(
CoreFeatures::enablePropIteratorSetter
? sourceProps.textVerticalAlign
? sourceProps.textAlignVertical
: convertRawProp(
context,
rawProps,
"textVerticalAlign",
sourceProps.textVerticalAlign,
"textAlignVertical",
sourceProps.textAlignVertical,
{})),
borderRadii(
CoreFeatures::enablePropIteratorSetter ? sourceProps.borderRadii
Expand Down Expand Up @@ -302,7 +302,7 @@ void ViewProps::setProp(
RAW_SET_PROP_SWITCH_CASE_BASIC(opacity, (Float)1.0);
RAW_SET_PROP_SWITCH_CASE_BASIC(foregroundColor, {});
RAW_SET_PROP_SWITCH_CASE_BASIC(backgroundColor, {});
RAW_SET_PROP_SWITCH_CASE_BASIC(textVerticalAlign, {});
RAW_SET_PROP_SWITCH_CASE_BASIC(textAlignVertical, {});
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowColor, {});
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowOffset, {});
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowOpacity, {});
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/react/renderer/components/view/ViewProps.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ViewProps : public YogaStylableProps, public AccessibilityProps {
Float opacity{1.0};
SharedColor foregroundColor{};
SharedColor backgroundColor{};
std::string textVerticalAlign{""};
std::string textAlignVertical{""};

// Borders
CascadedBorderRadii borderRadii{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ void ViewProps::propsDiffMapBuffer(
builder.putInt(VP_FG_COLOR, toAndroidRepr(newProps.foregroundColor));
}

if (oldProps.textVerticalAlign != newProps.textVerticalAlign) {
builder.putString(VP_TEXT_VERTICAL_ALIGN, newProps.textVerticalAlign);
if (oldProps.textAlignVertical != newProps.textAlignVertical) {
builder.putString(VP_TEXT_VERTICAL_ALIGN, newProps.textAlignVertical);
}

if (oldProps.borderCurves != newProps.borderCurves) {
Expand Down

0 comments on commit 7d147de

Please sign in to comment.