22
22
import com .facebook .react .uimanager .ViewProps ;
23
23
import com .facebook .react .uimanager .annotations .ReactProp ;
24
24
import com .facebook .yoga .YogaDirection ;
25
+
26
+ import org .w3c .dom .Text ;
27
+
25
28
import java .util .ArrayList ;
26
29
import java .util .List ;
27
30
import javax .annotation .Nullable ;
@@ -94,7 +97,10 @@ private static void buildSpannedFromShadowNode(
94
97
ReactShadowNode child = textShadowNode .getChildAt (i );
95
98
96
99
if (child instanceof ReactRawTextShadowNode ) {
97
- sb .append (((ReactRawTextShadowNode ) child ).getText ());
100
+ sb .append (
101
+ TextTransform .apply (
102
+ ((ReactRawTextShadowNode ) child ).getText (),
103
+ textAttributes .getTextTransform ()));
98
104
} else if (child instanceof ReactBaseTextShadowNode ) {
99
105
buildSpannedFromShadowNode ((ReactBaseTextShadowNode ) child , sb , ops , textAttributes , sb .length ());
100
106
} else if (child instanceof ReactTextInlineImageShadowNode ) {
@@ -182,13 +188,6 @@ private static void buildSpannedFromShadowNode(
182
188
new SetSpanOperation (
183
189
start , end , new CustomLineHeightSpan (effectiveLineHeight )));
184
190
}
185
- if (textShadowNode .mTextTransform != TextTransform .UNSET ) {
186
- ops .add (
187
- new SetSpanOperation (
188
- start ,
189
- end ,
190
- new CustomTextTransformSpan (textShadowNode .mTextTransform )));
191
- }
192
191
ops .add (new SetSpanOperation (start , end , new ReactTagSpan (textShadowNode .getReactTag ())));
193
192
}
194
193
}
@@ -207,7 +206,7 @@ protected static Spannable spannedFromShadowNode(
207
206
if (text != null ) {
208
207
// Handle text that is provided via a prop (e.g. the `value` and `defaultValue` props on
209
208
// TextInput).
210
- sb .append (text );
209
+ sb .append (TextTransform . apply ( text , textShadowNode . mTextAttributes . getTextTransform ()) );
211
210
}
212
211
213
212
buildSpannedFromShadowNode (textShadowNode , sb , ops , null , 0 );
@@ -266,7 +265,6 @@ private static int parseNumericFontWeight(String fontWeightString) {
266
265
protected int mTextAlign = Gravity .NO_GRAVITY ;
267
266
protected int mTextBreakStrategy =
268
267
(Build .VERSION .SDK_INT < Build .VERSION_CODES .M ) ? 0 : Layout .BREAK_STRATEGY_HIGH_QUALITY ;
269
- protected TextTransform mTextTransform = TextTransform .UNSET ;
270
268
271
269
protected float mTextShadowOffsetDx = 0 ;
272
270
protected float mTextShadowOffsetDy = 0 ;
@@ -520,14 +518,16 @@ public void setTextShadowColor(int textShadowColor) {
520
518
521
519
@ ReactProp (name = PROP_TEXT_TRANSFORM )
522
520
public void setTextTransform (@ Nullable String textTransform ) {
523
- if (textTransform == null || "none" .equals (textTransform )) {
524
- mTextTransform = TextTransform .NONE ;
521
+ if (textTransform == null ) {
522
+ mTextAttributes .setTextTransform (TextTransform .UNSET );
523
+ } else if ("none" .equals (textTransform )) {
524
+ mTextAttributes .setTextTransform (TextTransform .NONE );
525
525
} else if ("uppercase" .equals (textTransform )) {
526
- mTextTransform = TextTransform .UPPERCASE ;
526
+ mTextAttributes . setTextTransform ( TextTransform .UPPERCASE ) ;
527
527
} else if ("lowercase" .equals (textTransform )) {
528
- mTextTransform = TextTransform .LOWERCASE ;
528
+ mTextAttributes . setTextTransform ( TextTransform .LOWERCASE ) ;
529
529
} else if ("capitalize" .equals (textTransform )) {
530
- mTextTransform = TextTransform .CAPITALIZE ;
530
+ mTextAttributes . setTextTransform ( TextTransform .CAPITALIZE ) ;
531
531
} else {
532
532
throw new JSApplicationIllegalArgumentException ("Invalid textTransform: " + textTransform );
533
533
}
0 commit comments