mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-05 22:56: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:
@@ -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