mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Refactor sComponentNames Map out of FabricUIManager
Summary: Easy diff to refactor the sComponentNames map out of the FabricUIManager class. This is a necessary clean-up to perform a slightly major refactor of the Fabric classes Reviewed By: JoshuaGross Differential Revision: D15421769 fbshipit-source-id: 3be73a6e20b338c8cea23ef0c88db417df7e3aa9
This commit is contained in:
committed by
Facebook Github Bot
parent
3b8fc8b10a
commit
563e0bce97
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its 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 java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Utility class for Fabric components, this will be removed
|
||||
*
|
||||
* <p>//TODO T31905686: remove this class when the component names are unified between JS - Android
|
||||
* - iOS - C++
|
||||
*/
|
||||
public class FabricComponents {
|
||||
|
||||
private static final Map<String, String> sComponentNames = new HashMap<>();
|
||||
|
||||
static {
|
||||
// TODO T31905686: 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");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of component in the Fabric environment
|
||||
*/
|
||||
static String getFabricComponentName(String componentName) {
|
||||
String component = sComponentNames.get(componentName);
|
||||
return component != null ? component : componentName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -96,6 +96,7 @@ public class FabricJSIModuleProvider implements JSIModuleProvider<UIManager> {
|
||||
private static void loadClasses() {
|
||||
BatchEventDispatchedListener.class.getClass();
|
||||
ReactNativeConfig.class.getClass();
|
||||
FabricComponents.class.getClass();
|
||||
ViewManagerFactory.class.getClass();
|
||||
StateWrapper.class.getClass();
|
||||
ViewFactory.class.getClass();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
package com.facebook.react.fabric;
|
||||
|
||||
import static com.facebook.infer.annotation.ThreadConfined.UI;
|
||||
import static com.facebook.react.fabric.FabricComponents.getFabricComponentName;
|
||||
import static com.facebook.react.fabric.mounting.LayoutMetricsConversions.getMaxSize;
|
||||
import static com.facebook.react.fabric.mounting.LayoutMetricsConversions.getMinSize;
|
||||
import static com.facebook.react.fabric.mounting.LayoutMetricsConversions.getYogaMeasureMode;
|
||||
@@ -15,10 +16,10 @@ import static com.facebook.react.uimanager.common.UIManagerType.FABRIC;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.SystemClock;
|
||||
import android.view.View;
|
||||
import androidx.annotation.GuardedBy;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.UiThread;
|
||||
import android.view.View;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.debug.holder.PrinterHolder;
|
||||
import com.facebook.debug.tags.ReactDebugOverlayTags;
|
||||
@@ -38,9 +39,9 @@ import com.facebook.react.fabric.jsi.Binding;
|
||||
import com.facebook.react.fabric.jsi.EventBeatManager;
|
||||
import com.facebook.react.fabric.jsi.EventEmitterWrapper;
|
||||
import com.facebook.react.fabric.jsi.FabricSoLoader;
|
||||
import com.facebook.react.fabric.mounting.mountitems.CreateMountItem;
|
||||
import com.facebook.react.fabric.mounting.MountingManager;
|
||||
import com.facebook.react.fabric.mounting.mountitems.BatchMountItem;
|
||||
import com.facebook.react.fabric.mounting.mountitems.CreateMountItem;
|
||||
import com.facebook.react.fabric.mounting.mountitems.DeleteMountItem;
|
||||
import com.facebook.react.fabric.mounting.mountitems.DispatchCommandMountItem;
|
||||
import com.facebook.react.fabric.mounting.mountitems.InsertMountItem;
|
||||
@@ -73,27 +74,12 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
|
||||
public static final String TAG = FabricUIManager.class.getSimpleName();
|
||||
public static final boolean DEBUG =
|
||||
PrinterHolder.getPrinter().shouldDisplayLogMessage(ReactDebugOverlayTags.FABRIC_UI_MANAGER);
|
||||
private static final Map<String, String> sComponentNames = new HashMap<>();
|
||||
private static final int FRAME_TIME_MS = 16;
|
||||
private static final int MAX_TIME_IN_FRAME_FOR_NON_BATCHED_OPERATIONS_MS = 8;
|
||||
private static final int PRE_MOUNT_ITEMS_INITIAL_SIZE_ARRAY = 250;
|
||||
|
||||
static {
|
||||
FabricSoLoader.staticInit();
|
||||
|
||||
// TODO T31905686: 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");
|
||||
}
|
||||
|
||||
private Binding mBinding;
|
||||
@@ -192,7 +178,7 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
|
||||
@Nullable ReadableMap props,
|
||||
boolean isLayoutable) {
|
||||
ThemedReactContext context = mReactContextForRootTag.get(rootTag);
|
||||
String component = getComponent(componentName);
|
||||
String component = getFabricComponentName(componentName);
|
||||
synchronized (mPreMountItemsLock) {
|
||||
mPreMountItems.add(
|
||||
new PreAllocateViewMountItem(
|
||||
@@ -205,16 +191,11 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
private String getComponent(String componentName) {
|
||||
String component = sComponentNames.get(componentName);
|
||||
return component != null ? component : componentName;
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
@SuppressWarnings("unused")
|
||||
private MountItem createMountItem(
|
||||
String componentName, int reactRootTag, int reactTag, boolean isLayoutable) {
|
||||
String component = getComponent(componentName);
|
||||
String component = getFabricComponentName(componentName);
|
||||
ThemedReactContext reactContext = mReactContextForRootTag.get(reactRootTag);
|
||||
if (reactContext == null) {
|
||||
throw new IllegalArgumentException("Unable to find ReactContext for root: " + reactRootTag);
|
||||
|
||||
Reference in New Issue
Block a user