React Native no longer allows implicit copying of Props, since they're large data-structures and copies are often accidental (bbc517c8c8). This updates react-native-svg to be compatible with this change, and will provide a small perf win.
Since AGP8 this flag is disabled by default. Consumer projects have to enable this flag in them globally if the library doesn't do this correctly itself, but uses custom buildConfig fields.
- What issues does the pull request solve? Please tag them so that they will get automatically closed once the PR is merged
Solves Build Errors with default setup using AGP8+
- What is the feature? (if applicable)
No errors and better build performance than the workaround in consuming projects would be.
Apple made a breaking change in Xcode 15 / macOS Sonoma which breaks usages of drawRect:. You can no longer trust that the OS will provide you a dirtyRect will be within the bounds of your view. Specifically (from the appkit release notes):
Filling the dirty rect of a view inside of -drawRect. A fairly common pattern is to simply rect fill the dirty rect passed into an override of NSView.draw(). The dirty rect can now extend outside of your view’s bounds. This pattern can be adjusted by filling the bounds instead of the dirty rect, or by setting clipsToBounds = true.
This led to an unfortunate bug where any SVG drawn took up the full width/height of your window. Let's follow Apple's advice and draw using [self bounds] instead of dirtyRect.
Changed expo install react-native-svg to npx expo install react-native-svg, because global expo-cli is deprecated [docs-expo-cli](https://docs.expo.dev/archive/expo-cli/)
PR restoring macos CI job and restoring usage of UIGraphicsBeginImageContextWithOptions on macos since there is no implementation for UIGraphicsImageRendererFormat there yet.
Since UIGraphicsBeginImageContextWithOptions will be depracated in iOS 17 (developer.apple.com/documentation/uikit/1623912-uigraphicsbeginimagecontextwitho), I changed the implementation to not use it and use UIGraphicsImageRenderer instead.
Also added Mask examples to be able to test it.
When react-native-svg is used on a web project where typescript has been configured to resolve .web.ts file exentions before .ts, it causes type errors.
This is because the types in ReactNativeSVG.web.ts don't match the types in ReactNativeSVG.ts
This PR adds the correct types for all exported components on the web platform inside ReactNativeSVG.web.ts. Those changes are:
Added missing prop types for all components
Made style, gradientTransform, and patternTransform optional in BaseProps.
Made styleProp argument of resolve() undefined-able, to support style being an optional prop (this also seems to follow the logic in the body of the function, which has a check for a truthy styleProp)
These changes only impact types - no functionality has been changed.
PR adding the proper handling of strokeDasharray prop for when used with Animated and Reanimated. Code based on #1464 by @bardliu, but with the newest state of the repository.
SvgUri component crashes an app when uri with SVG returns html or some other content instead of valid SVG.
This change prevents those crashes and adds fallback property of JSX type which is rendered instead of corrupted SVG.
I implemented this by multiplying the alpha of the currentColor by the opacity when setting a currentColor brush.
Co-authored-by: Wojciech Lewicki <wojciech.lewicki@swmansion.com>
Setting Object to the props type does not allow passing any object to the method. So in TypeScript when using the method for example with Path, you will get an error when passing the d. Instead ob Object, you should use at least P so it allows the original props of the component you are using.
PR adding better Marker support on Android. Markers were only displayed on Path on Android. I have looked at the code and Markers are based on elements attribute which was only filled via PathParser. I have modified getPath method on other shapes in order to fill elements attribute. For groups I only copied data from children.
Co-authored-by: Wojciech Lewicki <wojciech.lewicki@swmansion.com>
PR removing methods that seem unnecessary for the accessibility props since they are provided by superclasses. It was necessary to update fabric updateProps method though, since we don't call super there. Also added proper type definitions and removed unnecessary casts.
It seems that the bug comes from the fact that on iOS we are making a Rect from those values, which takes its starting positions and than width and height as argument, whereas on Android the arguments are strictly 4 bounds, therefore we need to add the starting points to the right and bottom argument.
Since `Image` can use all the props provided by `CommonPathProps` type, we extend it with adding image-specific props.
Co-authored-by: Umesh Dangrecha <umeshdangrecha240@gmail.com>
Co-authored-by: Wojciech Lewicki <wojciech.lewicki@swmansion.com>
Since AGP 8.0 project namespace must be set inside build script.
It is also the recommended way in Android docs.
It is also recommended, that the package name definition is removed from Android manifest file, but I've had some problems in react-native-screens with RN CLI crashing (as it was expecting the package field to exist) & according to this conversation it'll still be legal to leave package name definition in Android manifest file as long as it exactly matches the value in build script.