Commit Graph

1834 Commits

Author SHA1 Message Date
Wojciech Lewicki
079d069c16 chore: remove formatting from blame (#1905)
Added formatting PR to ignored blame to help navigating through commits.
2022-11-03 15:42:16 +01:00
Wojciech Lewicki
b8d408f82f Release 13.5.0 2022-11-02 15:55:14 +01:00
Wojciech Lewicki
f2130ad7cf fix: handle null passed to matrix and tintColor (#1904)
PR adding handling of null values passed to matrix and tintColor props on Android. It should not happen from normal render method, but can still be passed with Animated or Reanimated through native updates or setNativeProps.
2022-11-02 14:54:32 +01:00
Wojciech Lewicki
8cf4068880 fix: handle null passed to SvgLength (#1903)
SvgLength from method should be able to parse null since it is a correct value, we then use the empty constructor since it provides default values.
2022-10-28 14:59:49 +02: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
Robert Sasak
dadf0c975e Web: Support for transform prop (#1835)
Transform prop is ignored on web. This PR stringify transform props so it is compatible with web SVG. It is an extension of #1824
2022-10-18 12:02:17 +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
795bff5f37 Release 13.4.0 2022-10-10 15:37:52 +02:00
Wojciech Lewicki
53abfe5cef fix: make Defs pass invalidate higher even though it does not conform… (#1889)
PR making Defs pass invalidate higher even though it does not conform to RNSVGContainer. Maybe it should be done another way round, making Defs component implement the protocol, since it does it already by having invalidate method.
2022-10-10 12:35:47 +02:00
Jasper Reddin
4aba67cea7 fix: restore compatibility with react-native <0.68 (#1890) (#1891)
Replaces PointerEvents.parsePointerEvents(pointerEventsStr) with PointerEvents.valueOf(pointerEventsStr.toUpperCase(Locale.US).replace("-", "_")). This is the implementation of the original method.
2022-10-10 12:15:39 +02:00
Wojciech Lewicki
f49728d783 Release 13.3.0 2022-10-05 19:28:56 +02:00
André Morales
046051291a Restoring pointer events box_none behavior on Android (#1808)
This PR is a bug fix and makes the pointer-events box-none work again after react-native 66 changes. It changes a bit how it should be used as I'll describe below. This solves #1807 .

I created a getHitSlopRect in the RenderableView that responds with a Rect that make the hit test detection fail on the react-native forcing it to run reactTagForTouch like it used to in previous versions.

This PR impacts pointer events box-none usage. This is an important change for me because it enables the usage of overlapping SVG keeping only the painted area as touchable elements, and not the whole SVG box.
2022-10-05 16:45:25 +02:00
Wojciech Lewicki
b3d2b76496 feat: remove processColor so the color is parsed on the native side (#1887)
PR fixing the behavior of setting color and tintColor values on SvgView component. Since we added proper annotations and macros on the native side, we don't have to call processColor on the JS side.
2022-10-03 09:48:16 +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
Renaud Chaput
f7343013be fix: use export type when exporting types (#1874)
If you built your app using `esbuild` (for example using [`@rnx-kit/metro-serializer-esbuild`](https://microsoft.github.io/rnx-kit/docs/tools/metro-serializer-esbuild)), then it complains that the imports do not exist for type imports.

Marking them explicitely as types fixes this issue, in addition to removing those import/exports from non-TS builds.

I also transformed them from an import + export statements to an `export … from …` statement.
2022-09-27 17:48:26 +02:00
Wojciech Lewicki
f82a0265e2 feat: update props field so rea works correctly (#1880)
PR adding update of _props after updateProps method in order for e.g. react-native-reanimated to pick correct props when running updates. Coauthored by @tomekzaw. It is needed since RCTMountingManager reads this field as oldProps: facebook/react-native@10e47b8/React/Fabric/Mounting/RCTMountingManager.mm#L306
2022-09-26 16:15:59 +02:00
Alessandro Gerelli
bf74342afa Fixed RCT_NEW_ARCH_ENABLED in podspec (#1877)
RCT_NEW_ARCH_ENABLED seems to be always true (even when its value is '0') without an explicit check
2022-09-22 14:42:50 +02:00
Wojciech Lewicki
e7395b41c0 feat: improve ios ci job (#1878)
PR based on software-mansion/react-native-reanimated#3448 which should improve the caches of iOS CI jobs resulting in smaller build time.

Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com>
2022-09-22 12:51:09 +02:00
Wojciech Lewicki
7b7ca40262 Release 13.2.0 2022-09-15 14:34:42 +02:00
insbodhi
0409f37ac2 resolves On Android devices "getPointAtLength" function returns incorrect values (#1727)
While computing the point at length I have passed in the scaled value for path length.
2022-09-15 12:49:45 +02:00
Wojciech Lewicki
3a04189df8 fix: reanimated on old architecture (#1869)
PR adding option for `Double` for all props that were of type `NumberProp` on `Android` so `reanimated` works the same as before on old architecture. It also introduces the change of how `fill` and `stroke` should be constructed for options not going through `render` method, e.g. `react-native-reanimated`. An example of how to handle it can be seen in the provided example: https://github.com/react-native-svg/react-native-svg/pull/1869/files#diff-76a76277daf14518270e8aea8a5e9358a8215d7e4276d2e5f1c4fe95107cdc20
2022-09-15 12:08:57 +02:00
Wojciech Lewicki
ee6e5da195 feat: transfer specs to ts and remove unnecessary props (#1865)
PR transfering Fabric specs to TS, removing unnecessary @ReactProp adnotations, unifying inheritance hierarchy across platforms, adding custom types for color and image source props so they are parsed by react-native.
2022-09-14 12:01:35 +02:00
Wojciech Lewicki
f16a08f40f fix: restore bitmap recycling on children changes (#1864)
PR fixing the regression introduced in #1844. In that PR we set mRemovedFromReactViewHierarchy after one of SvgView's children has been removed, resulting in not being able to update it after one of the components in its hierarchy has been removed. In this PR the behavior has been changed, now we subscribe to startViewTransition which should be called only by react-native-screens when the screen starts its removal animation. It should still work for old issues as well as the new ones.
2022-09-14 11:03:48 +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
2d4489360d fix: remove FabricEnabledViewGroup (#1851)
PR removing FabricEnabledViewGroup since it was only needed for custom state which is not used in react-native-svg.
2022-09-06 12:08:16 +02:00
Tomek Zawadzki
2ff92267ed Fix concurrent CI (#1853)
This PR should hopefully fix CI jobs for Example and FabricExample apps being cancelled by using matrix.working_directory variable in concurrency.group identifier.
2022-09-02 16:49:01 +02:00
Wojciech Lewicki
67755288c0 Release 13.1.0 2022-08-29 17:39:47 +02:00
Wojciech Lewicki
57ea716475 fix: bitmap nulled before screen transition (#1844)
This PR fixes the issues in `react-native-screens` and probably other libraries using native `Fragments` for transitions on Android (see https://github.com/software-mansion/react-native-screens/issues/773). It moves the recycling and setting `mBitMap` to `null` to `onDetachedFromWindow` when the view is removed from `react` view hierarchy. `invalidate` is not always the proper place for doing it since the native view can still be visible for the user after the `invalidate` is called (see this comment with video: https://github.com/software-mansion/react-native-screens/issues/773#issuecomment-769418173).
2022-08-26 16:03:54 +02:00
Wojciech Lewicki
b3618eff40 fix: setters for old react native versions (#1846)
On old react-native versions (e.g. 0.64.4), property setters on Android were handled differently, which resulted in calling Dynamic setters for e.g. fill, matrix and stroke prop. Since JS code has been changed, the props on the native side look a bit different. It lead to bugs in mentioned props, which was not spotted since the code was tested only on the newer versions of react-native, where new view managers are used and props do not resolve in Dynamic setters.
2022-08-26 14:45:18 +02:00
Tomek Zawadzki
8f0f649d2d Use angle-bracket imports (#1848)
This PR replaces bad double-quotes imports (which break Swift interop) with good angle-bracket imports.
2022-08-26 14:41:18 +02:00
Wojciech Lewicki
fdc6ca69bf fix: make svg invalidate after props update (#1843)
Previous method definition resulted in not overriding the base method so after the props update, SvgView was not invalidated and redrawn.
2022-08-23 10:36:04 +02:00
Wojciech Lewicki
0313f0cc07 Release 13.0.0 2022-08-17 16:42:35 +02:00
Wojciech Lewicki
a69cf7651d Update README.md 2022-08-17 16:35:11 +02:00
Wojciech Lewicki
778703d8a3 feat: remove unused common folder (#1838)
PR removing common directory from library since it is not used currently due to no custom shadow nodes etc. in Fabric implementation.
2022-08-17 15:50:01 +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
77267be5fc feat: support Fabric on Android (#1804)
Most of Android changes for Fabric and bump of FabricExample to RN 0.69.2. iOS and JS changes are available in #1821.
The most notable change on Android is adding methods to components that accept String values of each NumberProp instead of Dynamic. Another change is changed structure of RenderableViewManager.java since we needed to abstract methods that belong only to components inheriting from VirtualView in order to be able to properly override them in their children.
2022-08-12 11:42:44 +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
f1fa606664 Release 12.4.4 2022-08-10 12:52:22 +02:00
Wojciech Lewicki
7a773654b1 feat: change ios CI (#1831)
Added improved iOS CI jobs
2022-08-10 11:54:21 +02:00
Robert Sasak
4062c2e2b8 Add support for translateX and translateY on web (#1825)
Props translateX and translateY are ignored on web. This PR is addressing it the same way as it is already done for originX and originY.

This PR is not addressing the issue of transform as stated in issue.
2022-08-10 10:27:35 +02:00
Wojciech Lewicki
b00579a957 fix: export types from lib which were available before (#1829)
Exported all types from lib/extract/types.tsx since most of them were available before refactor done in #1806.
2022-08-09 15:45:17 +02:00
tainakanchu
6d1110b9c0 feat: fix broken enum declaration (#1819)
After #1800 merged, the refactoring 286c02f was performed and enum declaration was back to previous one.
So type error mentioned at #1210 for maskUnits should occurred again.
2022-08-09 14:20:33 +02:00
Hyo
8d0ae5e04e Fix constructor with deprecated context (#1822)
The constructor with context is deprecated and occurs types error in react-native@69+.
2022-08-09 14:08:07 +02:00
Wojciech Lewicki
34ece786b3 Release 12.4.3 2022-07-26 17:56:13 +02:00
Wojciech Lewicki
24cfaabe33 Add onLoad method to SvgUri (#1817)
Co-authored-by: Harvey Connor <harvey@smartguide.com.au>
2022-07-26 17:47:12 +02:00
Wojciech Lewicki
c87f823bf0 fix: remove tsignore in LocalSvg and provide correct types (#1816)
PR adding proper typings for asset prop of LocalSvg based on Image.resolveAssetSource() typings. Based on #1593 by @pratyushok.
2022-07-26 16:50:42 +02:00
Wojciech Lewicki
af68c93d04 add missing onLayout prop typings (#1815)
onLayout prop typings are missing. This PR simply adds missing onLayout prop to svg nodes.

Co-authored-by: Sergey Tshovrebov <sinxwal@gmail.com>
2022-07-26 16:03:38 +02:00
Wojciech Lewicki
9c1a8b1f71 fix: correctly export rest of the props and add onError to parsing (#1814)
PR correctly exporting rest of the props and adding onError to parsing in other Svg components.
2022-07-26 15:27:56 +02:00