Commit Graph

151 Commits

Author SHA1 Message Date
Wojciech Lewicki
2b030dda12 feat: move css to different package for size reduction (#2168)
PR based on https://github.com/software-mansion/react-native-svg/pull/1452 extracting `css` related components to different package to reduce the size of the package.

***THIS IS A BREAKING CHANGE***. From now on, you should import 
```
  SvgCss,
  SvgCssUri,
  SvgWithCss,
  SvgWithCssUri,
  inlineStyles,
  LocalSvg,
  WithLocalSvg,
  loadLocalRawResource,
  ```
 from `react-native-svg/css` package instead.
2023-11-14 11:50:03 +01:00
Marlene Cota
f88532d195 [Windows] Port to Direct2D to remove win2d dependency (#2052)
This change removes the win2d (Direct2D wrapper) dependency by using D2D directly. This removes the manual step of adding the win2d to any new react-native-windows projects that want to use react-native-svg. It is also a stepping stone to an easier Fabric implementation for windows.
2023-11-14 11:33:19 +01:00
Wojciech Lewicki
22f47333fb chore: bump examples to rn 0.72.6 (#2166)
PR bumping example apps to the newest RN version so its easier to bump to 0.73.x then.
2023-10-26 10:57:03 +02:00
dependabot[bot]
c514e5a247 chore(deps): bump @babel/traverse from 7.22.8 to 7.23.2 in /Example (#2158)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-25 15:08:31 +02:00
Wojciech Lewicki
7c2c179654 fix: web not working with reanimated in example (#2140)
PR fixing web example when using reanimated since __DEV__ is not defined there.
2023-09-20 16:27:25 +02:00
dependabot[bot]
c88ae5889b chore(deps): bump activesupport from 6.1.7.4 to 7.0.7.2 in /TestsExample (#2122)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-20 16:24:24 +02:00
Wojciech Lewicki
7e514d7232 feat: add macos back to Example app (#2119)
PR restoring macos CI job and restoring usage of UIGraphicsBeginImageContextWithOptions on macos since there is no implementation for UIGraphicsImageRendererFormat there yet.
2023-08-24 12:07:27 +02:00
Wojciech Lewicki
f5503e2c9b feat: remove UIGraphicsBeginImageContextWithOptions from repo (#2117)
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.
2023-08-21 11:35:50 +02:00
Wojciech Lewicki
416ccc8a86 fix: bump packages, eslint, tsconfig, prettier and resolve all conflicts (#2114)
PR bumping packages, eslint, tsconfig, prettier and resolving all conflicts connected to it.
2023-08-07 17:44:58 +02:00
Wojciech Lewicki
91f6bd1fa9 chore: bump Examples to 0.72 (#2084)
Bump Example and FabricExample to RN 0.72
2023-07-05 22:46:42 +02:00
Wojciech Lewicki
29382d927a fix: scale path markers so they match ios (#2018)
PR adding scaling of markers of path in order to make them behave the same as on iOS. Also bumped the versions of agp and spotless.
2023-03-30 14:27:30 +02:00
Mickael Lecoq
a7af70c43d fix #1592 : add marker support on Rect, Line, Ellipse, Circle and Group (#1594)
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>
2023-03-29 15:25:36 +02:00
Wojciech Lewicki
a917baf2ec fix: remove unnecessary methods provided by superclasses for accessibility (#2013)
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.
2023-03-27 15:18:59 +02:00
Wojciech Lewicki
d6975ea9f2 chore: update Example to newest react-native version (#1999)
PR bumping the Example app to RN 0.71
2023-03-09 11:31:48 +01:00
Wojciech Lewicki
cb87e7510f feat: update FabricExample to 0.71.0-rc.6 (#1962)
PR bumping examples to RN 0.71. For now web Example seems not to load code properly.
2023-01-13 14:19:17 +01:00
Marlene Cota
a118c879c7 feat(windows): add example app (#1937)
Added example app for Windows
2023-01-09 12:48:20 +01:00
dependabot[bot]
a21e47d3a1 chore(deps): bump json5 from 2.2.1 to 2.2.3 (#1955)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-04 16:25:45 +01:00
Wojciech Lewicki
1bac96f979 Fix nested SVGs in iOS #1437 (#1948)
PR making the nested svgs parse the references. Originally authored by @tiredBlueWhale.

Co-authored-by: Luca Meyer <lmeyer@Lucas-MacBook-Pro.local>
2023-01-03 20:19:25 +01:00
Wojciech Lewicki
05c33d3245 chore: align examples (#1914)
PR aligning example apps and fixing one bug. On web, if you don't pass a color to the elements, they are rendered with `black` fill. We recreate this behavior in examples, but maybe it should be the default behavior if `fill` is `undefined`. It would probably need to be changed on the native side somehow.

Another fix is to parse `fill` prop in `setNativeProps` since Fabric support has been added and `fill`  prop structure has been changed, it cannot be handled on the native side on `Android` due to complying to interfaces.
Another fix is passing `transform` prop in `Svg` to `G`  when it is not `react-native` style `transform` prop so it is always applied. It creates a problem mentioned in the comment in the code and should be addressed in later PRs.
2022-11-15 12:38:40 +01:00
Wojciech Lewicki
1a2e8c74ed chore: update RN versions to 0.70.5 (#1910)
PR bumping example apps to RN 0.70.5 since previous version will cause CI to fail due to bug in RN.
2022-11-07 16:58:25 +01:00
Wojciech Lewicki
6a5242f00b fix: proper transform prop handling (#1895)
PR aligning handling of transform prop between web and native and adding proper handling of transform prop on web.

origin prop is now treated as transform-origin since it seems like the current behavior of this prop on native platforms.
transform prop cannot be an object with transform properties since it does not provide order of transformations which would lead to undefined behavior so this option has been removed.
RN style of transform prop (array of rotation objects) can now be used
font-size on web seems to be 16px by default and it is 12 in library - maybe we should align it somehow
removed maskTransform prop since it does not exist in SVG standard and did nothing on native side
fixed typo in Fabric Pattern updateProps method
2022-10-25 15:55:17 +02:00
Denis Slávik
65f373b084 fix: [types] allow Image "href" & "xlinkHref" to be strings (#1896)
Allow 'string' type for href and xlinkHref props in Image component.
Logic in the component allows passing 'string' values to the Image.resolveAssetSource by checking for its type, so it would be nice to reflect it on the properties types as well.
2022-10-21 14:43:37 +02:00
Lenz Weber-Tronic
afaf500db9 make reanimated work in web (#1886)
Up until now, trying to use reanimated with react-native-svg in react-native-web resulted in an error.
This adds a setNativeProps function to the web implementation to directly modify the transform and style props on a SVGElement ref.

Since there is a need to track the "last merged props" and those need to be reset on every render, the render method has been moved into the WebShape class and a tag string property has been added.

As g had some extra handling for x and y, a prepareProps function was added as well.
2022-10-13 14:07:20 +02:00
Wojciech Lewicki
1beacf1be2 feat: make pointer events work on both platforms (#1879)
PR adding proper handling of pointerEvents in the library. Based on the comment by @RSNara :

> For all Android components, static ViewConfigs are generated from the components types + BaseVIewConfig.android.js. The BaseViewConfig for all android components is facebook/react-native@c5217f1/Libraries/NativeComponent/BaseViewConfig.android.js#L288-L297, which doesn't contain the pointerEvents validAttribute. So, React Native SVG components must re-declare the pointerEvents validAttribute. Otherwise, the pointerEvents validAttribute won't be in the static ViewConfig, which means React won't pass that prop to native with Static ViewConfigs.

We needed a way to trick codegen since we added our own pointerEvents with string type, and such prop is already present in ViewProps from react-native, but as a union of strings, so their types did not match. As codegen parses string literals, we include changed ViewProps type, without pointerEvents prop, so we satisfy both codegen and TS.

As for how pointerEvents are handled now:

iOS:
Paper: prop is passed in RCTViewManager but it looks like it does not matter what you pass there, since even if you set none, resulting in view.userInteractionEnabled = NO; (facebook/react-native@065db68/React/Views/RCTViewManager.m#L256), custom implementation of hitTest will not take it into account anyhow.

Fabric: we don’t use pointerEvents prop but it is not a problem since it is not used in the implementation of neither SvgView and RCTViewComponentView (it is used in hitTest method there, but we override it)

Android:
Paper: the prop was passed through ReactViewManager and was set on the view directly. But the setter for pointerEvents is not visible outside of ReactViewGroup . After adding Fabric integration for both platforms: BaseViewManager does not implement setter for pointerEvents so we have to add the prop by ourselves. Still, we cannot call the setter from ReactViewGroup since it is not visible, so all the logic for pointerEvents should be migrated to SvgView unfortunately or we should use reflection to get that method.

Despite that, it seems that behavior differs on Android and iOS since setting pointerEvents to none on Android makes the view not clickable, whereas on iOS it does not change anything.
2022-09-30 14:24:34 +02:00
Wojciech Lewicki
992cf19a68 chore: bump examples to rn 0.70 (#1858)
PR bumping Example and FabricExample apps to rn 0.70.
2022-09-06 15:32:00 +02:00
Wojciech Lewicki
0a26639532 chore: bump library and examples to rn 0.70-rc3 (#1837)
PR bumping library to RN 0.70-rc3, which might make it not compatible with earlier versions of RN on Fabric. It should come with the same change in other libraries.

In this PR, I had to remove macos code from Example since it breaks @react-native-community/cli resolution. Hopefully we can bring it back soon.
2022-08-17 14:24:50 +02:00
Wojciech Lewicki
98c14b4f45 chore: add CI for JS, iOS and Android formatting (#1782)
Added CI workflow and local pre-commit hook for formatting and linting the newly added JS, iOS and Android code.
2022-08-16 12:00:32 +02:00
Wojciech Lewicki
8f1bda4856 feat: add Fabric on iOS without ComponentViews (#1821)
Version of #1754 without usage of ComponentViews. It seems like a more proper way, but introduces the necessity of clearing whole state of each component on recycling for it not to be used when view is recycled.

Still known problems:

We stringify props of type NumberProp since codegen only accepts props of a single type. It is the fastest way of dealing with it, but maybe there could be a better way to handle it.
Image resolving should be probably handled the same as in RN core
SvgView needs to set opaque = NO so it is does not have black background (it comes from the fact that RCTViewComponentView overrides backgroundColor setter which in turn somehow messes with the view being opaque). All other svg components do it already so maybe it is not such an issue.
transform prop won't work when set natively since it is not parsed in Fabric
2022-08-11 14:08:11 +02:00
Wojciech Lewicki
286c02fac4 Refactor typescript code (#1806)
Co-authored-by: Eric Butler <eric@codebutler.com>
2022-07-22 17:41:30 +02:00
dependabot[bot]
05b3f28a84 chore(deps): bump async from 2.6.3 to 2.6.4 in /Example (#1759)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-15 12:21:13 +02:00
Wojciech Lewicki
68de5f8170 Update README.md 2022-04-27 15:26:35 +02:00
dependabot[bot]
cf3d817a2b chore(deps): bump ansi-regex from 4.1.0 to 4.1.1 in /Example (#1750)
bump some more deps from dependabot
2022-04-12 16:26:06 +02:00
dependabot[bot]
84e307433b chore(deps): bump many deps with dependabot
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-12 14:50:25 +02:00
Wojciech Lewicki
1b01381f28 feat: remove extractColor in favor of RN impl (#1726)
PR removing extractColor.ts in favor of using the processColor implementation straight from react-native. It should handle all the cases from the previous implementation and the cases with PlatformColor and DynamicColorIOS. Normally we would just send the returned value to the native side, but in react-native-svg, e.g. fill prop can have more values than just color, e.g. currentColor. Because of it, we cannot use UIColor on iOS, NSColor on macOS and customType="Color" on Android as a prop type there and therefore we need to prepare the custom values on the JS side. It is done by passing the prop as an array with specific first element. In case of colors, it is 0. (hopefully I understood the code right).
2022-04-12 13:47:21 +02:00
Mathieu Acthernoene
2fa9645cf6 Add web example (#1717)
Added web example to `Example`
2022-03-07 12:16:50 +01:00
Wojciech Lewicki
2484baa8db feat: move Example to TS (#1712)
This PR changes all examples in Example app to ts in order to more easily check if types are correct and in future remove index.d.ts file.
2022-03-01 14:35:53 +01:00
Wojciech Lewicki
bac4986a23 feat: add macos CI (#1704)
PR adding macOS configuration to Example app and adding CI job for building the app on macOS.
2022-02-24 14:44:17 +01:00
Wojciech Lewicki
14c1124e6f fix: try add gradle-wrapper 2022-02-22 10:16:43 +01:00
Wojciech Lewicki
522c2e31f8 chore: add Example to repo 2022-02-21 16:17:37 +01:00
Mikael Sand
a9f425f306 fix: remove example submodule 2019-08-27 18:09:22 +03:00
Mikael Sand
cc77c83956 Update Example reference 2018-02-12 01:34:50 +02:00
Horcrux
cc38ce3b57 Add example as submodule 2017-01-18 13:58:51 +08:00
Horcrux
80647727bd Remove example 2017-01-18 13:52:19 +08:00
Horcrux
da32b1bb96 Temp commit 2016-11-05 18:42:49 +08:00
Horcrux
ed2da1b364 Merge branch 'master' into text-refactor 2016-09-17 21:06:33 +08:00
Horcrux
d549f6ca9c clean up unused code 2016-09-17 09:49:28 +08:00
Horcrux
a0005fadbd fix eslint warning 2016-09-14 19:47:26 +08:00
Horcrux
699ec64807 update gradle and ESLint related dependencies 2016-09-14 19:40:04 +08:00
Brent Vatne
3d4974942a Make the example project compatible with Exponent and publish it 2016-09-13 21:02:28 -07:00
Horcrux
68b91bb12c update example react-native version to 0.33.0 2016-09-13 10:48:54 +08:00