Skip to content
Open
Show file tree
Hide file tree
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 @@ -33,7 +33,6 @@ - (RCTShadowView *)shadowView
RCT_REMAP_SHADOW_PROPERTY(gradientColors, textAttributes.gradientColors, NSArray)
RCT_REMAP_SHADOW_PROPERTY(gradientAngle, textAttributes.gradientAngle, CGFloat)
RCT_REMAP_SHADOW_PROPERTY(gradientLength, textAttributes.gradientLength, CGFloat)
RCT_REMAP_SHADOW_PROPERTY(gradientWidth, textAttributes.gradientWidth, CGFloat) // Deprecated alias for gradientLength
RCT_REMAP_SHADOW_PROPERTY(gradientMode, textAttributes.gradientMode, NSString)
RCT_REMAP_SHADOW_PROPERTY(opacity, textAttributes.opacity, CGFloat)
// Font
Expand Down
1 change: 0 additions & 1 deletion packages/react-native/Libraries/Text/RCTTextAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ __attribute__((deprecated("This API will be removed along with the legacy archit
@property (nonatomic, copy, nullable) NSArray *gradientColors;
@property (nonatomic, assign) CGFloat gradientAngle;
@property (nonatomic, assign) CGFloat gradientLength; // Length of gradient along its axis in pixels; NAN = use default (100px)
@property (nonatomic, assign) CGFloat gradientWidth; // Deprecated alias for gradientLength; gradientLength takes precedence when both are set
@property (nonatomic, copy, nullable) NSString *gradientMode; // "mirror" (default) or "clamp"
@property (nonatomic, assign) CGFloat opacity;
// Font
Expand Down
7 changes: 2 additions & 5 deletions packages/react-native/Libraries/Text/RCTTextAttributes.mm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ - (void)applyTextAttributes:(RCTTextAttributes *)textAttributes
_gradientColors = textAttributes->_gradientColors ?: _gradientColors;
_gradientAngle = !isnan(textAttributes->_gradientAngle) ? textAttributes->_gradientAngle : _gradientAngle;
_gradientLength = !isnan(textAttributes->_gradientLength) ? textAttributes->_gradientLength : _gradientLength;
_gradientWidth = !isnan(textAttributes->_gradientWidth) ? textAttributes->_gradientWidth : _gradientWidth;
_gradientMode = textAttributes->_gradientMode ?: _gradientMode;
_opacity =
!isnan(textAttributes->_opacity) ? (isnan(_opacity) ? 1.0 : _opacity) * textAttributes->_opacity : _opacity;
Expand Down Expand Up @@ -334,12 +333,10 @@ - (UIColor *)effectiveForegroundColor
}

CAGradientLayer *gradient = [CAGradientLayer layer];
// Prefer gradientLength; fall back to the deprecated gradientWidth; otherwise default to 100.
// Use gradientLength; otherwise default to 100.
CGFloat patternWidth;
if (!isnan(_gradientLength) && _gradientLength > 0) {
patternWidth = _gradientLength;
} else if (!isnan(_gradientWidth) && _gradientWidth > 0) {
patternWidth = _gradientWidth;
} else {
patternWidth = 100;
}
Expand Down Expand Up @@ -442,7 +439,7 @@ - (BOOL)isEqual:(RCTTextAttributes *)textAttributes

return RCTTextAttributesCompareObjects(_foregroundColor) && RCTTextAttributesCompareObjects(_backgroundColor) &&
RCTTextAttributesCompareObjects(_gradientColors) && RCTTextAttributesCompareFloats(_gradientAngle) &&
RCTTextAttributesCompareFloats(_gradientLength) && RCTTextAttributesCompareFloats(_gradientWidth) &&
RCTTextAttributesCompareFloats(_gradientLength) &&
RCTTextAttributesCompareFloats(_opacity) && RCTTextAttributesCompareStrings(_gradientMode) &&
// Font
RCTTextAttributesCompareObjects(_fontFamily) && RCTTextAttributesCompareFloats(_fontSize) &&
Expand Down
8 changes: 0 additions & 8 deletions packages/react-native/Libraries/Text/Text.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,6 @@ export interface TextProps
*/
gradientLength?: number | undefined;

/**
* @deprecated Use `gradientLength` instead. When both are provided,
* `gradientLength` takes precedence. Historically this was the width of the
* gradient pattern in pixels; it now maps to the gradient length along its
* axis. Default is 100.
*/
gradientWidth?: number | undefined;

/**
* Gradient tiling mode. "mirror" (default) tiles the gradient back and forth.
* "clamp" renders the gradient once from the start to the end of the text.
Expand Down
2 changes: 0 additions & 2 deletions packages/react-native/Libraries/Text/TextNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const textViewConfig = {
gradientColors: true,
gradientAngle: true,
gradientLength: true,
gradientWidth: true,
gradientMode: true,
textStrokeWidth: true,
textStrokeColor: true,
Expand All @@ -72,7 +71,6 @@ const virtualTextViewConfig = {
gradientColors: true,
gradientAngle: true,
gradientLength: true,
gradientWidth: true,
gradientMode: true,
textStrokeWidth: true,
textStrokeColor: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,9 @@ public class TextAttributeProps private constructor() {
public var gradientAngle: Float = Float.NaN
private set

// Deprecated alias for gradientLength; gradientLength takes precedence when both are set.
public var gradientWidth: Float = Float.NaN
public var gradientLength: Float = Float.NaN
private set

private var gradientLengthRaw: Float = Float.NaN

/**
* Effective gradient length, preferring [gradientLengthRaw] and falling back to the deprecated
* [gradientWidth] when [gradientLengthRaw] is unset.
*/
public val gradientLength: Float
get() = if (!gradientLengthRaw.isNaN()) gradientLengthRaw else gradientWidth

public var gradientMode: String? = null
private set

Expand Down Expand Up @@ -447,9 +437,7 @@ public class TextAttributeProps private constructor() {
public const val TA_KEY_TEXT_STROKE_WIDTH: Int = 31
public const val TA_KEY_TEXT_STROKE_COLOR: Int = 32
public const val TA_KEY_GRADIENT_ANGLE: Int = 33
// Deprecated alias for TA_KEY_GRADIENT_LENGTH; gradientLength takes precedence when both are set.
// Retains its original key (34) for backwards compatibility.
public const val TA_KEY_GRADIENT_WIDTH: Int = 34
public const val TA_KEY_GRADIENT_WIDTH: Int = 34 // Unused
public const val TA_KEY_GRADIENT_MODE: Int = 35
public const val TA_KEY_GRADIENT_LENGTH: Int = 36

Expand Down Expand Up @@ -510,8 +498,7 @@ public class TextAttributeProps private constructor() {
result.maxFontSizeMultiplier = entry.doubleValue.toFloat()
TA_KEY_GRADIENT_COLORS -> result.setGradientColors(entry.mapBufferValue)
TA_KEY_GRADIENT_ANGLE -> result.gradientAngle = entry.doubleValue.toFloat()
TA_KEY_GRADIENT_WIDTH -> result.gradientWidth = entry.doubleValue.toFloat()
TA_KEY_GRADIENT_LENGTH -> result.gradientLengthRaw = entry.doubleValue.toFloat()
TA_KEY_GRADIENT_LENGTH -> result.gradientLength = entry.doubleValue.toFloat()
TA_KEY_GRADIENT_MODE -> result.gradientMode = entry.stringValue
}
}
Expand Down Expand Up @@ -557,8 +544,7 @@ public class TextAttributeProps private constructor() {
result.setRole(getStringProp(props, ViewProps.ROLE))
result.setGradientColors(getArrayProp(props, "gradientColors"))
result.gradientAngle = getFloatProp(props, "gradientAngle", Float.NaN)
result.gradientLengthRaw = getFloatProp(props, "gradientLength", Float.NaN)
result.gradientWidth = getFloatProp(props, "gradientWidth", Float.NaN)
result.gradientLength = getFloatProp(props, "gradientLength", Float.NaN)
result.gradientMode = getStringProp(props, "gradientMode")
result.textStrokeWidth = getFloatProp(props, "textStrokeWidth", Float.NaN)
if (props.hasKey("textStrokeColor")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ void TextAttributes::apply(TextAttributes textAttributes) {
gradientLength = !std::isnan(textAttributes.gradientLength)
? textAttributes.gradientLength
: gradientLength;
gradientWidth = !std::isnan(textAttributes.gradientWidth)
? textAttributes.gradientWidth
: gradientWidth;
gradientMode = textAttributes.gradientMode.has_value()
? textAttributes.gradientMode
: gradientMode;
Expand Down Expand Up @@ -200,7 +197,6 @@ bool TextAttributes::operator==(const TextAttributes& rhs) const {
floatEquality(textStrokeWidth, rhs.textStrokeWidth) &&
floatEquality(gradientAngle, rhs.gradientAngle) &&
floatEquality(gradientLength, rhs.gradientLength) &&
floatEquality(gradientWidth, rhs.gradientWidth) &&
gradientColors == rhs.gradientColors &&
gradientMode == rhs.gradientMode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class TextAttributes : public DebugStringConvertible {
std::optional<std::vector<SharedColor>> gradientColors{};
Float gradientAngle{std::numeric_limits<Float>::quiet_NaN()};
Float gradientLength{std::numeric_limits<Float>::quiet_NaN()};
// Deprecated alias for gradientLength; gradientLength takes precedence when both are set.
Float gradientWidth{std::numeric_limits<Float>::quiet_NaN()};
std::optional<std::string> gradientMode{}; // "mirror" or "clamp"

// Font
Expand Down Expand Up @@ -151,7 +149,6 @@ struct hash<facebook::react::TextAttributes> {
textAttributes.gradientColors,
textAttributes.gradientAngle,
textAttributes.gradientLength,
textAttributes.gradientWidth,
textAttributes.gradientMode,
textAttributes.isHighlighted,
textAttributes.isPressable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1132,9 +1132,7 @@ constexpr static MapBuffer::Key TA_KEY_GRADIENT_COLORS = 30;
constexpr static MapBuffer::Key TA_KEY_TEXT_STROKE_WIDTH = 31;
constexpr static MapBuffer::Key TA_KEY_TEXT_STROKE_COLOR = 32;
constexpr static MapBuffer::Key TA_KEY_GRADIENT_ANGLE = 33;
// Deprecated alias for TA_KEY_GRADIENT_LENGTH; gradientLength takes precedence when both are set.
// Retains its original key (34) for backwards compatibility.
constexpr static MapBuffer::Key TA_KEY_GRADIENT_WIDTH = 34;
constexpr static MapBuffer::Key TA_KEY_GRADIENT_WIDTH = 34; // Unused
constexpr static MapBuffer::Key TA_KEY_GRADIENT_MODE = 35;
constexpr static MapBuffer::Key TA_KEY_GRADIENT_LENGTH = 36;

Expand Down Expand Up @@ -1273,9 +1271,6 @@ inline MapBuffer toMapBuffer(const TextAttributes &textAttributes)
if (!std::isnan(textAttributes.gradientLength)) {
builder.putDouble(TA_KEY_GRADIENT_LENGTH, textAttributes.gradientLength);
}
if (!std::isnan(textAttributes.gradientWidth)) {
builder.putDouble(TA_KEY_GRADIENT_WIDTH, textAttributes.gradientWidth);
}
if (textAttributes.gradientMode.has_value()) {
builder.putString(TA_KEY_GRADIENT_MODE, *textAttributes.gradientMode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ static TextAttributes convertRawProp(
"gradientLength",
sourceTextAttributes.gradientLength,
defaultTextAttributes.gradientLength);
textAttributes.gradientWidth = convertRawProp(
context,
rawProps,
"gradientWidth",
sourceTextAttributes.gradientWidth,
defaultTextAttributes.gradientWidth);
textAttributes.gradientMode = convertRawProp(
context,
rawProps,
Expand Down Expand Up @@ -299,8 +293,6 @@ void BaseTextProps::setProp(
defaults, value, textAttributes, gradientAngle, "gradientAngle");
REBUILD_FIELD_SWITCH_CASE(
defaults, value, textAttributes, gradientLength, "gradientLength");
REBUILD_FIELD_SWITCH_CASE(
defaults, value, textAttributes, gradientWidth, "gradientWidth");
REBUILD_FIELD_SWITCH_CASE(
defaults, value, textAttributes, gradientMode, "gradientMode");
REBUILD_FIELD_SWITCH_CASE(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,9 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
}

CAGradientLayer *gradient = [CAGradientLayer layer];
// Prefer gradientLength; fall back to the deprecated gradientWidth; otherwise default to 100.
CGFloat patternWidth;
if (!isnan(textAttributes.gradientLength) && textAttributes.gradientLength > 0) {
patternWidth = textAttributes.gradientLength;
} else if (!isnan(textAttributes.gradientWidth) && textAttributes.gradientWidth > 0) {
patternWidth = textAttributes.gradientWidth;
} else {
patternWidth = 100;
}
Expand Down