Skip to content

Commit

Permalink
fix: do not crash when borderRadius is set on Android (#2415)
Browse files Browse the repository at this point in the history
# 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 |    ✅      |
  • Loading branch information
jakex7 authored Sep 30, 2024
1 parent aa7701d commit cc96177
Show file tree
Hide file tree
Showing 6 changed files with 500 additions and 99 deletions.
4 changes: 3 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading

0 comments on commit cc96177

Please sign in to comment.