com.facebook.react.views.text.ReactTextShadowNode Java Examples

The following examples show how to use com.facebook.react.views.text.ReactTextShadowNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RNShadowTextGradient.java    From react-native-text-gradient with MIT License 4 votes vote down vote up
private Spannable getSpannable() {
  return ReflectUtils.getFieldValue(this, sSpannableField, ReactTextShadowNode.class);
}
 
Example #2
Source File: RNShadowTextGradient.java    From react-native-text-gradient with MIT License 4 votes vote down vote up
private static void buildSpannedGradientFromTextCSSNode(
  ReactBaseTextShadowNode textGradientShadowNode,
  SpannableStringBuilder builder,
  List<RNSetGradientSpanOperation> ops,
  float maxWidth,
  float maxHeight,
  Layout layout
) {
  int start = builder.length();

  for (int i = 0; i < textGradientShadowNode.getChildCount(); i++) {
    ReactShadowNode child = textGradientShadowNode.getChildAt(i);

    if (child instanceof ReactRawTextShadowNode) {
      builder.append(((ReactRawTextShadowNode) child).getText());

    } else if (child instanceof ReactBaseTextShadowNode) {
      buildSpannedGradientFromTextCSSNode(
        (ReactBaseTextShadowNode) child,
        builder,
        ops,
        maxWidth,
        maxHeight,
        layout
      );

    } else if (child instanceof ReactTextInlineImageShadowNode) {
      builder.append(
        (String) ReflectUtils.getFieldValue(
          textGradientShadowNode,
          "INLINE_IMAGE_PLACEHOLDER",
          ReactTextShadowNode.class
        )
      );
    }

    child.markUpdateSeen();
  }

  int end = builder.length();

  if (end >= start && textGradientShadowNode instanceof RNShadowTextGradient) {
    RNSetGradientSpanOperation spanOp = ((RNShadowTextGradient) textGradientShadowNode)
      .createSpan(builder, start, end, maxWidth, maxHeight, layout);

    ops.add(spanOp);
  }
}