xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricComponents.java (#45673)

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

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D60233417

fbshipit-source-id: f5506b8d2bf0e2246c8578c0c1c13ddd62507ee0
This commit is contained in:
Andrew Datsenko
2024-07-26 08:53:10 -07:00
committed by Facebook GitHub Bot
parent 87ff232a6b
commit 77dfa43e43
3 changed files with 47 additions and 57 deletions
@@ -2586,9 +2586,9 @@ public final class com/facebook/react/fabric/EmptyReactNativeConfig : com/facebo
public fun getString (Ljava/lang/String;)Ljava/lang/String;
}
public class com/facebook/react/fabric/FabricComponents {
public fun <init> ()V
public static fun getFabricComponentName (Ljava/lang/String;)Ljava/lang/String;
public final class com/facebook/react/fabric/FabricComponents {
public static final field INSTANCE Lcom/facebook/react/fabric/FabricComponents;
public static final fun getFabricComponentName (Ljava/lang/String;)Ljava/lang/String;
}
public final class com/facebook/react/fabric/FabricSoLoader {
@@ -1,54 +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.fabric;
import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Nullsafe;
import java.util.HashMap;
import java.util.Map;
/**
* Utility class for Fabric components, this will be removed
*
* <p>TODO T97384889: remove this class when the component names are unified between JS - Android -
* iOS - C++
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
public class FabricComponents {
private static @NonNull final Map<String, String> sComponentNames = new HashMap<>();
static {
// TODO T97384889: unify component names between JS - Android - iOS - C++
sComponentNames.put("View", "RCTView");
sComponentNames.put("Image", "RCTImageView");
sComponentNames.put("ScrollView", "RCTScrollView");
sComponentNames.put("Slider", "RCTSlider");
sComponentNames.put("ModalHostView", "RCTModalHostView");
sComponentNames.put("Paragraph", "RCTText");
sComponentNames.put("Text", "RCText");
sComponentNames.put("RawText", "RCTRawText");
sComponentNames.put("ActivityIndicatorView", "AndroidProgressBar");
sComponentNames.put("ShimmeringView", "RKShimmeringView");
sComponentNames.put("TemplateView", "RCTTemplateView");
sComponentNames.put("AxialGradientView", "RCTAxialGradientView");
sComponentNames.put("Video", "RCTVideo");
sComponentNames.put("Map", "RCTMap");
sComponentNames.put("WebView", "RCTWebView");
sComponentNames.put("Keyframes", "RCTKeyframes");
sComponentNames.put("ImpressionTrackingView", "RCTImpressionTrackingView");
}
/**
* @return the name of component in the Fabric environment
*/
public static String getFabricComponentName(String componentName) {
String component = sComponentNames.get(componentName);
return component != null ? component : componentName;
}
}
@@ -0,0 +1,44 @@
/*
* 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.fabric
/**
* Utility class for Fabric components, this will be removed
*
* TODO T97384889: remove this class when the component names are unified between JS - Android -
* iOS - C++
*/
public object FabricComponents {
// TODO T97384889: unify component names between JS - Android - iOS - C++
private val componentNames: Map<String, String> =
mapOf(
"View" to "RCTView",
"Image" to "RCTImageView",
"ScrollView" to "RCTScrollView",
"Slider" to "RCTSlider",
"ModalHostView" to "RCTModalHostView",
"Paragraph" to "RCTText",
"Text" to "RCText",
"RawText" to "RCTRawText",
"ActivityIndicatorView" to "AndroidProgressBar",
"ShimmeringView" to "RKShimmeringView",
"TemplateView" to "RCTTemplateView",
"AxialGradientView" to "RCTAxialGradientView",
"Video" to "RCTVideo",
"Map" to "RCTMap",
"WebView" to "RCTWebView",
"Keyframes" to "RCTKeyframes",
"ImpressionTrackingView" to "RCTImpressionTrackingView",
)
/** @return the name of component in the Fabric environment */
@JvmStatic
public fun getFabricComponentName(componentName: String): String =
componentNames.get(componentName) ?: componentName
}