From d5399dd40d8f939f3009288a4b69f7ab5282e89d Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Mon, 9 Feb 2026 22:33:05 -0800 Subject: [PATCH] Remove LayoutShadowNode descendants and use LayoutShadowNode directly (#55482) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55482 This change removes all descendant ShadowNode classes of LayoutShadowNode in ReactAndroid as part of the ongoing Legacy Architecture cleanup. These ShadowNode classes were deprecated and marked for removal. Deleted classes: - ProgressBarShadowNode - ReactSwitchShadowNode - ReactTextInlineImageShadowNode - ReactBaseTextShadowNode - ReactTextShadowNode - ReactTextInputShadowNode All usages in ViewManager classes have been updated to use LayoutShadowNode directly instead of these specialized subclasses. # Changelog [Android][Removed] - Remove Deprecated ProgressBarShadowNode [Android][Removed] - Remove Deprecated ReactSwitchShadowNode [Android][Removed] - Remove Deprecated ReactTextInlineImageShadowNode [Android][Removed] - Remove Deprecated ReactBaseTextShadowNode [Android][Removed] - Remove Deprecated ReactTextShadowNode [Android][Removed] - Remove Deprecated ReactTextInputShadowNode Reviewed By: mdvacca Differential Revision: D92646479 fbshipit-source-id: 59e3d73edbde0960476747891a9c1cba6a5114de --- .../ReactAndroid/api/ReactAndroid.api | 64 +---- .../progressbar/ProgressBarShadowNode.kt | 81 ------ .../ReactProgressBarViewManager.kt | 11 +- .../views/switchview/ReactSwitchManager.kt | 12 +- .../views/switchview/ReactSwitchShadowNode.kt | 72 ----- .../views/text/ReactBaseTextShadowNode.kt | 245 ------------------ .../react/views/text/ReactTextShadowNode.kt | 80 ------ .../react/views/text/ReactTextViewManager.kt | 13 +- .../views/textinput/ReactTextInputManager.kt | 10 +- .../textinput/ReactTextInputShadowNode.kt | 134 ---------- 10 files changed, 27 insertions(+), 695 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ProgressBarShadowNode.kt delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchShadowNode.kt delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.kt delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.kt delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.kt diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index d7de4590005..80c168cd95d 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -6061,49 +6061,6 @@ public final class com/facebook/react/views/text/DefaultStyleValuesUtil { public static final fun getTextColorSecondary (Landroid/content/Context;)Landroid/content/res/ColorStateList; } -public abstract class com/facebook/react/views/text/ReactBaseTextShadowNode : com/facebook/react/uimanager/LayoutShadowNode { - public static final field Companion Lcom/facebook/react/views/text/ReactBaseTextShadowNode$Companion; - public static final field DEFAULT_TEXT_SHADOW_COLOR I - public static final field PROP_SHADOW_COLOR Ljava/lang/String; - public static final field PROP_SHADOW_OFFSET Ljava/lang/String; - public static final field PROP_SHADOW_OFFSET_HEIGHT Ljava/lang/String; - public static final field PROP_SHADOW_OFFSET_WIDTH Ljava/lang/String; - public static final field PROP_SHADOW_RADIUS Ljava/lang/String; - public static final field PROP_TEXT_TRANSFORM Ljava/lang/String; - public fun ()V - public fun (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;)V - public synthetic fun (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - protected final fun getReactTextViewManagerCallback ()Lcom/facebook/react/views/text/ReactTextViewManagerCallback; - public final fun setAccessibilityRole (Ljava/lang/String;)V - public final fun setAdjustFontSizeToFit (Z)V - public final fun setAllowFontScaling (Z)V - public final fun setBackgroundColor (Ljava/lang/Integer;)V - public final fun setColor (Ljava/lang/Integer;)V - public final fun setFontFamily (Ljava/lang/String;)V - public final fun setFontSize (F)V - public final fun setFontStyle (Ljava/lang/String;)V - public final fun setFontVariant (Lcom/facebook/react/bridge/ReadableArray;)V - public final fun setFontWeight (Ljava/lang/String;)V - public final fun setIncludeFontPadding (Z)V - public final fun setLetterSpacing (F)V - public final fun setLineHeight (F)V - public final fun setMaxFontSizeMultiplier (F)V - public final fun setMinimumFontScale (F)V - public final fun setNumberOfLines (I)V - protected final fun setReactTextViewManagerCallback (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;)V - public final fun setRole (Ljava/lang/String;)V - public final fun setTextAlign (Ljava/lang/String;)V - public fun setTextBreakStrategy (Ljava/lang/String;)V - public final fun setTextDecorationLine (Ljava/lang/String;)V - public final fun setTextShadowColor (I)V - public final fun setTextShadowOffset (Lcom/facebook/react/bridge/ReadableMap;)V - public final fun setTextShadowRadius (F)V - public final fun setTextTransform (Ljava/lang/String;)V -} - -public final class com/facebook/react/views/text/ReactBaseTextShadowNode$Companion { -} - public final class com/facebook/react/views/text/ReactFontManager { public static final field Companion Lcom/facebook/react/views/text/ReactFontManager$Companion; public synthetic fun (Lcom/facebook/react/common/assets/ReactFontManager;Lkotlin/jvm/internal/DefaultConstructorMarker;)V @@ -6120,19 +6077,6 @@ public final class com/facebook/react/views/text/ReactFontManager$Companion { public final fun getInstance ()Lcom/facebook/react/views/text/ReactFontManager; } -public final class com/facebook/react/views/text/ReactTextShadowNode : com/facebook/react/views/text/ReactBaseTextShadowNode { - public fun ()V - public fun (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;)V - public synthetic fun (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun calculateLayoutOnChildren ()Ljava/lang/Iterable; - public fun hoistNativeChildren ()Z - public fun isVirtualAnchor ()Z - public fun markUpdated ()V - public fun onBeforeLayout (Lcom/facebook/react/uimanager/NativeViewHierarchyOptimizer;)V - public fun onCollectExtraUpdates (Lcom/facebook/react/uimanager/UIViewOperationQueue;)V - public final fun setShouldNotifyOnTextLayout (Z)V -} - public class com/facebook/react/views/text/ReactTextView : androidx/appcompat/widget/AppCompatTextView, com/facebook/react/uimanager/ReactCompoundView { public fun (Landroid/content/Context;)V protected fun dispatchHoverEvent (Landroid/view/MotionEvent;)Z @@ -6174,9 +6118,9 @@ public final class com/facebook/react/views/text/ReactTextViewManager : com/face public fun ()V public fun (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;)V public synthetic fun (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun createShadowNodeInstance ()Lcom/facebook/react/uimanager/LayoutShadowNode; public synthetic fun createShadowNodeInstance ()Lcom/facebook/react/uimanager/ReactShadowNode; - public fun createShadowNodeInstance ()Lcom/facebook/react/views/text/ReactTextShadowNode; - public final fun createShadowNodeInstance (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;)Lcom/facebook/react/views/text/ReactTextShadowNode; + public final fun createShadowNodeInstance (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;)Lcom/facebook/react/uimanager/LayoutShadowNode; public synthetic fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Landroid/view/View; public fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Lcom/facebook/react/views/text/ReactTextView; public fun getExportedCustomDirectEventTypeConstants ()Ljava/util/Map; @@ -6416,9 +6360,9 @@ public class com/facebook/react/views/textinput/ReactTextInputManager : com/face public fun ()V public synthetic fun addEventEmitters (Lcom/facebook/react/uimanager/ThemedReactContext;Landroid/view/View;)V protected fun addEventEmitters (Lcom/facebook/react/uimanager/ThemedReactContext;Lcom/facebook/react/views/textinput/ReactEditText;)V + public fun createShadowNodeInstance ()Lcom/facebook/react/uimanager/LayoutShadowNode; public synthetic fun createShadowNodeInstance ()Lcom/facebook/react/uimanager/ReactShadowNode; - public fun createShadowNodeInstance ()Lcom/facebook/react/views/text/ReactBaseTextShadowNode; - public final fun createShadowNodeInstance (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;)Lcom/facebook/react/views/text/ReactBaseTextShadowNode; + public final fun createShadowNodeInstance (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;)Lcom/facebook/react/uimanager/LayoutShadowNode; public synthetic fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Landroid/view/View; public fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Lcom/facebook/react/views/textinput/ReactEditText; public fun getCommandsMap ()Ljava/util/Map; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ProgressBarShadowNode.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ProgressBarShadowNode.kt deleted file mode 100644 index fc8c0e2e214..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ProgressBarShadowNode.kt +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.views.progressbar - -import android.util.SparseIntArray -import android.view.View -import android.view.ViewGroup -import com.facebook.react.common.annotations.LegacyArchitectureShadowNodeWithCxxImpl -import com.facebook.react.common.annotations.internal.LegacyArchitecture -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger -import com.facebook.react.uimanager.annotations.ReactProp -import com.facebook.yoga.YogaMeasureFunction -import com.facebook.yoga.YogaMeasureMode -import com.facebook.yoga.YogaMeasureOutput -import com.facebook.yoga.YogaNode - -/** - * Node responsible for holding the style of the ProgressBar, see under [ ] for possible styles. - * ReactProgressBarViewManager manages how this style is applied to the ProgressBar. - */ -@Suppress("DEPRECATION") -@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR) -@LegacyArchitectureShadowNodeWithCxxImpl -@Deprecated( - message = "This class is part of Legacy Architecture and will be removed in a future release", - level = DeprecationLevel.WARNING, -) -internal class ProgressBarShadowNode : - com.facebook.react.uimanager.LayoutShadowNode(), YogaMeasureFunction { - private val height: SparseIntArray = SparseIntArray() - private val width: SparseIntArray = SparseIntArray() - private val measured: MutableSet = HashSet() - - init { - setMeasureFunction(this) - } - - @set:ReactProp(name = ReactProgressBarViewManager.PROP_STYLE) - var style: String? = ReactProgressBarViewManager.DEFAULT_STYLE - set(value) { - field = value ?: ReactProgressBarViewManager.DEFAULT_STYLE - } - - override fun measure( - node: YogaNode, - width: Float, - widthMode: YogaMeasureMode, - height: Float, - heightMode: YogaMeasureMode, - ): Long { - val style = ReactProgressBarViewManager.getStyleFromString(style) - if (!measured.contains(style)) { - val progressBar = ReactProgressBarViewManager.createProgressBar(themedContext, style) - val spec = - View.MeasureSpec.makeMeasureSpec( - ViewGroup.LayoutParams.WRAP_CONTENT, - View.MeasureSpec.UNSPECIFIED, - ) - progressBar.measure(spec, spec) - this.height.put(style, progressBar.measuredHeight) - this.width.put(style, progressBar.measuredWidth) - measured.add(style) - } - return YogaMeasureOutput.make(this.width[style], this.height[style]) - } - - companion object { - init { - LegacyArchitectureLogger.assertLegacyArchitecture( - "ProgressBarShadowNode", - LegacyArchitectureLogLevel.ERROR, - ) - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ReactProgressBarViewManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ReactProgressBarViewManager.kt index 62486bd725b..93b28c4a43a 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ReactProgressBarViewManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ReactProgressBarViewManager.kt @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +@file:Suppress("DEPRECATION") + package com.facebook.react.views.progressbar import android.content.Context @@ -16,6 +18,7 @@ import com.facebook.react.bridge.ReadableMap import com.facebook.react.common.ReactConstants import com.facebook.react.module.annotations.ReactModule import com.facebook.react.uimanager.BaseViewManager +import com.facebook.react.uimanager.LayoutShadowNode import com.facebook.react.uimanager.PixelUtil.toDIPFromPixel import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.ViewManagerDelegate @@ -33,10 +36,9 @@ import java.util.WeakHashMap * a [ProgressBar] changes, we have to drop the existing [ProgressBar] (if there is one) and create * a new one with the style given. */ -@Suppress("DEPRECATION") @ReactModule(name = ReactProgressBarViewManager.REACT_CLASS) internal class ReactProgressBarViewManager : - BaseViewManager(), + BaseViewManager(), AndroidProgressBarManagerInterface { @Suppress("IDENTITY_SENSITIVE_OPERATIONS_WITH_VALUE_TYPE") private val measuredStyles = WeakHashMap>() @@ -82,10 +84,9 @@ internal class ReactProgressBarViewManager : @ReactProp(name = PROP_ATTR) override fun setTypeAttr(view: ProgressBarContainerView, value: String?): Unit = Unit - override fun createShadowNodeInstance(): ProgressBarShadowNode = ProgressBarShadowNode() + override fun createShadowNodeInstance(): LayoutShadowNode = LayoutShadowNode() - override fun getShadowNodeClass(): Class = - ProgressBarShadowNode::class.java + override fun getShadowNodeClass(): Class = LayoutShadowNode::class.java override fun updateExtraData(root: ProgressBarContainerView, extraData: Any) { // do nothing diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchManager.kt index e9a36bf990f..632cc3f13db 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchManager.kt @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +@file:Suppress("DEPRECATION") + package com.facebook.react.views.switchview import android.content.Context @@ -14,6 +16,7 @@ import androidx.annotation.ColorInt import com.facebook.react.bridge.ReactContext import com.facebook.react.bridge.ReadableMap import com.facebook.react.uimanager.BaseViewManager +import com.facebook.react.uimanager.LayoutShadowNode import com.facebook.react.uimanager.PixelUtil import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.UIManagerHelper @@ -25,19 +28,16 @@ import com.facebook.react.viewmanagers.AndroidSwitchManagerInterface import com.facebook.yoga.YogaMeasureMode import com.facebook.yoga.YogaMeasureOutput -@Suppress("DEPRECATION") internal class ReactSwitchManager : - BaseViewManager(), - AndroidSwitchManagerInterface { + BaseViewManager(), AndroidSwitchManagerInterface { private val delegate: ViewManagerDelegate = AndroidSwitchManagerDelegate(this) override fun getName(): String = REACT_CLASS - override fun createShadowNodeInstance(): ReactSwitchShadowNode = ReactSwitchShadowNode() + override fun createShadowNodeInstance(): LayoutShadowNode = LayoutShadowNode() - override fun getShadowNodeClass(): Class = - ReactSwitchShadowNode::class.java + override fun getShadowNodeClass(): Class = LayoutShadowNode::class.java override fun createViewInstance(context: ThemedReactContext): ReactSwitch = ReactSwitch(context).apply { showText = false } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchShadowNode.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchShadowNode.kt deleted file mode 100644 index c63f86b252a..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchShadowNode.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.views.switchview - -import android.view.View -import com.facebook.react.common.annotations.LegacyArchitectureShadowNodeWithCxxImpl -import com.facebook.react.common.annotations.internal.LegacyArchitecture -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger -import com.facebook.yoga.YogaMeasureFunction -import com.facebook.yoga.YogaMeasureMode -import com.facebook.yoga.YogaMeasureOutput -import com.facebook.yoga.YogaNode - -@Suppress("DEPRECATION") -@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR) -@Deprecated( - message = "This class is part of Legacy Architecture and will be removed in a future release", - level = DeprecationLevel.WARNING, -) -@LegacyArchitectureShadowNodeWithCxxImpl -internal class ReactSwitchShadowNode : - com.facebook.react.uimanager.LayoutShadowNode(), YogaMeasureFunction { - private var width = 0 - private var height = 0 - private var measured = false - - init { - initMeasureFunction() - } - - private fun initMeasureFunction() { - setMeasureFunction(this) - } - - override fun measure( - node: YogaNode, - width: Float, - widthMode: YogaMeasureMode, - height: Float, - heightMode: YogaMeasureMode, - ): Long { - if (!measured) { - // Create a switch with the default config and measure it; since we don't (currently) - // support setting custom switch text, this is fine, as all switches will measure the same - // on a specific device/theme/locale combination. - val reactSwitch = ReactSwitch(themedContext) - reactSwitch.showText = false - val spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED) - reactSwitch.measure(spec, spec) - this.width = reactSwitch.measuredWidth - this.height = reactSwitch.measuredHeight - measured = true - } - - return YogaMeasureOutput.make(this.width, this.height) - } - - companion object { - init { - LegacyArchitectureLogger.assertLegacyArchitecture( - "ReactSwitchShadowNode", - LegacyArchitectureLogLevel.ERROR, - ) - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.kt deleted file mode 100644 index 5341d7989aa..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.kt +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -@file:Suppress("DEPRECATION") - -package com.facebook.react.views.text - -import android.text.Spannable -import com.facebook.react.bridge.ReadableArray -import com.facebook.react.bridge.ReadableMap -import com.facebook.react.common.ReactConstants -import com.facebook.react.common.annotations.internal.LegacyArchitecture -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel -import com.facebook.react.uimanager.LayoutShadowNode -import com.facebook.react.uimanager.ReactShadowNode -import com.facebook.react.uimanager.ViewProps -import com.facebook.react.uimanager.annotations.ReactProp - -/** - * [ReactShadowNode] abstract class for spannable text nodes. - * - * This class handles all text attributes associated with ``-ish node. A concrete node can be - * an anchor `` node, an anchor `` node or virtual `` node inside `` or - * `` node. Or even something else. - * - * This also node calculates [Spannable] object based on sub nodes of the same type, which can be - * used in concrete classes to feed native views and compute layout. - */ -@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR) -@Deprecated( - message = "This class is part of Legacy Architecture and will be removed in a future release" -) -public abstract class ReactBaseTextShadowNode -@JvmOverloads -public constructor( - protected var reactTextViewManagerCallback: ReactTextViewManagerCallback? = null -) : LayoutShadowNode() { - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.NUMBER_OF_LINES, defaultInt = ReactConstants.UNSET) - public fun setNumberOfLines(numberOfLines: Int) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.LINE_HEIGHT, defaultFloat = Float.NaN) - public fun setLineHeight(lineHeight: Float) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.LETTER_SPACING, defaultFloat = 0f) - public fun setLetterSpacing(letterSpacing: Float) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.ALLOW_FONT_SCALING, defaultBoolean = true) - public fun setAllowFontScaling(allowFontScaling: Boolean) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.MAX_FONT_SIZE_MULTIPLIER, defaultFloat = Float.NaN) - public fun setMaxFontSizeMultiplier(maxFontSizeMultiplier: Float) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.TEXT_ALIGN) - public fun setTextAlign(textAlign: String?) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.FONT_SIZE, defaultFloat = Float.NaN) - public fun setFontSize(fontSize: Float) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.COLOR, customType = "Color") - public fun setColor(color: Int?) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.BACKGROUND_COLOR, customType = "Color") - public fun setBackgroundColor(color: Int?) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.ACCESSIBILITY_ROLE) - public fun setAccessibilityRole(accessibilityRole: String?) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.ROLE) - public fun setRole(role: String?) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.FONT_FAMILY) - public fun setFontFamily(fontFamily: String?) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.FONT_WEIGHT) - public fun setFontWeight(fontWeightString: String?) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.FONT_VARIANT) - public fun setFontVariant(fontVariantArray: ReadableArray?) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.FONT_STYLE) - public fun setFontStyle(fontStyleString: String?) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.INCLUDE_FONT_PADDING, defaultBoolean = true) - public fun setIncludeFontPadding(includepad: Boolean) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.TEXT_DECORATION_LINE) - public fun setTextDecorationLine(textDecorationLineString: String?) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.TEXT_BREAK_STRATEGY) - public open fun setTextBreakStrategy(textBreakStrategy: String?) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = PROP_SHADOW_OFFSET) - public fun setTextShadowOffset(offsetMap: ReadableMap?) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = PROP_SHADOW_RADIUS, defaultInt = 1) - public fun setTextShadowRadius(textShadowRadius: Float) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = PROP_SHADOW_COLOR, defaultInt = DEFAULT_TEXT_SHADOW_COLOR, customType = "Color") - public fun setTextShadowColor(textShadowColor: Int) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = PROP_TEXT_TRANSFORM) - public fun setTextTransform(textTransform: String?) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.ADJUSTS_FONT_SIZE_TO_FIT) - public fun setAdjustFontSizeToFit(adjustsFontSizeToFit: Boolean) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = ViewProps.MINIMUM_FONT_SCALE) - public fun setMinimumFontScale(minimumFontScale: Float) { - error( - "ReactBaseTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - public companion object { - public const val PROP_SHADOW_OFFSET: String = "textShadowOffset" - public const val PROP_SHADOW_OFFSET_WIDTH: String = "width" - public const val PROP_SHADOW_OFFSET_HEIGHT: String = "height" - public const val PROP_SHADOW_RADIUS: String = "textShadowRadius" - public const val PROP_SHADOW_COLOR: String = "textShadowColor" - - public const val PROP_TEXT_TRANSFORM: String = "textTransform" - - public const val DEFAULT_TEXT_SHADOW_COLOR: Int = 0x55000000 - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.kt deleted file mode 100644 index cd11ab732b4..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.kt +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -@file:Suppress("DEPRECATION") - -package com.facebook.react.views.text - -import com.facebook.react.common.annotations.internal.LegacyArchitecture -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel -import com.facebook.react.uimanager.NativeViewHierarchyOptimizer -import com.facebook.react.uimanager.ReactShadowNode -import com.facebook.react.uimanager.UIViewOperationQueue -import com.facebook.react.uimanager.annotations.ReactProp - -/** - * [ReactBaseTextShadowNode] concrete class for anchor `Text` node. - * - * The class measures text in `` view and feeds native [TextView] using [Spannable] object - * constructed in superclass. - */ -@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR) -@Deprecated( - message = "This class is part of Legacy Architecture and will be removed in a future release", - level = DeprecationLevel.WARNING, -) -public class ReactTextShadowNode -@JvmOverloads -public constructor(reactTextViewManagerCallback: ReactTextViewManagerCallback? = null) : - ReactBaseTextShadowNode(reactTextViewManagerCallback) { - - override fun isVirtualAnchor(): Boolean { - error( - "ReactTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - override fun hoistNativeChildren(): Boolean { - error( - "ReactTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - override fun markUpdated() { - error( - "ReactTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - override fun onBeforeLayout(nativeViewHierarchyOptimizer: NativeViewHierarchyOptimizer) { - error( - "ReactTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - override fun onCollectExtraUpdates(uiViewOperationQueue: UIViewOperationQueue) { - error( - "ReactTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = "onTextLayout") - public fun setShouldNotifyOnTextLayout(shouldNotifyOnTextLayout: Boolean) { - error( - "ReactTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - override fun calculateLayoutOnChildren(): Iterable?>? { - error( - "ReactTextShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.kt index 47ed95d420b..2e3669c113d 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.kt @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +@file:Suppress("DEPRECATION") + package com.facebook.react.views.text import android.os.Build @@ -25,6 +27,7 @@ import com.facebook.react.module.annotations.ReactModule import com.facebook.react.uimanager.BackgroundStyleApplicator import com.facebook.react.uimanager.BaseViewManager import com.facebook.react.uimanager.IViewManagerWithChildren +import com.facebook.react.uimanager.LayoutShadowNode import com.facebook.react.uimanager.LengthPercentage import com.facebook.react.uimanager.LengthPercentageType import com.facebook.react.uimanager.ReactStylesDiffMap @@ -41,7 +44,6 @@ import com.facebook.react.views.text.DefaultStyleValuesUtil.getDefaultTextColorH import java.util.HashMap /** View manager for `` nodes. */ -@Suppress("DEPRECATION") @ReactModule(name = ReactTextViewManager.REACT_CLASS) @OptIn(UnstableReactNativeAPI::class) public class ReactTextViewManager @@ -49,7 +51,7 @@ public class ReactTextViewManager public constructor( protected var reactTextViewManagerCallback: ReactTextViewManagerCallback? = null ) : - BaseViewManager(), + BaseViewManager(), IViewManagerWithChildren, ReactTextViewManagerCallback { init { @@ -108,14 +110,13 @@ public constructor( } } - override fun createShadowNodeInstance(): ReactTextShadowNode = - ReactTextShadowNode(reactTextViewManagerCallback) + override fun createShadowNodeInstance(): LayoutShadowNode = LayoutShadowNode() public fun createShadowNodeInstance( reactTextViewManagerCallback: ReactTextViewManagerCallback? - ): ReactTextShadowNode = ReactTextShadowNode(reactTextViewManagerCallback) + ): LayoutShadowNode = LayoutShadowNode() - override fun getShadowNodeClass(): Class = ReactTextShadowNode::class.java + override fun getShadowNodeClass(): Class = LayoutShadowNode::class.java override fun onAfterUpdateTransaction(view: ReactTextView) { super.onAfterUpdateTransaction(view) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt index 4c0fb6a4ba8..21fbfb4d06d 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt @@ -66,7 +66,6 @@ import com.facebook.react.views.scroll.ScrollEventType.Companion.getJSEventName import com.facebook.react.views.text.DefaultStyleValuesUtil.getDefaultTextColor import com.facebook.react.views.text.DefaultStyleValuesUtil.getDefaultTextColorHighlight import com.facebook.react.views.text.DefaultStyleValuesUtil.getDefaultTextColorHint -import com.facebook.react.views.text.ReactBaseTextShadowNode import com.facebook.react.views.text.ReactTextUpdate import com.facebook.react.views.text.ReactTextUpdate.Companion.buildReactTextUpdateFromState import com.facebook.react.views.text.ReactTextViewManagerCallback @@ -100,14 +99,13 @@ public open class ReactTextInputManager public constructor() : return editText } - override fun createShadowNodeInstance(): ReactBaseTextShadowNode = ReactTextInputShadowNode() + override fun createShadowNodeInstance(): LayoutShadowNode = LayoutShadowNode() public fun createShadowNodeInstance( reactTextViewManagerCallback: ReactTextViewManagerCallback? - ): ReactBaseTextShadowNode = ReactTextInputShadowNode(reactTextViewManagerCallback) + ): LayoutShadowNode = LayoutShadowNode() - override fun getShadowNodeClass(): Class = - ReactTextInputShadowNode::class.java + override fun getShadowNodeClass(): Class = LayoutShadowNode::class.java override fun getExportedCustomBubblingEventTypeConstants(): Map { val baseEventTypeConstants = super.getExportedCustomBubblingEventTypeConstants() @@ -326,7 +324,7 @@ public open class ReactTextInputManager public constructor() : } // Sets the letter spacing as an absolute point size. - // This extra handling, on top of what ReactBaseTextShadowNode already does, is required for the + // This extra handling is required for the // correct display of spacing in placeholder (hint) text. @ReactProp(name = ViewProps.LETTER_SPACING, defaultFloat = 0f) public fun setLetterSpacing(view: ReactEditText, letterSpacing: Float) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.kt deleted file mode 100644 index 7f39e1936f3..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.kt +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -@file:Suppress("DEPRECATION") - -package com.facebook.react.views.textinput - -import com.facebook.react.common.annotations.LegacyArchitectureShadowNodeWithCxxImpl -import com.facebook.react.common.annotations.internal.LegacyArchitecture -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger -import com.facebook.react.uimanager.ThemedReactContext -import com.facebook.react.uimanager.UIViewOperationQueue -import com.facebook.react.uimanager.annotations.ReactProp -import com.facebook.react.views.text.ReactBaseTextShadowNode -import com.facebook.react.views.text.ReactTextViewManagerCallback -import com.facebook.yoga.YogaMeasureFunction -import com.facebook.yoga.YogaMeasureMode -import com.facebook.yoga.YogaNode - -@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR) -@LegacyArchitectureShadowNodeWithCxxImpl -@Deprecated( - message = "This class is part of Legacy Architecture and will be removed in a future release", - level = DeprecationLevel.WARNING, -) -internal class ReactTextInputShadowNode -@JvmOverloads -constructor(reactTextViewManagerCallback: ReactTextViewManagerCallback? = null) : - ReactBaseTextShadowNode(reactTextViewManagerCallback), YogaMeasureFunction { - - @Suppress("UNUSED_PARAMETER") - @set:ReactProp(name = PROP_TEXT) - var text: String? = null - set(_) { - error( - "ReactTextInputShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @set:ReactProp(name = PROP_PLACEHOLDER) - var placeholder: String? = null - set(_) { - error( - "ReactTextInputShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - override fun setThemedContext(themedContext: ThemedReactContext) { - error( - "ReactTextInputShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - override fun measure( - node: YogaNode, - width: Float, - widthMode: YogaMeasureMode, - height: Float, - heightMode: YogaMeasureMode, - ): Long { - error( - "ReactTextInputShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - override fun isVirtualAnchor(): Boolean { - error( - "ReactTextInputShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - override fun isYogaLeafNode(): Boolean { - error( - "ReactTextInputShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - override fun setLocalData(data: Any) { - error( - "ReactTextInputShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - @ReactProp(name = "mostRecentEventCount") - public fun setMostRecentEventCount(mostRecentEventCount: Int) { - error( - "ReactTextInputShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - override fun setTextBreakStrategy(textBreakStrategy: String?) { - error( - "ReactTextInputShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - override fun onCollectExtraUpdates(uiViewOperationQueue: UIViewOperationQueue) { - error( - "ReactTextInputShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - @Suppress("UNUSED_PARAMETER") - override fun setPadding(spacingType: Int, padding: Float) { - error( - "ReactTextInputShadowNode methods are unsupported, and the ShadowNode will be fully removed in a future version of React Native." - ) - } - - companion object { - const val PROP_TEXT: String = "text" - - const val PROP_PLACEHOLDER: String = "placeholder" - - init { - LegacyArchitectureLogger.assertLegacyArchitecture( - "ReactTextInputShadowNode", - LegacyArchitectureLogLevel.ERROR, - ) - } - } -}