From 50fe8119de397794c566e77588e0a2f76b5fa112 Mon Sep 17 00:00:00 2001 From: Oleksandr Melnykov Date: Mon, 12 Aug 2019 06:32:20 -0700 Subject: [PATCH] Use ViewManagerDelegate if provided instead of $$PropsSetter to update view props MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: This diff introduces an interface `ViewManagerDelegate` and its base implementation `BaseViewManagerDelegate`, which is used as a parent class for all view manager delegates generated by the JS codegen. Before the changes in this diff, generated delegates didn't support setting the base view properties such as background color, rotation, opacity, etc. Now it's possible to do by using `BaseViewManagerDelegate.setProperty(...)`, and since all generated delegates extend BaseViewManagerDelegate, they can just call `super.setProperty(...)` for properties they don't want to handle. This diff also introduced a new method `ViewManager.getDelegate()`. This will allow view managers to return an instance of the delegate generated by JS and ensure that the view properties are set in a type-safe manner. If this method returns null (it does by default), we fall back to the default implementation of setting view properties using Java-generated `$$PropsSetter` classes. This is an example of an interface class generated by JS: ``` public interface RCTAxialGradientViewViewManagerInterface { void setColors(T view, Nullable ReadableArray value); void setLocations(T view, Nullable ReadableArray value); void setEndX(T view, Float value); void setEndY(T view, Float value); void setStartX(T view, Float value); void setStartY(T view, Float value); } ``` This is an example of a delegate class generated by JS: ``` public class RCTAxialGradientViewManagerDelegate & RCTAxialGradientViewManagerInterface> extends BaseViewManagerDelegate { public RCTAxialGradientViewManagerDelegate(U viewManager) { super(viewManager); } Override public void setProperty(T view, String propName, Nullable Object value) { switch (propName) { case "colors": mViewManager.setColors(view, (ReadableArray) value); break; case "locations": mViewManager.setLocations(view, (ReadableArray) value); break; case "endX": mViewManager.setEndX(view, value == null ? Float.NaN : ((Double) value).floatValue()); break; case "endY": mViewManager.setEndY(view, value == null ? Float.NaN : ((Double) value).floatValue()); break; case "startX": mViewManager.setStartX(view, value == null ? Float.NaN : ((Double) value).floatValue()); break; case "startY": mViewManager.setStartY(view, value == null ? Float.NaN : ((Double) value).floatValue()); break; default: super.setProperty(view, propName, value); } } } ``` NOTE: What if a view manager, for instance ReactAxialGradientManager, wanted to add support for the borderRadius prop? In the old Java codegen, it would just need to create a method and annotate it with ReactProp (name = ViewProps.BORDER_RADIUS) and $$PropsSetter would call this method when a property with this name must be set. With the new JS codegen, borderRadius is a part of the basic view props, so setBorderRadius is not generated as a part of the ViewManagerInterface, so it’s not possible to set this value. I see two options: 1) add a method boolean setProperty (String propName, Object value) and let the view manager handle it in a non-type safe way (return true if it’s been handled). 2) Generate BaseViewManagerInterface which will include all basic view props and make BaseViewManager implement this interface, leaving all methods empty so that it stays compatible with the current implementation. Override these methods in a view manager that needs to handle a specific property in a custom way (so we would override setBorderRadius in ReactAxialGradientManager). Reviewed By: mdvacca Differential Revision: D16667686 fbshipit-source-id: 06a15a92f8af55640b7a53c5a34f40366d1be2a8 --- .../react/uimanager/BaseViewManager.java | 69 +-- .../uimanager/BaseViewManagerDelegate.java | 90 ++++ .../facebook/react/uimanager/ViewManager.java | 24 +- .../react/uimanager/ViewManagerDelegate.java | 14 + .../uimanager/ViewManagerPropertyUpdater.java | 9 + .../facebook/react/uimanager/ViewProps.java | 25 + packages/react-native-codegen/DEFS.bzl | 1 + .../ArrayPropsNativeComponentViewManager.java | 6 +- ...BooleanPropNativeComponentViewManager.java | 5 +- .../ColorPropNativeComponentViewManager.java | 4 +- .../EnumPropNativeComponentViewManager.java | 4 +- ...ObjectPropsNativeComponentViewManager.java | 5 +- .../EventPropsNativeComponentViewManager.java | 4 +- .../FloatPropsNativeComponentViewManager.java | 4 +- .../ImagePropNativeComponentViewManager.java | 4 +- ...IntegerPropNativeComponentViewManager.java | 4 +- ...terfaceOnlyNativeComponentViewManager.java | 5 +- ...iNativePropNativeComponentViewManager.java | 5 +- ...opsNoEventsNativeComponentViewManager.java | 5 +- .../PointPropNativeComponentViewManager.java | 4 +- .../StringPropNativeComponentViewManager.java | 4 +- .../components/ArrayPropsNativeComponent.js | 2 +- .../components/BooleanPropNativeComponent.js | 2 +- .../components/ColorPropNativeComponent.js | 2 +- .../components/EnumPropNativeComponent.js | 2 +- .../EventNestedObjectPropsNativeComponent.js | 2 +- .../components/EventPropsNativeComponent.js | 2 +- .../components/FloatPropsNativeComponent.js | 2 +- .../components/ImagePropNativeComponent.js | 2 +- .../components/IntegerPropNativeComponent.js | 2 +- .../InterfaceOnlyNativeComponent.js | 2 +- .../MultiNativePropNativeComponent.js | 2 +- .../NoPropsNoEventsNativeComponent.js | 2 +- .../components/PointPropNativeComponent.js | 2 +- .../components/StringPropNativeComponent.js | 2 +- .../components/GeneratePropsJavaDelegate.js | 20 +- .../components/GeneratePropsJavaInterface.js | 2 +- .../GeneratePropsJavaDelegate-test.js.snap | 436 +++++++++++++----- .../GeneratePropsJavaInterface-test.js.snap | 84 ++-- 39 files changed, 611 insertions(+), 254 deletions(-) create mode 100644 ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.java create mode 100644 ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.java diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java index d613f2fd3df69a..f3d841f6505ebb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java @@ -34,35 +34,9 @@ public abstract class BaseViewManager extends ViewManager { - private static final String PROP_BACKGROUND_COLOR = ViewProps.BACKGROUND_COLOR; - private static final String PROP_TRANSFORM = "transform"; - private static final String PROP_ELEVATION = "elevation"; - private static final String PROP_Z_INDEX = "zIndex"; - private static final String PROP_RENDER_TO_HARDWARE_TEXTURE = "renderToHardwareTextureAndroid"; - private static final String PROP_ACCESSIBILITY_LABEL = "accessibilityLabel"; - private static final String PROP_ACCESSIBILITY_HINT = "accessibilityHint"; - private static final String PROP_ACCESSIBILITY_LIVE_REGION = "accessibilityLiveRegion"; - private static final String PROP_ACCESSIBILITY_ROLE = "accessibilityRole"; - private static final String PROP_ACCESSIBILITY_STATES = "accessibilityStates"; - private static final String PROP_ACCESSIBILITY_STATE = "accessibilityState"; - private static final String PROP_ACCESSIBILITY_ACTIONS = "accessibilityActions"; - private static final String PROP_IMPORTANT_FOR_ACCESSIBILITY = "importantForAccessibility"; - - // DEPRECATED - private static final String PROP_ROTATION = "rotation"; - private static final String PROP_SCALE_X = "scaleX"; - private static final String PROP_SCALE_Y = "scaleY"; - private static final String PROP_TRANSLATE_X = "translateX"; - private static final String PROP_TRANSLATE_Y = "translateY"; - private static final int PERSPECTIVE_ARRAY_INVERTED_CAMERA_DISTANCE_INDEX = 2; private static final float CAMERA_DISTANCE_NORMALIZATION_MULTIPLIER = (float) Math.sqrt(5); - /** Used to locate views in end-to-end (UI) tests. */ - public static final String PROP_TEST_ID = "testID"; - - public static final String PROP_NATIVE_ID = "nativeID"; - private static MatrixMathHelper.MatrixDecompositionContext sMatrixDecompositionContext = new MatrixMathHelper.MatrixDecompositionContext(); private static double[] sTransformDecompositionArray = new double[16]; @@ -84,12 +58,15 @@ public abstract class BaseViewManager> + implements ViewManagerDelegate { + protected final U mViewManager; + + public BaseViewManagerDelegate(U viewManager) { + mViewManager = viewManager; + } + + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + switch (propName) { + case ViewProps.ACCESSIBILITY_ACTIONS: + mViewManager.setAccessibilityActions(view, (ReadableArray) value); + break; + case ViewProps.ACCESSIBILITY_HINT: + mViewManager.setAccessibilityHint(view, (String) value); + break; + case ViewProps.ACCESSIBILITY_LABEL: + mViewManager.setAccessibilityLabel(view, (String) value); + break; + case ViewProps.ACCESSIBILITY_LIVE_REGION: + mViewManager.setAccessibilityLiveRegion(view, (String) value); + break; + case ViewProps.ACCESSIBILITY_ROLE: + mViewManager.setAccessibilityRole(view, (String) value); + break; + case ViewProps.ACCESSIBILITY_STATE: + mViewManager.setViewState(view, (ReadableMap) value); + break; + case ViewProps.ACCESSIBILITY_STATES: + mViewManager.setViewStates(view, (ReadableArray) value); + break; + case ViewProps.BACKGROUND_COLOR: + mViewManager.setBackgroundColor(view, value == null ? 0 : ((Double) value).intValue()); + break; + case ViewProps.ELEVATION: + mViewManager.setElevation(view, value == null ? 0.0f : ((Double) value).floatValue()); + break; + case ViewProps.IMPORTANT_FOR_ACCESSIBILITY: + mViewManager.setImportantForAccessibility(view, (String) value); + break; + case ViewProps.NATIVE_ID: + mViewManager.setNativeId(view, (String) value); + break; + case ViewProps.OPACITY: + mViewManager.setOpacity(view, value == null ? 1.0f : ((Double) value).floatValue()); + break; + case ViewProps.RENDER_TO_HARDWARE_TEXTURE: + //noinspection SimplifiableConditionalExpression + mViewManager.setRenderToHardwareTexture(view, value == null ? false : (boolean) value); + break; + case ViewProps.ROTATION: + mViewManager.setRotation(view, value == null ? 0.0f : ((Double) value).floatValue()); + break; + case ViewProps.SCALE_X: + mViewManager.setScaleX(view, value == null ? 1.0f : ((Double) value).floatValue()); + break; + case ViewProps.SCALE_Y: + mViewManager.setScaleY(view, value == null ? 1.0f : ((Double) value).floatValue()); + break; + case ViewProps.TEST_ID: + mViewManager.setTestId(view, (String) value); + break; + case ViewProps.TRANSFORM: + mViewManager.setTransform(view, (ReadableArray) value); + break; + case ViewProps.TRANSLATE_X: + mViewManager.setTranslateX(view, value == null ? 0.0f : ((Double) value).floatValue()); + break; + case ViewProps.TRANSLATE_Y: + mViewManager.setTranslateY(view, value == null ? 0.0f : ((Double) value).floatValue()); + break; + case ViewProps.Z_INDEX: + mViewManager.setZIndex(view, value == null ? 0.0f : ((Double) value).floatValue()); + break; + } + } +} diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java index 084e9d61ab1938..8f894dea57b452 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java @@ -40,10 +40,32 @@ public abstract class ViewManager * @param stateWrapper */ public void updateProperties(@NonNull T viewToUpdate, ReactStylesDiffMap props) { - ViewManagerPropertyUpdater.updateProps(this, viewToUpdate, props); + final ViewManagerDelegate delegate = getDelegate(); + if (delegate != null) { + ViewManagerPropertyUpdater.updateProps(delegate, viewToUpdate, props); + } else { + ViewManagerPropertyUpdater.updateProps(this, viewToUpdate, props); + } onAfterUpdateTransaction(viewToUpdate); } + /** + * Override this method and return an instance of {@link ViewManagerDelegate} if the props of the + * view managed by this view manager should be set via this delegate. The provided instance will + * then get calls to {@link ViewManagerDelegate#setProperty(View, String, Object)} for every prop + * that must be updated and it's the delegate's responsibility to apply these values to the view. + * + *

By default this method returns {@code null}, which means that the view manager doesn't have + * a delegate and the view props should be set internally by the view manager itself. + * + * @return an instance of {@link ViewManagerDelegate} if the props of the view managed by this + * view manager should be set via this delegate + */ + @Nullable + protected ViewManagerDelegate getDelegate() { + return null; + } + /** Creates a view and installs event emitters on it. */ private final @NonNull T createView( @NonNull ThemedReactContext reactContext, JSResponderHandler jsResponderHandler) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.java new file mode 100644 index 00000000000000..6ca8c5e9b021dc --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.java @@ -0,0 +1,14 @@ +package com.facebook.react.uimanager; + +import android.view.View; +import androidx.annotation.Nullable; + +/** + * This is an interface that must be implemented by classes that wish to take over the + * responsibility of setting properties of all views managed by the view manager. + * + * @param the type of the view supported by this delegate + */ +public interface ViewManagerDelegate { + void setProperty(T view, String propName, @Nullable Object value); +} diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerPropertyUpdater.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerPropertyUpdater.java index bb1d5588d69dcf..3431dc401ec224 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerPropertyUpdater.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerPropertyUpdater.java @@ -36,6 +36,15 @@ public static void clear() { SHADOW_NODE_SETTER_MAP.clear(); } + public static , V extends View> void updateProps( + T delegate, V v, ReactStylesDiffMap props) { + Iterator> iterator = props.mBackingMap.getEntryIterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + delegate.setProperty(v, entry.getKey(), entry.getValue()); + } + } + public static void updateProps( T manager, V v, ReactStylesDiffMap props) { ViewManagerSetter setter = findManagerSetter(manager.getClass()); diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java index 2828dce3f77542..8e86e7d8e22443 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java @@ -131,6 +131,31 @@ public class ViewProps { public static final String BORDER_END_COLOR = "borderEndColor"; public static final String ON_LAYOUT = "onLayout"; + public static final String TRANSFORM = "transform"; + public static final String ELEVATION = "elevation"; + public static final String Z_INDEX = "zIndex"; + public static final String RENDER_TO_HARDWARE_TEXTURE = "renderToHardwareTextureAndroid"; + public static final String ACCESSIBILITY_LABEL = "accessibilityLabel"; + public static final String ACCESSIBILITY_HINT = "accessibilityHint"; + public static final String ACCESSIBILITY_LIVE_REGION = "accessibilityLiveRegion"; + public static final String ACCESSIBILITY_ROLE = "accessibilityRole"; + public static final String ACCESSIBILITY_STATES = "accessibilityStates"; + public static final String ACCESSIBILITY_STATE = "accessibilityState"; + public static final String ACCESSIBILITY_ACTIONS = "accessibilityActions"; + public static final String IMPORTANT_FOR_ACCESSIBILITY = "importantForAccessibility"; + + // DEPRECATED + public static final String ROTATION = "rotation"; + public static final String SCALE_X = "scaleX"; + public static final String SCALE_Y = "scaleY"; + public static final String TRANSLATE_X = "translateX"; + public static final String TRANSLATE_Y = "translateY"; + + /** Used to locate views in end-to-end (UI) tests. */ + public static final String TEST_ID = "testID"; + + public static final String NATIVE_ID = "nativeID"; + public static final int[] BORDER_SPACING_TYPES = { Spacing.ALL, Spacing.START, diff --git a/packages/react-native-codegen/DEFS.bzl b/packages/react-native-codegen/DEFS.bzl index 38d7bd17553262..a73bded17fb047 100644 --- a/packages/react-native-codegen/DEFS.bzl +++ b/packages/react-native-codegen/DEFS.bzl @@ -270,6 +270,7 @@ def rn_codegen( deps = [ react_native_dep("third-party/android/androidx:annotation"), react_native_target("java/com/facebook/react/bridge:bridge"), + react_native_target("java/com/facebook/react/uimanager:uimanager"), ], ) diff --git a/packages/react-native-codegen/buck_tests/java/ArrayPropsNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/ArrayPropsNativeComponentViewManager.java index 65bc8985a69fc8..0ffe9ae04a8f2f 100644 --- a/packages/react-native-codegen/buck_tests/java/ArrayPropsNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/ArrayPropsNativeComponentViewManager.java @@ -8,7 +8,7 @@ public class ArrayPropsNativeComponentViewManager extends SimpleViewManager implements ArrayPropsNativeComponentViewManagerInterface { - public static final String REACT_CLASS = "ArrayPropsNativeComponent"; + public static final String REACT_CLASS = "ArrayPropsNativeComponentView"; @Override public String getName() { @@ -16,8 +16,8 @@ public String getName() { } private void test() { - ArrayPropsNativeComponentViewManagerDelegate delegate = - new ArrayPropsNativeComponentViewManagerDelegate(); + ArrayPropsNativeComponentViewManagerDelegate + delegate = new ArrayPropsNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/buck_tests/java/BooleanPropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/BooleanPropNativeComponentViewManager.java index 70c427b46f1fb1..40292c89a09e86 100644 --- a/packages/react-native-codegen/buck_tests/java/BooleanPropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/BooleanPropNativeComponentViewManager.java @@ -6,6 +6,7 @@ public class BooleanPropNativeComponentViewManager extends SimpleViewManager implements BooleanPropNativeComponentViewManagerInterface { + public static final String REACT_CLASS = "BooleanPropNativeComponentView"; @Override @@ -14,8 +15,8 @@ public String getName() { } private void test() { - BooleanPropNativeComponentViewManagerDelegate delegate = - new BooleanPropNativeComponentViewManagerDelegate(); + BooleanPropNativeComponentViewManagerDelegate + delegate = new BooleanPropNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/buck_tests/java/ColorPropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/ColorPropNativeComponentViewManager.java index 7627fcfedb4c27..01062319ad4c1a 100644 --- a/packages/react-native-codegen/buck_tests/java/ColorPropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/ColorPropNativeComponentViewManager.java @@ -15,8 +15,8 @@ public String getName() { } private void test() { - ColorPropNativeComponentViewManagerDelegate delegate = - new ColorPropNativeComponentViewManagerDelegate(); + ColorPropNativeComponentViewManagerDelegate + delegate = new ColorPropNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/buck_tests/java/EnumPropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/EnumPropNativeComponentViewManager.java index 7542b9952b15ad..1a1e467c7caa84 100644 --- a/packages/react-native-codegen/buck_tests/java/EnumPropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/EnumPropNativeComponentViewManager.java @@ -15,8 +15,8 @@ public String getName() { } private void test() { - EnumPropNativeComponentViewManagerDelegate delegate = - new EnumPropNativeComponentViewManagerDelegate(); + EnumPropNativeComponentViewManagerDelegate + delegate = new EnumPropNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/buck_tests/java/EventNestedObjectPropsNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/EventNestedObjectPropsNativeComponentViewManager.java index bec14f4b43aaf4..21cc9984ec46c8 100644 --- a/packages/react-native-codegen/buck_tests/java/EventNestedObjectPropsNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/EventNestedObjectPropsNativeComponentViewManager.java @@ -15,8 +15,9 @@ public String getName() { } private void test() { - EventNestedObjectPropsNativeComponentViewManagerDelegate delegate = - new EventNestedObjectPropsNativeComponentViewManagerDelegate(); + EventNestedObjectPropsNativeComponentViewManagerDelegate< + ViewGroup, EventNestedObjectPropsNativeComponentViewManager> + delegate = new EventNestedObjectPropsNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/buck_tests/java/EventPropsNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/EventPropsNativeComponentViewManager.java index 1116b769c79a04..63a381372a42a2 100644 --- a/packages/react-native-codegen/buck_tests/java/EventPropsNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/EventPropsNativeComponentViewManager.java @@ -15,8 +15,8 @@ public String getName() { } private void test() { - EventPropsNativeComponentViewManagerDelegate delegate = - new EventPropsNativeComponentViewManagerDelegate(); + EventPropsNativeComponentViewManagerDelegate + delegate = new EventPropsNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/buck_tests/java/FloatPropsNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/FloatPropsNativeComponentViewManager.java index 4ceaf8f4254035..25c8698f106e2b 100644 --- a/packages/react-native-codegen/buck_tests/java/FloatPropsNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/FloatPropsNativeComponentViewManager.java @@ -15,8 +15,8 @@ public String getName() { } private void test() { - FloatPropsNativeComponentViewManagerDelegate delegate = - new FloatPropsNativeComponentViewManagerDelegate(); + FloatPropsNativeComponentViewManagerDelegate + delegate = new FloatPropsNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/buck_tests/java/ImagePropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/ImagePropNativeComponentViewManager.java index 8c1ebcc88b9410..7ff9ea125f3177 100644 --- a/packages/react-native-codegen/buck_tests/java/ImagePropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/ImagePropNativeComponentViewManager.java @@ -16,8 +16,8 @@ public String getName() { } private void test() { - ImagePropNativeComponentViewManagerDelegate delegate = - new ImagePropNativeComponentViewManagerDelegate(); + ImagePropNativeComponentViewManagerDelegate + delegate = new ImagePropNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/buck_tests/java/IntegerPropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/IntegerPropNativeComponentViewManager.java index 01af02c796a783..0359546fa416e7 100644 --- a/packages/react-native-codegen/buck_tests/java/IntegerPropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/IntegerPropNativeComponentViewManager.java @@ -15,8 +15,8 @@ public String getName() { } private void test() { - IntegerPropNativeComponentViewManagerDelegate delegate = - new IntegerPropNativeComponentViewManagerDelegate(); + IntegerPropNativeComponentViewManagerDelegate + delegate = new IntegerPropNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/buck_tests/java/InterfaceOnlyNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/InterfaceOnlyNativeComponentViewManager.java index db8ade6419b6dd..afd9e9c4b23102 100644 --- a/packages/react-native-codegen/buck_tests/java/InterfaceOnlyNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/InterfaceOnlyNativeComponentViewManager.java @@ -15,8 +15,9 @@ public String getName() { } private void test() { - InterfaceOnlyNativeComponentViewManagerDelegate delegate = - new InterfaceOnlyNativeComponentViewManagerDelegate(); + InterfaceOnlyNativeComponentViewManagerDelegate< + ViewGroup, InterfaceOnlyNativeComponentViewManager> + delegate = new InterfaceOnlyNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/buck_tests/java/MultiNativePropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/MultiNativePropNativeComponentViewManager.java index d2446a27b7e3dd..cad18fdf3afbae 100644 --- a/packages/react-native-codegen/buck_tests/java/MultiNativePropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/MultiNativePropNativeComponentViewManager.java @@ -16,8 +16,9 @@ public String getName() { } private void test() { - MultiNativePropNativeComponentViewManagerDelegate delegate = - new MultiNativePropNativeComponentViewManagerDelegate(); + MultiNativePropNativeComponentViewManagerDelegate< + ViewGroup, MultiNativePropNativeComponentViewManager> + delegate = new MultiNativePropNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/buck_tests/java/NoPropsNoEventsNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/NoPropsNoEventsNativeComponentViewManager.java index bd69c3058fe08d..c8579fd830b225 100644 --- a/packages/react-native-codegen/buck_tests/java/NoPropsNoEventsNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/NoPropsNoEventsNativeComponentViewManager.java @@ -15,8 +15,9 @@ public String getName() { } private void test() { - NoPropsNoEventsNativeComponentViewManagerDelegate delegate = - new NoPropsNoEventsNativeComponentViewManagerDelegate(); + NoPropsNoEventsNativeComponentViewManagerDelegate< + ViewGroup, NoPropsNoEventsNativeComponentViewManager> + delegate = new NoPropsNoEventsNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/buck_tests/java/PointPropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/PointPropNativeComponentViewManager.java index 548097d955f46e..2c68bdadd5bf05 100644 --- a/packages/react-native-codegen/buck_tests/java/PointPropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/PointPropNativeComponentViewManager.java @@ -16,8 +16,8 @@ public String getName() { } private void test() { - PointPropNativeComponentViewManagerDelegate delegate = - new PointPropNativeComponentViewManagerDelegate(); + PointPropNativeComponentViewManagerDelegate + delegate = new PointPropNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/buck_tests/java/StringPropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/StringPropNativeComponentViewManager.java index 08f331ba3d25c3..3a0ebb41a27eb3 100644 --- a/packages/react-native-codegen/buck_tests/java/StringPropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/StringPropNativeComponentViewManager.java @@ -15,8 +15,8 @@ public String getName() { } private void test() { - StringPropNativeComponentViewManagerDelegate delegate = - new StringPropNativeComponentViewManagerDelegate(); + StringPropNativeComponentViewManagerDelegate + delegate = new StringPropNativeComponentViewManagerDelegate<>(this); } @Override diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js index bf0fa17bd1ebe5..58aadf57954c5c 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js @@ -39,5 +39,5 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'ArrayPropsNativeComponent', + 'ArrayPropsNativeComponentView', ): NativeComponentType); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js index 2df67f38f041ca..806740cd3dfce6 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js @@ -23,5 +23,5 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'BooleanPropNativeComponent', + 'BooleanPropNativeComponentView', ): NativeComponentType); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js index 1a8c263ccfbf0b..38cd6f9b03cd49 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js @@ -23,5 +23,5 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'ColorPropNativeComponent', + 'ColorPropNativeComponentView', ): NativeComponentType); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js index 5a4ad2d5ac8088..93e3939758b096 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js @@ -23,5 +23,5 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'EnumPropNativeComponent', + 'EnumPropNativeComponentView', ): NativeComponentType); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js index ed93e3ffcfcce5..63bd40e9c09aca 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js @@ -40,5 +40,5 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'EventNestedObjectPropsNativeComponent', + 'EventNestedObjectPropsNativeComponentView', ): NativeComponentType); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js index 406381cfb15c6b..bec60e49347f07 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js @@ -61,5 +61,5 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'EventPropsNativeComponent', + 'EventPropsNativeComponentView', ): NativeComponentType); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js index 5e72e470ee00d5..992defaee321d6 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js @@ -31,5 +31,5 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'FloatPropsNativeComponent', + 'FloatPropsNativeComponentView', ): NativeComponentType); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js index 2ed439a0fab2b7..74d794e6e0d025 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js @@ -23,5 +23,5 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'ImagePropNativeComponent', + 'ImagePropNativeComponentView', ): NativeComponentType); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js index efb1c901844fc2..6eca06ff958865 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js @@ -28,5 +28,5 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'IntegerPropNativeComponent', + 'IntegerPropNativeComponentView', ): NativeComponentType); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js index 9433c1e33e37f2..7d662ffd6c50cd 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js @@ -29,7 +29,7 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'InterfaceOnlyNativeComponent', + 'InterfaceOnlyNativeComponentView', { interfaceOnly: true, paperComponentName: 'RCTInterfaceOnlyComponent', diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js index a495f01adeee0a..f332f60ac896e7 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js @@ -30,5 +30,5 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'MultiNativePropNativeComponent', + 'MultiNativePropNativeComponentView', ): NativeComponentType); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js index 5e7cb39f407299..25d6f98a56d573 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js @@ -21,5 +21,5 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'NoPropsNoEventsNativeComponent', + 'NoPropsNoEventsNativeComponentView', ): NativeComponentType); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js index 62bf4d2185f8d1..bbdcdc7b8307f7 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js @@ -23,5 +23,5 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'PointPropNativeComponent', + 'PointPropNativeComponentView', ): NativeComponentType); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js index 3a293470390249..b23d385a9486a3 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js @@ -24,5 +24,5 @@ type NativeProps = $ReadOnly<{| |}>; export default (codegenNativeComponent( - 'StringPropNativeComponent', + 'StringPropNativeComponentView', ): NativeComponentType); diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js index 4f48c0cf56604f..cb8fefbda33757 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js @@ -26,13 +26,17 @@ package com.facebook.react.viewmanagers; ::_IMPORTS_:: -public class ::_CLASSNAME_:: { +public class ::_CLASSNAME_:: & ::_INTERFACE_CLASSNAME_::> extends BaseViewManagerDelegate { + public ::_CLASSNAME_::(U viewManager) { + super(viewManager); + } ::_METHODS_:: } `; const propSetterTemplate = ` - public void setProperty(::_INTERFACE_CLASSNAME_:: viewManager, T view, String propName, Object value) { + @Override + public void setProperty(T view, String propName, @Nullable Object value) { ::_PROP_CASES_:: } `; @@ -104,7 +108,7 @@ function generatePropCasesString( const cases = component.props .map(prop => { return `case "${prop.name}": - viewManager.set${toSafeJavaString( + mViewManager.set${toSafeJavaString( prop.name, )}(view, ${getJavaValueForProp(prop, componentName)}); break;`; @@ -113,6 +117,8 @@ function generatePropCasesString( return `switch (propName) { ${cases} + default: + super.setProperty(view, propName, value); }`; } @@ -192,6 +198,10 @@ function getDelegateImports(component) { if (component.commands.length > 0) { imports.add('import com.facebook.react.bridge.ReadableArray;'); } + imports.add('import androidx.annotation.Nullable;'); + imports.add('import com.facebook.react.uimanager.BaseViewManager;'); + imports.add('import com.facebook.react.uimanager.BaseViewManagerDelegate;'); + imports.add('import com.facebook.react.uimanager.LayoutShadowNode;'); return imports; } @@ -223,8 +233,8 @@ module.exports = { return Object.keys(components).forEach(componentName => { const component = components[componentName]; - const className = `${componentName}ViewManagerDelegate`; - const interfaceClassName = `${componentName}ViewManagerInterface`; + const className = `${componentName}ManagerDelegate`; + const interfaceClassName = `${componentName}ManagerInterface`; const fileName = `${className}.java`; const imports = getDelegateImports(component); diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js index 0ee838f894eabf..853dd89c32b3b5 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js @@ -173,7 +173,7 @@ module.exports = { return Object.keys(components).forEach(componentName => { const component = components[componentName]; - const className = `${componentName}ViewManagerInterface`; + const className = `${componentName}ManagerInterface`; const fileName = `${className}.java`; const imports = getImports(component); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap index ee6971107d2f45..8ca6e476b0eb13 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap @@ -2,39 +2,49 @@ exports[`GeneratePropsJavaDelegate can generate fixture ARRAY_PROPS 1`] = ` Map { - "ArrayPropsNativeComponentViewManagerDelegate.java" => " + "ArrayPropsNativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; +import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableArray; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; -public class ArrayPropsNativeComponentViewManagerDelegate { - public void setProperty(ArrayPropsNativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +public class ArrayPropsNativeComponentManagerDelegate & ArrayPropsNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public ArrayPropsNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"names\\": - viewManager.setNames(view, (ReadableArray) value); + mViewManager.setNames(view, (ReadableArray) value); break; case \\"disableds\\": - viewManager.setDisableds(view, (ReadableArray) value); + mViewManager.setDisableds(view, (ReadableArray) value); break; case \\"progress\\": - viewManager.setProgress(view, (ReadableArray) value); + mViewManager.setProgress(view, (ReadableArray) value); break; case \\"radii\\": - viewManager.setRadii(view, (ReadableArray) value); + mViewManager.setRadii(view, (ReadableArray) value); break; case \\"colors\\": - viewManager.setColors(view, (ReadableArray) value); + mViewManager.setColors(view, (ReadableArray) value); break; case \\"srcs\\": - viewManager.setSrcs(view, (ReadableArray) value); + mViewManager.setSrcs(view, (ReadableArray) value); break; case \\"points\\": - viewManager.setPoints(view, (ReadableArray) value); + mViewManager.setPoints(view, (ReadableArray) value); break; case \\"sizes\\": - viewManager.setSizes(view, (ReadableArray) value); + mViewManager.setSizes(view, (ReadableArray) value); break; + default: + super.setProperty(view, propName, value); } } } @@ -44,17 +54,27 @@ public class ArrayPropsNativeComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture BOOLEAN_PROP 1`] = ` Map { - "BooleanPropNativeComponentViewManagerDelegate.java" => " + "BooleanPropNativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class BooleanPropNativeComponentViewManagerDelegate { - public void setProperty(BooleanPropNativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class BooleanPropNativeComponentManagerDelegate & BooleanPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public BooleanPropNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"disabled\\": - viewManager.setDisabled(view, value == null ? false : (boolean) value); + mViewManager.setDisabled(view, value == null ? false : (boolean) value); break; + default: + super.setProperty(view, propName, value); } } } @@ -64,17 +84,27 @@ public class BooleanPropNativeComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture COLOR_PROP 1`] = ` Map { - "ColorPropNativeComponentViewManagerDelegate.java" => " + "ColorPropNativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class ColorPropNativeComponentViewManagerDelegate { - public void setProperty(ColorPropNativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class ColorPropNativeComponentManagerDelegate & ColorPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public ColorPropNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"tintColor\\": - viewManager.setTintColor(view, value == null ? null : ((Double) value).intValue()); + mViewManager.setTintColor(view, value == null ? null : ((Double) value).intValue()); break; + default: + super.setProperty(view, propName, value); } } } @@ -84,18 +114,26 @@ public class ColorPropNativeComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture COMMANDS 1`] = ` Map { - "CommandNativeComponentViewManagerDelegate.java" => " + "CommandNativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; +import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableArray; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; -public class CommandNativeComponentViewManagerDelegate { - public void setProperty(CommandNativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +public class CommandNativeComponentManagerDelegate & CommandNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public CommandNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { // No props } - public void receiveCommand(CommandNativeComponentViewManagerInterface viewManager, T view, String commandName, ReadableArray args) { + public void receiveCommand(CommandNativeComponentManagerInterface viewManager, T view, String commandName, ReadableArray args) { case \\"flashScrollIndicators\\": viewManager.flashScrollIndicators(view); break; @@ -110,22 +148,32 @@ public class CommandNativeComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { - "CommandNativeComponentViewManagerDelegate.java" => " + "CommandNativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; +import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableArray; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; -public class CommandNativeComponentViewManagerDelegate { - public void setProperty(CommandNativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +public class CommandNativeComponentManagerDelegate & CommandNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public CommandNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"accessibilityHint\\": - viewManager.setAccessibilityHint(view, value == null ? \\"\\" : (String) value); + mViewManager.setAccessibilityHint(view, value == null ? \\"\\" : (String) value); break; + default: + super.setProperty(view, propName, value); } } - public void receiveCommand(CommandNativeComponentViewManagerInterface viewManager, T view, String commandName, ReadableArray args) { + public void receiveCommand(CommandNativeComponentManagerInterface viewManager, T view, String commandName, ReadableArray args) { case \\"hotspotUpdate\\": viewManager.hotspotUpdate(view, args.getInt(0), args.getInt(1)); break; @@ -137,17 +185,27 @@ public class CommandNativeComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture ENUM_PROP 1`] = ` Map { - "EnumPropsNativeComponentViewManagerDelegate.java" => " + "EnumPropsNativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class EnumPropsNativeComponentViewManagerDelegate { - public void setProperty(EnumPropsNativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class EnumPropsNativeComponentManagerDelegate & EnumPropsNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public EnumPropsNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"alignment\\": - viewManager.setAlignment(view, (String) value); + mViewManager.setAlignment(view, (String) value); break; + default: + super.setProperty(view, propName, value); } } } @@ -157,17 +215,27 @@ public class EnumPropsNativeComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { - "EventsNestedObjectNativeComponentViewManagerDelegate.java" => " + "EventsNestedObjectNativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class EventsNestedObjectNativeComponentViewManagerDelegate { - public void setProperty(EventsNestedObjectNativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class EventsNestedObjectNativeComponentManagerDelegate & EventsNestedObjectNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public EventsNestedObjectNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"disabled\\": - viewManager.setDisabled(view, value == null ? false : (boolean) value); + mViewManager.setDisabled(view, value == null ? false : (boolean) value); break; + default: + super.setProperty(view, propName, value); } } } @@ -177,17 +245,27 @@ public class EventsNestedObjectNativeComponentViewManagerDelegate " + "EventsNativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class EventsNativeComponentViewManagerDelegate { - public void setProperty(EventsNativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class EventsNativeComponentManagerDelegate & EventsNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public EventsNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"disabled\\": - viewManager.setDisabled(view, value == null ? false : (boolean) value); + mViewManager.setDisabled(view, value == null ? false : (boolean) value); break; + default: + super.setProperty(view, propName, value); } } } @@ -197,13 +275,21 @@ public class EventsNativeComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture EVENTS_WITH_PAPER_NAME 1`] = ` Map { - "InterfaceOnlyComponentViewManagerDelegate.java" => " + "InterfaceOnlyComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class InterfaceOnlyComponentViewManagerDelegate { - public void setProperty(InterfaceOnlyComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class InterfaceOnlyComponentManagerDelegate & InterfaceOnlyComponentManagerInterface> extends BaseViewManagerDelegate { + public InterfaceOnlyComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { // No props } } @@ -213,32 +299,42 @@ public class InterfaceOnlyComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture FLOAT_PROPS 1`] = ` Map { - "FloatPropNativeComponentViewManagerDelegate.java" => " + "FloatPropNativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class FloatPropNativeComponentViewManagerDelegate { - public void setProperty(FloatPropNativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class FloatPropNativeComponentManagerDelegate & FloatPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public FloatPropNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"blurRadius\\": - viewManager.setBlurRadius(view, value == null ? Float.NaN : ((Double) value).floatValue()); + mViewManager.setBlurRadius(view, value == null ? Float.NaN : ((Double) value).floatValue()); break; case \\"blurRadius2\\": - viewManager.setBlurRadius2(view, value == null ? 0.001f : ((Double) value).floatValue()); + mViewManager.setBlurRadius2(view, value == null ? 0.001f : ((Double) value).floatValue()); break; case \\"blurRadius3\\": - viewManager.setBlurRadius3(view, value == null ? 2.1f : ((Double) value).floatValue()); + mViewManager.setBlurRadius3(view, value == null ? 2.1f : ((Double) value).floatValue()); break; case \\"blurRadius4\\": - viewManager.setBlurRadius4(view, value == null ? 0f : ((Double) value).floatValue()); + mViewManager.setBlurRadius4(view, value == null ? 0f : ((Double) value).floatValue()); break; case \\"blurRadius5\\": - viewManager.setBlurRadius5(view, value == null ? 1f : ((Double) value).floatValue()); + mViewManager.setBlurRadius5(view, value == null ? 1f : ((Double) value).floatValue()); break; case \\"blurRadius6\\": - viewManager.setBlurRadius6(view, value == null ? 0f : ((Double) value).floatValue()); + mViewManager.setBlurRadius6(view, value == null ? 0f : ((Double) value).floatValue()); break; + default: + super.setProperty(view, propName, value); } } } @@ -248,18 +344,28 @@ public class FloatPropNativeComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture IMAGE_PROP 1`] = ` Map { - "ImagePropNativeComponentViewManagerDelegate.java" => " + "ImagePropNativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; +import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; -public class ImagePropNativeComponentViewManagerDelegate { - public void setProperty(ImagePropNativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +public class ImagePropNativeComponentManagerDelegate & ImagePropNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public ImagePropNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"thumbImage\\": - viewManager.setThumbImage(view, (ReadableMap) value); + mViewManager.setThumbImage(view, (ReadableMap) value); break; + default: + super.setProperty(view, propName, value); } } } @@ -269,23 +375,33 @@ public class ImagePropNativeComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture INTEGER_PROPS 1`] = ` Map { - "IntegerPropNativeComponentViewManagerDelegate.java" => " + "IntegerPropNativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class IntegerPropNativeComponentViewManagerDelegate { - public void setProperty(IntegerPropNativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class IntegerPropNativeComponentManagerDelegate & IntegerPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public IntegerPropNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"progress1\\": - viewManager.setProgress1(view, value == null ? 0 : ((Double) value).intValue()); + mViewManager.setProgress1(view, value == null ? 0 : ((Double) value).intValue()); break; case \\"progress2\\": - viewManager.setProgress2(view, value == null ? -1 : ((Double) value).intValue()); + mViewManager.setProgress2(view, value == null ? -1 : ((Double) value).intValue()); break; case \\"progress3\\": - viewManager.setProgress3(view, value == null ? 10 : ((Double) value).intValue()); + mViewManager.setProgress3(view, value == null ? 10 : ((Double) value).intValue()); break; + default: + super.setProperty(view, propName, value); } } } @@ -295,17 +411,27 @@ public class IntegerPropNativeComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture INTERFACE_ONLY 1`] = ` Map { - "InterfaceOnlyComponentViewManagerDelegate.java" => " + "InterfaceOnlyComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class InterfaceOnlyComponentViewManagerDelegate { - public void setProperty(InterfaceOnlyComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class InterfaceOnlyComponentManagerDelegate & InterfaceOnlyComponentManagerInterface> extends BaseViewManagerDelegate { + public InterfaceOnlyComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"accessibilityHint\\": - viewManager.setAccessibilityHint(view, value == null ? \\"\\" : (String) value); + mViewManager.setAccessibilityHint(view, value == null ? \\"\\" : (String) value); break; + default: + super.setProperty(view, propName, value); } } } @@ -315,27 +441,37 @@ public class InterfaceOnlyComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { - "ImageColorPropNativeComponentViewManagerDelegate.java" => " + "ImageColorPropNativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; +import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; -public class ImageColorPropNativeComponentViewManagerDelegate { - public void setProperty(ImageColorPropNativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +public class ImageColorPropNativeComponentManagerDelegate & ImageColorPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public ImageColorPropNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"thumbImage\\": - viewManager.setThumbImage(view, (ReadableMap) value); + mViewManager.setThumbImage(view, (ReadableMap) value); break; case \\"color\\": - viewManager.setColor(view, value == null ? null : ((Double) value).intValue()); + mViewManager.setColor(view, value == null ? null : ((Double) value).intValue()); break; case \\"thumbTintColor\\": - viewManager.setThumbTintColor(view, value == null ? null : ((Double) value).intValue()); + mViewManager.setThumbTintColor(view, value == null ? null : ((Double) value).intValue()); break; case \\"point\\": - viewManager.setPoint(view, (ReadableMap) value); + mViewManager.setPoint(view, (ReadableMap) value); break; + default: + super.setProperty(view, propName, value); } } } @@ -345,13 +481,21 @@ public class ImageColorPropNativeComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture NO_PROPS_NO_EVENTS 1`] = ` Map { - "NoPropsNoEventsComponentViewManagerDelegate.java" => " + "NoPropsNoEventsComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class NoPropsNoEventsComponentViewManagerDelegate { - public void setProperty(NoPropsNoEventsComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class NoPropsNoEventsComponentManagerDelegate & NoPropsNoEventsComponentManagerInterface> extends BaseViewManagerDelegate { + public NoPropsNoEventsComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { // No props } } @@ -361,18 +505,28 @@ public class NoPropsNoEventsComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture POINT_PROP 1`] = ` Map { - "PointPropNativeComponentViewManagerDelegate.java" => " + "PointPropNativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; +import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; -public class PointPropNativeComponentViewManagerDelegate { - public void setProperty(PointPropNativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +public class PointPropNativeComponentManagerDelegate & PointPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public PointPropNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"startPoint\\": - viewManager.setStartPoint(view, (ReadableMap) value); + mViewManager.setStartPoint(view, (ReadableMap) value); break; + default: + super.setProperty(view, propName, value); } } } @@ -382,20 +536,30 @@ public class PointPropNativeComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture STRING_PROP 1`] = ` Map { - "StringPropComponentViewManagerDelegate.java" => " + "StringPropComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class StringPropComponentViewManagerDelegate { - public void setProperty(StringPropComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class StringPropComponentManagerDelegate & StringPropComponentManagerInterface> extends BaseViewManagerDelegate { + public StringPropComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"accessibilityHint\\": - viewManager.setAccessibilityHint(view, value == null ? \\"\\" : (String) value); + mViewManager.setAccessibilityHint(view, value == null ? \\"\\" : (String) value); break; case \\"accessibilityRole\\": - viewManager.setAccessibilityRole(view, value == null ? null : (String) value); + mViewManager.setAccessibilityRole(view, value == null ? null : (String) value); break; + default: + super.setProperty(view, propName, value); } } } @@ -405,32 +569,52 @@ public class StringPropComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture TWO_COMPONENTS_DIFFERENT_FILES 1`] = ` Map { - "MultiFile1NativeComponentViewManagerDelegate.java" => " + "MultiFile1NativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class MultiFile1NativeComponentViewManagerDelegate { - public void setProperty(MultiFile1NativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class MultiFile1NativeComponentManagerDelegate & MultiFile1NativeComponentManagerInterface> extends BaseViewManagerDelegate { + public MultiFile1NativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"disabled\\": - viewManager.setDisabled(view, value == null ? false : (boolean) value); + mViewManager.setDisabled(view, value == null ? false : (boolean) value); break; + default: + super.setProperty(view, propName, value); } } } ", - "MultiFile2NativeComponentViewManagerDelegate.java" => " + "MultiFile2NativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class MultiFile2NativeComponentViewManagerDelegate { - public void setProperty(MultiFile2NativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class MultiFile2NativeComponentManagerDelegate & MultiFile2NativeComponentManagerInterface> extends BaseViewManagerDelegate { + public MultiFile2NativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"disabled\\": - viewManager.setDisabled(view, value == null ? true : (boolean) value); + mViewManager.setDisabled(view, value == null ? true : (boolean) value); break; + default: + super.setProperty(view, propName, value); } } } @@ -440,32 +624,52 @@ public class MultiFile2NativeComponentViewManagerDelegate { exports[`GeneratePropsJavaDelegate can generate fixture TWO_COMPONENTS_SAME_FILE 1`] = ` Map { - "MultiComponent1NativeComponentViewManagerDelegate.java" => " + "MultiComponent1NativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class MultiComponent1NativeComponentViewManagerDelegate { - public void setProperty(MultiComponent1NativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class MultiComponent1NativeComponentManagerDelegate & MultiComponent1NativeComponentManagerInterface> extends BaseViewManagerDelegate { + public MultiComponent1NativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"disabled\\": - viewManager.setDisabled(view, value == null ? false : (boolean) value); + mViewManager.setDisabled(view, value == null ? false : (boolean) value); break; + default: + super.setProperty(view, propName, value); } } } ", - "MultiComponent2NativeComponentViewManagerDelegate.java" => " + "MultiComponent2NativeComponentManagerDelegate.java" => " package com.facebook.react.viewmanagers; import android.view.View; - -public class MultiComponent2NativeComponentViewManagerDelegate { - public void setProperty(MultiComponent2NativeComponentViewManagerInterface viewManager, T view, String propName, Object value) { +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManager; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class MultiComponent2NativeComponentManagerDelegate & MultiComponent2NativeComponentManagerInterface> extends BaseViewManagerDelegate { + public MultiComponent2NativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { case \\"disabled\\": - viewManager.setDisabled(view, value == null ? true : (boolean) value); + mViewManager.setDisabled(view, value == null ? true : (boolean) value); break; + default: + super.setProperty(view, propName, value); } } } diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap index 4a51dd66ee901b..5e9faf2bfdd2b4 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap @@ -2,14 +2,14 @@ exports[`GeneratePropsJavaInterface can generate fixture ARRAY_PROPS 1`] = ` Map { - "ArrayPropsNativeComponentViewManagerInterface.java" => " + "ArrayPropsNativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableArray; -public interface ArrayPropsNativeComponentViewManagerInterface { +public interface ArrayPropsNativeComponentManagerInterface { void setNames(T view, @Nullable ReadableArray value); void setDisableds(T view, @Nullable ReadableArray value); void setProgress(T view, @Nullable ReadableArray value); @@ -25,12 +25,12 @@ public interface ArrayPropsNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture BOOLEAN_PROP 1`] = ` Map { - "BooleanPropNativeComponentViewManagerInterface.java" => " + "BooleanPropNativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; -public interface BooleanPropNativeComponentViewManagerInterface { +public interface BooleanPropNativeComponentManagerInterface { void setDisabled(T view, boolean value); } ", @@ -39,13 +39,13 @@ public interface BooleanPropNativeComponentViewManagerInterface exports[`GeneratePropsJavaInterface can generate fixture COLOR_PROP 1`] = ` Map { - "ColorPropNativeComponentViewManagerInterface.java" => " + "ColorPropNativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; -public interface ColorPropNativeComponentViewManagerInterface { +public interface ColorPropNativeComponentManagerInterface { void setTintColor(T view, @Nullable Integer value); } ", @@ -54,12 +54,12 @@ public interface ColorPropNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture COMMANDS 1`] = ` Map { - "CommandNativeComponentViewManagerInterface.java" => " + "CommandNativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; -public interface CommandNativeComponentViewManagerInterface { +public interface CommandNativeComponentManagerInterface { // No props void flashScrollIndicators(T view); void allTypes(T view, int x, String message, boolean animated); @@ -70,13 +70,13 @@ public interface CommandNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { - "CommandNativeComponentViewManagerInterface.java" => " + "CommandNativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; -public interface CommandNativeComponentViewManagerInterface { +public interface CommandNativeComponentManagerInterface { void setAccessibilityHint(T view, @Nullable String value); void hotspotUpdate(T view, int x, int y); } @@ -86,13 +86,13 @@ public interface CommandNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture ENUM_PROP 1`] = ` Map { - "EnumPropsNativeComponentViewManagerInterface.java" => " + "EnumPropsNativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; -public interface EnumPropsNativeComponentViewManagerInterface { +public interface EnumPropsNativeComponentManagerInterface { void setAlignment(T view, @Nullable String value); } ", @@ -101,12 +101,12 @@ public interface EnumPropsNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { - "EventsNestedObjectNativeComponentViewManagerInterface.java" => " + "EventsNestedObjectNativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; -public interface EventsNestedObjectNativeComponentViewManagerInterface { +public interface EventsNestedObjectNativeComponentManagerInterface { void setDisabled(T view, boolean value); } ", @@ -115,12 +115,12 @@ public interface EventsNestedObjectNativeComponentViewManagerInterface " + "EventsNativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; -public interface EventsNativeComponentViewManagerInterface { +public interface EventsNativeComponentManagerInterface { void setDisabled(T view, boolean value); } ", @@ -129,12 +129,12 @@ public interface EventsNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture EVENTS_WITH_PAPER_NAME 1`] = ` Map { - "InterfaceOnlyComponentViewManagerInterface.java" => " + "InterfaceOnlyComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; -public interface InterfaceOnlyComponentViewManagerInterface { +public interface InterfaceOnlyComponentManagerInterface { // No props } ", @@ -143,13 +143,13 @@ public interface InterfaceOnlyComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture FLOAT_PROPS 1`] = ` Map { - "FloatPropNativeComponentViewManagerInterface.java" => " + "FloatPropNativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; -public interface FloatPropNativeComponentViewManagerInterface { +public interface FloatPropNativeComponentManagerInterface { void setBlurRadius(T view, Float value); void setBlurRadius2(T view, Float value); void setBlurRadius3(T view, Float value); @@ -163,14 +163,14 @@ public interface FloatPropNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture IMAGE_PROP 1`] = ` Map { - "ImagePropNativeComponentViewManagerInterface.java" => " + "ImagePropNativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableMap; -public interface ImagePropNativeComponentViewManagerInterface { +public interface ImagePropNativeComponentManagerInterface { void setThumbImage(T view, @Nullable ReadableMap value); } ", @@ -179,12 +179,12 @@ public interface ImagePropNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture INTEGER_PROPS 1`] = ` Map { - "IntegerPropNativeComponentViewManagerInterface.java" => " + "IntegerPropNativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; -public interface IntegerPropNativeComponentViewManagerInterface { +public interface IntegerPropNativeComponentManagerInterface { void setProgress1(T view, int value); void setProgress2(T view, int value); void setProgress3(T view, int value); @@ -195,13 +195,13 @@ public interface IntegerPropNativeComponentViewManagerInterface exports[`GeneratePropsJavaInterface can generate fixture INTERFACE_ONLY 1`] = ` Map { - "InterfaceOnlyComponentViewManagerInterface.java" => " + "InterfaceOnlyComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; -public interface InterfaceOnlyComponentViewManagerInterface { +public interface InterfaceOnlyComponentManagerInterface { void setAccessibilityHint(T view, @Nullable String value); } ", @@ -210,14 +210,14 @@ public interface InterfaceOnlyComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { - "ImageColorPropNativeComponentViewManagerInterface.java" => " + "ImageColorPropNativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableMap; -public interface ImageColorPropNativeComponentViewManagerInterface { +public interface ImageColorPropNativeComponentManagerInterface { void setThumbImage(T view, @Nullable ReadableMap value); void setColor(T view, @Nullable Integer value); void setThumbTintColor(T view, @Nullable Integer value); @@ -229,12 +229,12 @@ public interface ImageColorPropNativeComponentViewManagerInterface " + "NoPropsNoEventsComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; -public interface NoPropsNoEventsComponentViewManagerInterface { +public interface NoPropsNoEventsComponentManagerInterface { // No props } ", @@ -243,14 +243,14 @@ public interface NoPropsNoEventsComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture POINT_PROP 1`] = ` Map { - "PointPropNativeComponentViewManagerInterface.java" => " + "PointPropNativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableMap; -public interface PointPropNativeComponentViewManagerInterface { +public interface PointPropNativeComponentManagerInterface { void setStartPoint(T view, @Nullable ReadableMap value); } ", @@ -259,13 +259,13 @@ public interface PointPropNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture STRING_PROP 1`] = ` Map { - "StringPropComponentViewManagerInterface.java" => " + "StringPropComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; -public interface StringPropComponentViewManagerInterface { +public interface StringPropComponentManagerInterface { void setAccessibilityHint(T view, @Nullable String value); void setAccessibilityRole(T view, @Nullable String value); } @@ -275,21 +275,21 @@ public interface StringPropComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture TWO_COMPONENTS_DIFFERENT_FILES 1`] = ` Map { - "MultiFile1NativeComponentViewManagerInterface.java" => " + "MultiFile1NativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; -public interface MultiFile1NativeComponentViewManagerInterface { +public interface MultiFile1NativeComponentManagerInterface { void setDisabled(T view, boolean value); } ", - "MultiFile2NativeComponentViewManagerInterface.java" => " + "MultiFile2NativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; -public interface MultiFile2NativeComponentViewManagerInterface { +public interface MultiFile2NativeComponentManagerInterface { void setDisabled(T view, boolean value); } ", @@ -298,21 +298,21 @@ public interface MultiFile2NativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture TWO_COMPONENTS_SAME_FILE 1`] = ` Map { - "MultiComponent1NativeComponentViewManagerInterface.java" => " + "MultiComponent1NativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; -public interface MultiComponent1NativeComponentViewManagerInterface { +public interface MultiComponent1NativeComponentManagerInterface { void setDisabled(T view, boolean value); } ", - "MultiComponent2NativeComponentViewManagerInterface.java" => " + "MultiComponent2NativeComponentManagerInterface.java" => " package com.facebook.react.viewmanagers; import android.view.View; -public interface MultiComponent2NativeComponentViewManagerInterface { +public interface MultiComponent2NativeComponentManagerInterface { void setDisabled(T view, boolean value); } ",