Migrate com.facebook.react.views.text.ReactRawTextManager to Kotlin (#47571)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47571

As per title.

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D65600851

fbshipit-source-id: cd88beca23f5d7b1036354457e67d0d530e62a95
This commit is contained in:
Fabrizio Cucci 2024-11-12 08:30:35 -08:00 committed by Facebook GitHub Bot
parent fe1057afcd
commit 6f59627903
3 changed files with 47 additions and 57 deletions

View File

@ -7276,7 +7276,8 @@ public final class com/facebook/react/views/text/ReactFontManager$Companion {
public final fun getInstance ()Lcom/facebook/react/views/text/ReactFontManager;
}
public class com/facebook/react/views/text/ReactRawTextManager : com/facebook/react/uimanager/ViewManager {
public final class com/facebook/react/views/text/ReactRawTextManager : com/facebook/react/uimanager/ViewManager {
public static final field REACT_CLASS Ljava/lang/String;
public fun <init> ()V
public synthetic fun createShadowNodeInstance ()Lcom/facebook/react/uimanager/ReactShadowNode;
public fun createShadowNodeInstance ()Lcom/facebook/react/views/text/ReactRawTextShadowNode;
@ -7284,7 +7285,6 @@ public class com/facebook/react/views/text/ReactRawTextManager : com/facebook/re
public fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Lcom/facebook/react/views/text/ReactTextView;
public fun getName ()Ljava/lang/String;
public fun getShadowNodeClass ()Ljava/lang/Class;
protected fun prepareToRecycleView (Lcom/facebook/react/uimanager/ThemedReactContext;Landroid/view/View;)Landroid/view/View;
public fun updateExtraData (Landroid/view/View;Ljava/lang/Object;)V
}

View File

@ -1,55 +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.text;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.ViewManager;
/**
* Manages raw text nodes (aka {@code textContent} in terms of DOM). Since they are used only as a
* virtual nodes, any type of native view operation will throw an {@link IllegalStateException}.
*/
@ReactModule(name = ReactRawTextManager.REACT_CLASS)
public class ReactRawTextManager extends ViewManager<View, ReactRawTextShadowNode> {
@VisibleForTesting public static final String REACT_CLASS = "RCTRawText";
@Override
public String getName() {
return REACT_CLASS;
}
@Override
public ReactTextView createViewInstance(ThemedReactContext context) {
throw new IllegalStateException("Attempt to create a native view for RCTRawText");
}
@Override
protected @Nullable View prepareToRecycleView(
@NonNull ThemedReactContext reactContext, @NonNull View view) {
throw new IllegalStateException("Attempt to recycle a native view for RCTRawText");
}
@Override
public void updateExtraData(View view, Object extraData) {}
@Override
public Class<ReactRawTextShadowNode> getShadowNodeClass() {
return ReactRawTextShadowNode.class;
}
@Override
public ReactRawTextShadowNode createShadowNodeInstance() {
return new ReactRawTextShadowNode();
}
}

View File

@ -0,0 +1,45 @@
/*
* 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.text
import android.view.View
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.ViewManager
/**
* Manages raw text nodes (aka `textContent` in terms of DOM). Since they are used only as a virtual
* nodes, any type of native view operation will throw an [IllegalStateException].
*/
@ReactModule(name = ReactRawTextManager.REACT_CLASS)
public class ReactRawTextManager : ViewManager<View, ReactRawTextShadowNode>() {
override public fun getName(): String {
return REACT_CLASS
}
override public fun createViewInstance(context: ThemedReactContext): ReactTextView =
throw IllegalStateException("Attempt to create a native view for RCTRawText")
override protected fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? =
throw IllegalStateException("Attempt to recycle a native view for RCTRawText")
override public fun updateExtraData(view: View, extraData: Any): Unit = Unit
override public fun getShadowNodeClass(): Class<ReactRawTextShadowNode> {
return ReactRawTextShadowNode::class.java
}
override public fun createShadowNodeInstance(): ReactRawTextShadowNode {
return ReactRawTextShadowNode()
}
internal companion object {
public const val REACT_CLASS: String = "RCTRawText"
}
}