mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-06 07:06:11 +00:00
fix: do not crash when borderRadius is set on Android (#2415)
# Summary Fixes #2462 Currently, on Android, when `borderRadius` style is applied to a `Svg` component an error occurs, stating `Cannot cast Double to Float` This PR updates the codegen types, changing them from Double to Dynamic, aligning with the implementation with the ViewProps. ## Test ### Tested on - [x] react-native@0.76.0-rc.1 - [x] react-native@0.75.1 - [x] react-native@0.74.2 - [x] react-native@0.73.9 ### Test case ```jsx <Svg width="60" height="60" viewBox="0 0 24 24" style={{ borderRadius: 16.2, borderTopLeftRadius: 16.2, borderBottomRightRadius: 16.2, borderStartStartRadius: 16.2, borderStartEndRadius: 16.2, borderTopRightRadius: 16.2, borderBottomLeftRadius: 16.2, borderTopStartRadius: 16.2, borderTopEndRadius: 16.2, borderBottomStartRadius: 16.2, borderBottomEndRadius: 16.2, borderEndEndRadius: 16.2, borderEndStartRadius: 16.2, }}> <Rect x="0" y="0" width="24" height="24" fill="red" /> </Svg> ``` ## Compatibility | OS | Implemented | | ------- | :---------: | | Android | ✅ |
This commit is contained in:
@@ -118,7 +118,9 @@ android {
|
||||
"src/paper/java",
|
||||
]
|
||||
}
|
||||
if (getReactNativeMinorVersion() >= 73) {
|
||||
if (getReactNativeMinorVersion() >= 75) {
|
||||
srcDirs += "src/borderRadiusRn75/java"
|
||||
} else if (getReactNativeMinorVersion() >= 73) {
|
||||
srcDirs += "src/transformRn73/java"
|
||||
} else {
|
||||
srcDirs += "src/deprecated/java"
|
||||
|
||||
@@ -0,0 +1,394 @@
|
||||
/*
|
||||
* Copyright (c) 2015-present, Horcrux.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT-style license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.horcrux.svg;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.util.SparseArray;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.bridge.Dynamic;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableType;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
import com.facebook.react.uimanager.PointerEvents;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
import com.facebook.react.uimanager.ViewManagerDelegate;
|
||||
import com.facebook.react.uimanager.ViewProps;
|
||||
import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
import com.facebook.react.viewmanagers.RNSVGSvgViewAndroidManagerDelegate;
|
||||
import com.facebook.react.viewmanagers.RNSVGSvgViewAndroidManagerInterface;
|
||||
import com.facebook.react.views.view.ReactViewGroup;
|
||||
import com.facebook.react.views.view.ReactViewManager;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Locale;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* ViewManager for RNSVGSvgView React views. Renders as a {@link SvgView} and handles invalidating
|
||||
* the native view on view updates happening in the underlying tree.
|
||||
*/
|
||||
class SvgViewManager extends ReactViewManager
|
||||
implements RNSVGSvgViewAndroidManagerInterface<SvgView> {
|
||||
|
||||
public static final String REACT_CLASS = "RNSVGSvgViewAndroid";
|
||||
|
||||
private static final SparseArray<SvgView> mTagToSvgView = new SparseArray<>();
|
||||
private static final SparseArray<Runnable> mTagToRunnable = new SparseArray<>();
|
||||
|
||||
private final ViewManagerDelegate<SvgView> mDelegate;
|
||||
|
||||
protected ViewManagerDelegate getDelegate() {
|
||||
return mDelegate;
|
||||
}
|
||||
|
||||
public SvgViewManager() {
|
||||
mDelegate = new RNSVGSvgViewAndroidManagerDelegate(this);
|
||||
}
|
||||
|
||||
static void setSvgView(int tag, SvgView svg) {
|
||||
mTagToSvgView.put(tag, svg);
|
||||
Runnable task = mTagToRunnable.get(tag);
|
||||
if (task != null) {
|
||||
task.run();
|
||||
mTagToRunnable.delete(tag);
|
||||
}
|
||||
}
|
||||
|
||||
static void runWhenViewIsAvailable(int tag, Runnable task) {
|
||||
mTagToRunnable.put(tag, task);
|
||||
}
|
||||
|
||||
static @Nullable SvgView getSvgViewByTag(int tag) {
|
||||
return mTagToSvgView.get(tag);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return REACT_CLASS;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ReactViewGroup createViewInstance(ThemedReactContext reactContext) {
|
||||
return new SvgView(reactContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExtraData(ReactViewGroup root, Object extraData) {
|
||||
super.updateExtraData(root, extraData);
|
||||
root.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDropViewInstance(@Nonnull ReactViewGroup view) {
|
||||
super.onDropViewInstance(view);
|
||||
mTagToSvgView.remove(view.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsCustomLayoutForChildren() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ReactProp(name = "tintColor", customType = "Color")
|
||||
@Override
|
||||
public void setTintColor(SvgView node, Integer tintColor) {
|
||||
node.setTintColor(tintColor);
|
||||
}
|
||||
|
||||
@ReactProp(name = "color", customType = "Color")
|
||||
@Override
|
||||
public void setColor(SvgView node, Integer color) {
|
||||
node.setTintColor(color);
|
||||
}
|
||||
|
||||
@ReactProp(name = "minX")
|
||||
@Override
|
||||
public void setMinX(SvgView node, float minX) {
|
||||
node.setMinX(minX);
|
||||
}
|
||||
|
||||
@ReactProp(name = "minY")
|
||||
@Override
|
||||
public void setMinY(SvgView node, float minY) {
|
||||
node.setMinY(minY);
|
||||
}
|
||||
|
||||
@ReactProp(name = "vbWidth")
|
||||
@Override
|
||||
public void setVbWidth(SvgView node, float vbWidth) {
|
||||
node.setVbWidth(vbWidth);
|
||||
}
|
||||
|
||||
@ReactProp(name = "vbHeight")
|
||||
@Override
|
||||
public void setVbHeight(SvgView node, float vbHeight) {
|
||||
node.setVbHeight(vbHeight);
|
||||
}
|
||||
|
||||
@ReactProp(name = "bbWidth")
|
||||
public void setBbWidth(SvgView node, Dynamic bbWidth) {
|
||||
node.setBbWidth(bbWidth);
|
||||
}
|
||||
|
||||
@ReactProp(name = "bbHeight")
|
||||
public void setBbHeight(SvgView node, Dynamic bbHeight) {
|
||||
node.setBbHeight(bbHeight);
|
||||
}
|
||||
|
||||
@ReactProp(name = "align")
|
||||
@Override
|
||||
public void setAlign(SvgView node, String align) {
|
||||
node.setAlign(align);
|
||||
}
|
||||
|
||||
@ReactProp(name = "meetOrSlice")
|
||||
@Override
|
||||
public void setMeetOrSlice(SvgView node, int meetOrSlice) {
|
||||
node.setMeetOrSlice(meetOrSlice);
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.POINTER_EVENTS)
|
||||
public void setPointerEvents(SvgView view, @Nullable String pointerEventsStr) {
|
||||
try {
|
||||
Class<?> superclass = view.getClass().getSuperclass();
|
||||
if (superclass != null) {
|
||||
Method method = superclass.getDeclaredMethod("setPointerEvents", PointerEvents.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(
|
||||
view, PointerEvents.valueOf(pointerEventsStr.toUpperCase(Locale.US).replace("-", "_")));
|
||||
}
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHasTVPreferredFocus(SvgView view, boolean value) {
|
||||
super.setTVPreferredFocus(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBottomColor(SvgView view, @Nullable Integer value) {
|
||||
super.setBorderColor(view, 4, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNextFocusDown(SvgView view, int value) {
|
||||
super.nextFocusDown(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderRightColor(SvgView view, @Nullable Integer value) {
|
||||
super.setBorderColor(view, 2, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNextFocusRight(SvgView view, int value) {
|
||||
super.nextFocusRight(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderLeftColor(SvgView view, @Nullable Integer value) {
|
||||
super.setBorderColor(view, 1, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderColor(SvgView view, @Nullable Integer value) {
|
||||
super.setBorderColor(view, 0, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemoveClippedSubviews(SvgView view, boolean value) {
|
||||
super.setRemoveClippedSubviews(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNextFocusForward(SvgView view, int value) {
|
||||
super.nextFocusForward(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNextFocusUp(SvgView view, int value) {
|
||||
super.nextFocusUp(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccessible(SvgView view, boolean value) {
|
||||
super.setAccessible(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderStartColor(SvgView view, @Nullable Integer value) {
|
||||
super.setBorderColor(view, 5, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderEndColor(SvgView view, @Nullable Integer value) {
|
||||
super.setBorderColor(view, 6, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocusable(SvgView view, boolean value) {
|
||||
super.setFocusable(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNativeBackgroundAndroid(SvgView view, @Nullable ReadableMap value) {
|
||||
super.setNativeBackground(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNativeForegroundAndroid(SvgView view, @Nullable ReadableMap value) {
|
||||
super.setNativeForeground(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackfaceVisibility(SvgView view, @Nullable String value) {
|
||||
super.setBackfaceVisibility(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderStyle(SvgView view, @Nullable String value) {
|
||||
super.setBorderStyle(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNeedsOffscreenAlphaCompositing(SvgView view, boolean value) {
|
||||
super.setNeedsOffscreenAlphaCompositing(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHitSlop(SvgView view, Dynamic hitSlop) {
|
||||
// we don't call super here since its signature changed in RN 0.69 and we want backwards
|
||||
// compatibility
|
||||
switch (hitSlop.getType()) {
|
||||
case Map:
|
||||
ReadableMap hitSlopMap = hitSlop.asMap();
|
||||
view.setHitSlopRect(
|
||||
new Rect(
|
||||
hitSlopMap.hasKey("left")
|
||||
? (int) PixelUtil.toPixelFromDIP(hitSlopMap.getDouble("left"))
|
||||
: 0,
|
||||
hitSlopMap.hasKey("top")
|
||||
? (int) PixelUtil.toPixelFromDIP(hitSlopMap.getDouble("top"))
|
||||
: 0,
|
||||
hitSlopMap.hasKey("right")
|
||||
? (int) PixelUtil.toPixelFromDIP(hitSlopMap.getDouble("right"))
|
||||
: 0,
|
||||
hitSlopMap.hasKey("bottom")
|
||||
? (int) PixelUtil.toPixelFromDIP(hitSlopMap.getDouble("bottom"))
|
||||
: 0));
|
||||
break;
|
||||
case Number:
|
||||
int hitSlopValue = (int) PixelUtil.toPixelFromDIP(hitSlop.asDouble());
|
||||
view.setHitSlopRect(new Rect(hitSlopValue, hitSlopValue, hitSlopValue, hitSlopValue));
|
||||
break;
|
||||
default:
|
||||
FLog.w(ReactConstants.TAG, "Invalid type for 'hitSlop' value " + hitSlop.getType());
|
||||
/* falls through */
|
||||
case Null:
|
||||
view.setHitSlopRect(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderTopColor(SvgView view, @Nullable Integer value) {
|
||||
super.setBorderColor(view, 3, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNextFocusLeft(SvgView view, int value) {
|
||||
super.nextFocusLeft(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBlockColor(SvgView view, @Nullable Integer value) {
|
||||
super.setBorderColor(view, 9, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBlockEndColor(SvgView view, @Nullable Integer value) {
|
||||
super.setBorderColor(view, 10, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBlockStartColor(SvgView view, @Nullable Integer value) {
|
||||
super.setBorderColor(view, 11, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
super.setBorderRadius(view, 0, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderTopLeftRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
super.setBorderRadius(view, 1, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderTopRightRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
super.setBorderRadius(view, 2, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBottomRightRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
super.setBorderRadius(view, 3, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBottomLeftRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
super.setBorderRadius(view, 4, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderTopStartRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
super.setBorderRadius(view, 5, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderTopEndRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
super.setBorderRadius(view, 6, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBottomStartRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
super.setBorderRadius(view, 7, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBottomEndRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
super.setBorderRadius(view, 8, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderEndEndRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
super.setBorderRadius(view, 9, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderEndStartRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
super.setBorderRadius(view, 10, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderStartEndRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
super.setBorderRadius(view, 11, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderStartStartRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
super.setBorderRadius(view, 12, rawBorderRadius);
|
||||
}
|
||||
}
|
||||
@@ -60,12 +60,6 @@ public class RNSVGSvgViewAndroidManagerDelegate<T extends View, U extends BaseVi
|
||||
case "hasTVPreferredFocus":
|
||||
mViewManager.setHasTVPreferredFocus(view, value == null ? false : (boolean) value);
|
||||
break;
|
||||
case "borderTopEndRadius":
|
||||
mViewManager.setBorderTopEndRadius(view, value == null ? 0f : ((Double) value).floatValue());
|
||||
break;
|
||||
case "borderBottomStartRadius":
|
||||
mViewManager.setBorderBottomStartRadius(view, value == null ? 0f : ((Double) value).floatValue());
|
||||
break;
|
||||
case "borderBottomColor":
|
||||
mViewManager.setBorderBottomColor(view, ColorPropConverter.getColor(value, view.getContext()));
|
||||
break;
|
||||
@@ -99,9 +93,6 @@ public class RNSVGSvgViewAndroidManagerDelegate<T extends View, U extends BaseVi
|
||||
case "borderStartColor":
|
||||
mViewManager.setBorderStartColor(view, ColorPropConverter.getColor(value, view.getContext()));
|
||||
break;
|
||||
case "borderBottomEndRadius":
|
||||
mViewManager.setBorderBottomEndRadius(view, value == null ? 0f : ((Double) value).floatValue());
|
||||
break;
|
||||
case "borderEndColor":
|
||||
mViewManager.setBorderEndColor(view, ColorPropConverter.getColor(value, view.getContext()));
|
||||
break;
|
||||
@@ -111,9 +102,6 @@ public class RNSVGSvgViewAndroidManagerDelegate<T extends View, U extends BaseVi
|
||||
case "nativeBackgroundAndroid":
|
||||
mViewManager.setNativeBackgroundAndroid(view, (ReadableMap) value);
|
||||
break;
|
||||
case "borderTopStartRadius":
|
||||
mViewManager.setBorderTopStartRadius(view, value == null ? 0f : ((Double) value).floatValue());
|
||||
break;
|
||||
case "nativeForegroundAndroid":
|
||||
mViewManager.setNativeForegroundAndroid(view, (ReadableMap) value);
|
||||
break;
|
||||
@@ -135,21 +123,6 @@ public class RNSVGSvgViewAndroidManagerDelegate<T extends View, U extends BaseVi
|
||||
case "nextFocusLeft":
|
||||
mViewManager.setNextFocusLeft(view, value == null ? 0 : ((Double) value).intValue());
|
||||
break;
|
||||
case "borderTopRightRadius":
|
||||
mViewManager.setBorderTopRightRadius(view, value == null ? 0f : ((Double) value).doubleValue());
|
||||
break;
|
||||
case "borderBottomRightRadius":
|
||||
mViewManager.setBorderBottomRightRadius(view, value == null ? 0f : ((Double) value).doubleValue());
|
||||
break;
|
||||
case "borderRadius":
|
||||
mViewManager.setBorderRadius(view, value == null ? 0f : ((Double) value).doubleValue());
|
||||
break;
|
||||
case "borderBottomLeftRadius":
|
||||
mViewManager.setBorderBottomLeftRadius(view, value == null ? 0f : ((Double) value).doubleValue());
|
||||
break;
|
||||
case "borderTopLeftRadius":
|
||||
mViewManager.setBorderTopLeftRadius(view, value == null ? 0f : ((Double) value).doubleValue());
|
||||
break;
|
||||
case "borderBlockColor":
|
||||
mViewManager.setBorderBlockColor(view, ColorPropConverter.getColor(value, view.getContext()));
|
||||
break;
|
||||
@@ -159,17 +132,44 @@ public class RNSVGSvgViewAndroidManagerDelegate<T extends View, U extends BaseVi
|
||||
case "borderBlockStartColor":
|
||||
mViewManager.setBorderBlockStartColor(view, ColorPropConverter.getColor(value, view.getContext()));
|
||||
break;
|
||||
case "borderRadius":
|
||||
mViewManager.setBorderRadius(view, new DynamicFromObject(value));
|
||||
break;
|
||||
case "borderTopLeftRadius":
|
||||
mViewManager.setBorderTopLeftRadius(view, new DynamicFromObject(value));
|
||||
break;
|
||||
case "borderTopRightRadius":
|
||||
mViewManager.setBorderTopRightRadius(view, new DynamicFromObject(value));
|
||||
break;
|
||||
case "borderBottomRightRadius":
|
||||
mViewManager.setBorderBottomRightRadius(view, new DynamicFromObject(value));
|
||||
break;
|
||||
case "borderBottomLeftRadius":
|
||||
mViewManager.setBorderBottomLeftRadius(view, new DynamicFromObject(value));
|
||||
break;
|
||||
case "borderTopStartRadius":
|
||||
mViewManager.setBorderTopStartRadius(view, new DynamicFromObject(value));
|
||||
break;
|
||||
case "borderTopEndRadius":
|
||||
mViewManager.setBorderTopEndRadius(view, new DynamicFromObject(value));
|
||||
break;
|
||||
case "borderBottomStartRadius":
|
||||
mViewManager.setBorderBottomStartRadius(view, new DynamicFromObject(value));
|
||||
break;
|
||||
case "borderBottomEndRadius":
|
||||
mViewManager.setBorderBottomEndRadius(view, new DynamicFromObject(value));
|
||||
break;
|
||||
case "borderEndEndRadius":
|
||||
mViewManager.setBorderEndEndRadius(view, value == null ? 0f : ((Double) value).doubleValue());
|
||||
mViewManager.setBorderEndEndRadius(view, new DynamicFromObject(value));
|
||||
break;
|
||||
case "borderEndStartRadius":
|
||||
mViewManager.setBorderEndStartRadius(view, value == null ? 0f : ((Double) value).doubleValue());
|
||||
mViewManager.setBorderEndStartRadius(view, new DynamicFromObject(value));
|
||||
break;
|
||||
case "borderStartEndRadius":
|
||||
mViewManager.setBorderStartEndRadius(view, value == null ? 0f : ((Double) value).doubleValue());
|
||||
mViewManager.setBorderStartEndRadius(view, new DynamicFromObject(value));
|
||||
break;
|
||||
case "borderStartStartRadius":
|
||||
mViewManager.setBorderStartStartRadius(view, value == null ? 0f : ((Double) value).doubleValue());
|
||||
mViewManager.setBorderStartStartRadius(view, new DynamicFromObject(value));
|
||||
break;
|
||||
default:
|
||||
super.setProperty(view, propName, value);
|
||||
|
||||
@@ -27,8 +27,6 @@ public interface RNSVGSvgViewAndroidManagerInterface<T extends View> {
|
||||
void setColor(T view, @Nullable Integer value);
|
||||
void setPointerEvents(T view, @Nullable String value);
|
||||
void setHasTVPreferredFocus(T view, boolean value);
|
||||
void setBorderTopEndRadius(T view, float value);
|
||||
void setBorderBottomStartRadius(T view, float value);
|
||||
void setBorderBottomColor(T view, @Nullable Integer value);
|
||||
void setNextFocusDown(T view, int value);
|
||||
void setBorderRightColor(T view, @Nullable Integer value);
|
||||
@@ -40,11 +38,9 @@ public interface RNSVGSvgViewAndroidManagerInterface<T extends View> {
|
||||
void setNextFocusUp(T view, int value);
|
||||
void setAccessible(T view, boolean value);
|
||||
void setBorderStartColor(T view, @Nullable Integer value);
|
||||
void setBorderBottomEndRadius(T view, float value);
|
||||
void setBorderEndColor(T view, @Nullable Integer value);
|
||||
void setFocusable(T view, boolean value);
|
||||
void setNativeBackgroundAndroid(T view, @Nullable ReadableMap value);
|
||||
void setBorderTopStartRadius(T view, float value);
|
||||
void setNativeForegroundAndroid(T view, @Nullable ReadableMap value);
|
||||
void setBackfaceVisibility(T view, @Nullable String value);
|
||||
void setBorderStyle(T view, @Nullable String value);
|
||||
@@ -52,16 +48,20 @@ public interface RNSVGSvgViewAndroidManagerInterface<T extends View> {
|
||||
void setHitSlop(T view, Dynamic value);
|
||||
void setBorderTopColor(T view, @Nullable Integer value);
|
||||
void setNextFocusLeft(T view, int value);
|
||||
void setBorderTopRightRadius(T view, double value);
|
||||
void setBorderBottomRightRadius(T view, double value);
|
||||
void setBorderRadius(T view, double value);
|
||||
void setBorderBottomLeftRadius(T view, double value);
|
||||
void setBorderTopLeftRadius(T view, double value);
|
||||
void setBorderBlockColor(T view, @Nullable Integer value);
|
||||
void setBorderBlockEndColor(T view, @Nullable Integer value);
|
||||
void setBorderBlockStartColor(T view, @Nullable Integer value);
|
||||
void setBorderEndEndRadius(T view, double value);
|
||||
void setBorderEndStartRadius(T view, double value);
|
||||
void setBorderStartEndRadius(T view, double value);
|
||||
void setBorderStartStartRadius(T view, double value);
|
||||
void setBorderRadius(T view, Dynamic value);
|
||||
void setBorderTopLeftRadius(T view, Dynamic value);
|
||||
void setBorderTopRightRadius(T view, Dynamic value);
|
||||
void setBorderBottomRightRadius(T view, Dynamic value);
|
||||
void setBorderBottomLeftRadius(T view, Dynamic value);
|
||||
void setBorderTopStartRadius(T view, Dynamic value);
|
||||
void setBorderTopEndRadius(T view, Dynamic value);
|
||||
void setBorderBottomStartRadius(T view, Dynamic value);
|
||||
void setBorderBottomEndRadius(T view, Dynamic value);
|
||||
void setBorderEndEndRadius(T view, Dynamic value);
|
||||
void setBorderEndStartRadius(T view, Dynamic value);
|
||||
void setBorderStartEndRadius(T view, Dynamic value);
|
||||
void setBorderStartStartRadius(T view, Dynamic value);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.util.SparseArray;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.bridge.Dynamic;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableType;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
import com.facebook.react.uimanager.PointerEvents;
|
||||
@@ -176,16 +177,6 @@ class SvgViewManager extends ReactViewManager
|
||||
super.setTVPreferredFocus(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderTopEndRadius(SvgView view, float value) {
|
||||
super.setBorderRadius(view, 6, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBottomStartRadius(SvgView view, float value) {
|
||||
super.setBorderRadius(view, 7, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBottomColor(SvgView view, @Nullable Integer value) {
|
||||
super.setBorderColor(view, 4, value);
|
||||
@@ -241,11 +232,6 @@ class SvgViewManager extends ReactViewManager
|
||||
super.setBorderColor(view, 5, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBottomEndRadius(SvgView view, float value) {
|
||||
super.setBorderRadius(view, 8, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderEndColor(SvgView view, @Nullable Integer value) {
|
||||
super.setBorderColor(view, 6, value);
|
||||
@@ -261,11 +247,6 @@ class SvgViewManager extends ReactViewManager
|
||||
super.setNativeBackground(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderTopStartRadius(SvgView view, float value) {
|
||||
super.setBorderRadius(view, 5, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNativeForegroundAndroid(SvgView view, @Nullable ReadableMap value) {
|
||||
super.setNativeForeground(view, value);
|
||||
@@ -346,48 +327,76 @@ class SvgViewManager extends ReactViewManager
|
||||
super.setBorderColor(view, 11, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderRadius(SvgView view, double value) {
|
||||
super.setBorderRadius(view, 0, (float) value);
|
||||
public void setBorderRadius(ReactViewGroup view, int index, Dynamic rawBorderRadius) {
|
||||
double test = 0;
|
||||
if (rawBorderRadius.getType() == ReadableType.Number) {
|
||||
test = rawBorderRadius.asDouble();
|
||||
}
|
||||
super.setBorderRadius(view, index, (float) test);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderTopLeftRadius(SvgView view, double value) {
|
||||
super.setBorderRadius(view, 1, (float) value);
|
||||
public void setBorderRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
this.setBorderRadius(view, 0, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderTopRightRadius(SvgView view, double value) {
|
||||
super.setBorderRadius(view, 2, (float) value);
|
||||
public void setBorderTopLeftRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
this.setBorderRadius(view, 1, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBottomRightRadius(SvgView view, double value) {
|
||||
super.setBorderRadius(view, 3, (float) value);
|
||||
public void setBorderTopRightRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
this.setBorderRadius(view, 2, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBottomLeftRadius(SvgView view, double value) {
|
||||
super.setBorderRadius(view, 4, (float) value);
|
||||
public void setBorderBottomRightRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
this.setBorderRadius(view, 3, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderEndEndRadius(SvgView view, double value) {
|
||||
super.setBorderRadius(view, 9, (float) value);
|
||||
public void setBorderBottomLeftRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
this.setBorderRadius(view, 4, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderEndStartRadius(SvgView view, double value) {
|
||||
super.setBorderRadius(view, 10, (float) value);
|
||||
public void setBorderTopStartRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
this.setBorderRadius(view, 5, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderStartEndRadius(SvgView view, double value) {
|
||||
super.setBorderRadius(view, 11, (float) value);
|
||||
public void setBorderTopEndRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
this.setBorderRadius(view, 6, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderStartStartRadius(SvgView view, double value) {
|
||||
super.setBorderRadius(view, 12, (float) value);
|
||||
public void setBorderBottomStartRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
this.setBorderRadius(view, 7, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderBottomEndRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
this.setBorderRadius(view, 8, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderEndEndRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
this.setBorderRadius(view, 9, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderEndStartRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
this.setBorderRadius(view, 10, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderStartEndRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
this.setBorderRadius(view, 11, rawBorderRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorderStartStartRadius(SvgView view, Dynamic rawBorderRadius) {
|
||||
this.setBorderRadius(view, 12, rawBorderRadius);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,6 @@ interface NativeProps extends ViewProps {
|
||||
|
||||
// props needed for Android SvgView
|
||||
hasTVPreferredFocus?: boolean;
|
||||
borderTopEndRadius?: Float;
|
||||
borderBottomStartRadius?: Float;
|
||||
borderBottomColor?: ColorValue;
|
||||
nextFocusDown?: Int32;
|
||||
borderRightColor?: ColorValue;
|
||||
@@ -52,11 +50,9 @@ interface NativeProps extends ViewProps {
|
||||
nextFocusUp?: Int32;
|
||||
accessible?: boolean;
|
||||
borderStartColor?: ColorValue;
|
||||
borderBottomEndRadius?: Float;
|
||||
borderEndColor?: ColorValue;
|
||||
focusable?: boolean;
|
||||
nativeBackgroundAndroid?: NativeBackgroundProp; // maybe there should a value accepted by codegen for this?
|
||||
borderTopStartRadius?: Float;
|
||||
nativeForegroundAndroid?: NativeBackgroundProp; // maybe there should a value accepted by codegen for this?
|
||||
backfaceVisibility?: string;
|
||||
borderStyle?: string;
|
||||
@@ -64,22 +60,22 @@ interface NativeProps extends ViewProps {
|
||||
hitSlop?: UnsafeMixed<HitSlop | null | number | undefined>;
|
||||
borderTopColor?: ColorValue;
|
||||
nextFocusLeft?: Int32;
|
||||
// TODO: those props are present in the `ReactPropGroup` but are not supported
|
||||
// (https://github.com/facebook/react-native/blob/35556dba600fbb28e0f41340a74b6c4a59bc6018/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java#L613)
|
||||
// and static view config validator says that they are missing.
|
||||
// We pass them as doubles although they should be floats, and cast them to floats again on the native side.
|
||||
borderTopRightRadius?: Double;
|
||||
borderBottomRightRadius?: Double;
|
||||
borderRadius?: Double;
|
||||
borderBottomLeftRadius?: Double;
|
||||
borderTopLeftRadius?: Double;
|
||||
borderBlockColor?: ColorValue;
|
||||
borderBlockEndColor?: ColorValue;
|
||||
borderBlockStartColor?: ColorValue;
|
||||
borderEndEndRadius?: Double;
|
||||
borderEndStartRadius?: Double;
|
||||
borderStartEndRadius?: Double;
|
||||
borderStartStartRadius?: Double;
|
||||
borderRadius?: UnsafeMixed<Double | string>;
|
||||
borderTopLeftRadius?: UnsafeMixed<Double | string>;
|
||||
borderTopRightRadius?: UnsafeMixed<Double | string>;
|
||||
borderBottomRightRadius?: UnsafeMixed<Double | string>;
|
||||
borderBottomLeftRadius?: UnsafeMixed<Double | string>;
|
||||
borderTopStartRadius?: UnsafeMixed<Double | string>;
|
||||
borderTopEndRadius?: UnsafeMixed<Double | string>;
|
||||
borderBottomStartRadius?: UnsafeMixed<Double | string>;
|
||||
borderBottomEndRadius?: UnsafeMixed<Double | string>;
|
||||
borderEndEndRadius?: UnsafeMixed<Double | string>;
|
||||
borderEndStartRadius?: UnsafeMixed<Double | string>;
|
||||
borderStartEndRadius?: UnsafeMixed<Double | string>;
|
||||
borderStartStartRadius?: UnsafeMixed<Double | string>;
|
||||
}
|
||||
|
||||
export default codegenNativeComponent<NativeProps>('RNSVGSvgViewAndroid', {
|
||||
|
||||
Reference in New Issue
Block a user