Commit Graph
2019 Commits
Author SHA1 Message Date
Jakub GrzywaczandGitHub acd29d7468 fix: FilterImage css filter on web (#2387) 2024-08-01 09:29:20 +02:00
Bohdan ArtiukhovandGitHub 15135d695b fix: change way passing onPress prop (#2386) 2024-08-01 09:28:57 +02:00
Jakub GrzywaczandGitHub cec99a5035 fix: mac os crashes (#2385)
# Summary

Fix some crashes on MacOS
* patch `reanimated`
* update fabric type
* invert axis in `FeOffset`
2024-07-31 16:27:35 +02:00
Jakub GrzywaczandGitHub 7acbee41f3 fix: FeMerge on paper (#2384)
# Summary

Use empty string (`""`) instead of `undefined` for previous filter
result in `FeMergeNode`
2024-07-31 15:13:50 +02:00
Jakub GrzywaczandGitHub b8b022c31e feat: add FeMerge and FeMergeNode filters (#2369)
# Summary

As mentioned in #2362
Introduce new filters:
* `FeMerge`
* `FeMergeNode`

## Example usage

```tsx
<Svg width="200" height="200">
  <Filter id="mergeWithOffset" width="180" height="180">
    <FeOffset dx="50" dy="50" result="test" />
    <FeOffset dx="100" dy="100" in="SourceGraphic" />
    <FeMerge>
      <FeMergeNode in="SourceGraphic" />
      <FeMergeNode in="test" />
      <FeMergeNode />
    </FeMerge>
  </Filter>
  <Rect
    x="0"
    y="0"
    width="100"
    height="100"
    stroke="black"
    fill="red"
    filter="url(#mergeWithOffset)"
  />
</Svg>
```

<img width="207" alt="image"
src="https://github.com/user-attachments/assets/9cb3ded6-f939-4b2b-8ece-df54e64fe898">

## Test Plan

`Example` app -> `Filters` -> `FeMerge`

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅     |
| Android |    ✅     |

## Checklist

- [x] I have tested this on a device and a simulator
- [x] I added documentation in `README.md`
- [x] I updated the typed files (typescript)
2024-07-31 13:23:53 +02:00
a2e843bc9c feat: add web implementation SvgXml and others component (#2382)
# Summary
We want to make available SvgXml and other components in the web
platform.

## Test Plan
We can easily check how that works by opening `Test1813`.

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| Web     |    ✅     |

---------

Co-authored-by: Jakub Grzywacz <jakub.grzywacz@swmansion.com>
2024-07-31 11:56:48 +02:00
a27e17f505 fix: circular-dependencies (#2381)
# Summary
- Require cycles are allowed, but can result in uninitialized values.
Consider refactoring to remove the need for a cycle.
- extract SVG web components.
- extract web types.
- extract utils function.

## Test Plan
You can test that problem by running a test example `Test1813`

### What are the steps to reproduce (after prerequisites)?
Without those changes, you can occur that problem by running a test
example `Test1813`

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅     |
| Android |    ✅     |

---------

Co-authored-by: Jakub Grzywacz <jakub.grzywacz@swmansion.com>
2024-07-31 11:45:04 +02:00
Tomasz ŻelawskiandGitHub 129e8ed8b5 feat: Make CMake less verbose (#2377)
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect -->

# Summary

Explain the **motivation** for making this change: here are some points
to help you:

* What issues does the pull request solve? Please tag them so that they
will get automatically closed once the PR is merged
* What is the feature? (if applicable)
* How did you implement the solution?
* What areas of the library does it impact?

## Test Plan

Demonstrate the code is solid. Example: The exact commands you ran and
their output, screenshots / videos if the pull request changes UI.

### What's required for testing (prerequisites)?

### What are the steps to reproduce (after prerequisites)?

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅❌     |
| Android |    ✅❌     |

## Checklist

<!-- Check completed item, when applicable, via: [X] -->

- [x] I have tested this on a device and a simulator
- [x] I added documentation in `README.md`
- [x] I updated the typed files (typescript)
- [x] I added a test for the API in the `__tests__` folder
2024-07-30 09:34:37 +02:00
Bohdan ArtiukhovandGitHub e8f129c6b7 chore: update example yarn.lock (#2378)
# Summary
update yarn.lock file in example app.
2024-07-29 15:10:20 +02:00
4fd2ccdb94 fix: add new macos examples (#2372)
# Summary
We want to avoid problems with GitHub workflows.
Create a new Macos example for new and old architecture.

## Test Plan

Run GitHub workflows

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| macOS     |    ✅     |

---------

Co-authored-by: Jakub Grzywacz <jakub.grzywacz@swmansion.com>
2024-07-29 14:46:00 +02:00
Jakub GrzywaczandGitHub bbd38fb15b fix: web example (#2376)
Fix web example by adding missing tags and importing react
2024-07-29 13:57:53 +02:00
Bohdan ArtiukhovandGitHub 6a563f42b6 fix: type problem ReactNativeSvg.web.ts (#2374)
# Summary

Fix type problem in `ReactNativeSvg.web.ts`
2024-07-29 13:57:19 +02:00
360e0ee01a fix(xml): extract tags map to separate entry point for mobile & web (#1916)
# Summary

**What issues does the pull request solve? Please tag them so that they
will get automatically closed once the PR is merged**

When utilizing with `react-native-web`: SvgXml and SvgUri are not
exported in the `src/ReactNativeSVG.web.ts` extension. The logic for
SvgXml and SvgUri do not have native dependencies, so they are safe to
consume on web.

Issues:
- https://github.com/software-mansion/react-native-svg/issues/1279
- https://github.com/software-mansion/react-native-svg/issues/1742

**What is the feature? (if applicable)**

Add SvgXml and SvgUri as consumable exports for `react-native-web`

**How did you implement the solution?**

Extract `tags` to shapes map into separate `tags.tsx` file, where native
shape elements and web shape elements can be provided to their
respective envs.

**What areas of the library does it impact?**

`src` directory

## Test Plan

Demonstrate the code is solid. Example: The exact commands you ran and
their output, screenshots / videos if the pull request changes UI.

### What's required for testing (prerequisites)?
n/a

### What are the steps to reproduce (after prerequisites)?
n/a

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅     |
| Android |    ✅     |

## Checklist

<!-- Check completed item, when applicable, via: [X] -->

- [x] I have tested this on a device and a simulator
- [x] I added documentation in `README.md`
- [x] I updated the typed files (typescript)
- [ ] I added a test for the API in the `__tests__` folder

---------

Co-authored-by: bohdanprog <bohdan.artiukhov@swmansion.com>
2024-07-29 13:06:19 +02:00
Bohdan ArtiukhovandGitHub c5e601a98f feat: Add link to QA section and feature requests (#2373)
# Summary
Add a link to the QA section and feature requests
2024-07-29 09:43:59 +02:00
Jakub GrzywaczandGitHub 25099ff220 refactor: small changes to filters (#2368)
# Summary

This PR contains two small refactors of filters:
* extract common props on ViewManagers on Android
* remove unnecessary extract in `FeOffset` filter
2024-07-29 08:21:17 +02:00
bohdanprog 45d6484c6a feat: check build only old arch 2024-07-26 11:09:40 +02:00
Jakub GrzywaczandGitHub 5807f2c1a6 feat: add FeOffset filter (#2361)
# Summary

Continuation of #2316
Introducing new filter `FeOffset`.

## Test Plan

Example app -> Filters -> FeOffset

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅     |
| Android |    ✅     |

## Checklist

- [x] I have tested this on a device and a simulator
- [x] I added documentation in `README.md`
- [x] I updated the typed files (typescript)
2024-07-25 12:32:15 +02:00
Jakub GrzywaczandGitHub 44254df9fb feat: add FeGaussianBlur filter (#2352)
# Summary

Continuation of #2316 
Introducing new filter `FeGaussianBlur`.

### Implementation notes

On Android there is no easy way to fully implement Gaussian blur, as
there is no native api for this. While a basic implementation is
possible with `RenderScript`, it does not allow for blur in one axis and
greater than `25`

## Test Plan

Example app -> Filters -> FeGaussianBlur

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅     |
| Android |    ✅     |
2024-07-25 11:46:45 +02:00
Jakub GrzywaczandGitHub ba7d77548f feat: support filters on web (#2346)
# Summary

* Export `Filter` and `FeColorMatrix` components on `web`
* Change filter IDs in example to be unique*
* Generate filter ID when using `FilterImage`*
* Hide `FilterImage` example on web, since it's crashing the whole site
(see #2334)

\* ID on web has to be unique, otherwise it'll use the first element
with that ID, even if they are in the separate SVG elements

## Test Plan

run `web-example` app

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| Web     |    ✅     |
2024-07-25 10:45:24 +02:00
Jakub GrzywaczandGitHub 52466a2564 feat: introduce CSS filter API on FilterImage (#2359)
# Summary

Provide a **CSS**-like filter API in the `FilterImage` component. 
Unlike the SVG filter API, which can be complex and challenging even for
simple tasks, the CSS API is straightforward and allows users to quickly
achieve satisfactory results.

The full API can be viewed here
https://developer.mozilla.org/en-US/docs/Web/CSS/filter
_We support all `<filter-function>` listed in the docs while we do not
support functions from `<url>` (`url()` and `src()`)._

All shorthands are implemented according to the W3 standard described
here
https://www.w3.org/TR/filter-effects-1/#ShorthandEquivalents

This PR also changes the `filters` prop behavior as it adds `fe` in
front of `name` attribute to not introduce any abstract above that
specified in the docs.
```tsx
<FilterImage
  source={myImage}
  filters={[{ name: 'colorMatrix', type: 'saturate', values: 0.2 }])
/>
```
is now 
```tsx
<FilterImage
  source={myImage}
  filters={[{ name: 'feColorMatrix', type: 'saturate', values: 0.2 }])
/>
```

## Examples
Below are the simple examples of the usage

through `StyleSheet`
```tsx
import React from 'react';
import {StyleSheet, View} from 'react-native';
import {FilterImage} from 'react-native-svg/filter-image';

export default () => {
  return (
    <FilterImage
      style={styles.image}
      source={{
        uri: 'https://cdn.pixabay.com/photo/2024/05/26/00/40/lizard-8787888_1280.jpg',
      }}
    />
  );
};
const styles = StyleSheet.create({
  image: {
    width: 200,
    height: 200,
    filter: 'saturate(100) grayscale(100%)',
  },
});
```

or directly in the `style` prop

```tsx
import React from 'react';
import {StyleSheet, View} from 'react-native';
import {FilterImage} from 'react-native-svg/filter-image';

export default () => {
  return (
    <FilterImage
      style={{
        width: 200,
        height: 200,
        filter: 'saturate(100) grayscale(100%)',
      }}
      source={{
        uri: 'https://cdn.pixabay.com/photo/2024/05/26/00/40/lizard-8787888_1280.jpg',
      }}
    />
  );
};
```

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅     |
| Android |    ✅     |

## Checklist

- [x] I have tested this on a device and a simulator
- [x] I added documentation in `README.md`
- [x] I updated the typed files (typescript)
2024-07-25 10:19:47 +02:00
Jakub GrzywaczandGitHub 00e492e8cf fix: applying multiple filters on iOS (#2366)
# Summary

Applying multiple `FeColorFilter` instances can cause unexpected
behavior on iOS, likely due to a bug in `CoreImage` where the `CIImage`
recipe isn't applied step by step as it should be. This fix ensures that
the filter result is rendered after each application by converting the
image to `CGImage` and then back to `CIImage`.

## Test Plan

With this simple test, we can prove that these changes are working
```tsx
<Svg height="200" width="200">
  <Filter id="filter">
    <FeColorMatrix type="matrix" values="78 -70 -7 0 0 -21 29 -7 0 0 -21 -70 0 0 0 0 0 0 1 0"/>
    <FeColorMatrix type="matrix" values="0.2126, 0.7152, 0.0722, 0, 0, 0.2126, 0.7152, 0.0722, 0, 0, 0.2126, 0.7152, 0, 0, 0, 0, 0, 0, 1, 0"/>
  </Filter>
  <Rect width="200" height="200" fill="red" filter="url(#filter)"/>
</Svg>
```

| Web | iOS before changes | iOS after changes |
| --- | --- | --- |
| <img width="242" alt="image"
src="https://github.com/user-attachments/assets/dc683341-b3ca-4fab-86d8-cf72b15c13d4">
| <img width="237" alt="image"
src="https://github.com/user-attachments/assets/d4a1af5d-ae67-4ed9-9dbd-d03540b2c63c">
| <img width="249" alt="image"
src="https://github.com/user-attachments/assets/83e856a6-5bcc-4534-ad7b-a1f188434e1c">
|
2024-07-25 10:15:08 +02:00
Jakub GrzywaczandGitHub 9a2cd3d855 fix: color shift in FeColorMatrix on android (#2365)
# Summary

While debugging #2364 I've noticed that color shift in `FeColorMatrix`
on Android is wrong.
On web, elements 5, 10, 15, 20 is a color shift represented by number
where 1 mean full color shift, while on Android it's 255 for full color
shift.

## Test

```tsx
<svg width="180" height="180" viewBox="0 0 180 180">
  <rect width="180" height="180" fill="red" filter="url(#filter)"/>
  <filter id="filter">
    <feColorMatrix type="matrix" values="0 0 0 0 1
                                         0 1 0 0 0
                                         0 0 1 0 0
                                         0 0 0 1 0"/>
  </filter>
</svg>
```
2024-07-24 16:27:06 +02:00
67620f5b6a fix: macOS new architecture build (#2341)
# Summary
Based on recommendations from this
[proposition](https://github.com/software-mansion/react-native-svg/issues/2192#issuecomment-2177330499)
and added some changes now we can build macOS using the new
architecture.

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| macOS     |    ✅     |

---------

Co-authored-by: Maciej Stosio <maciekstosio@users.noreply.github.com>
2024-07-23 15:34:32 +02:00
Jakub GrzywaczandGitHub 0d97399d06 fix: ignore invalid filter id (#2360)
# Summary

Closes #2356
Currently, when `filter` prop is defined, but there is no equivalent
`<Filter>` component, on iOS nothing is rendered, with this fix this
prop would be ignored, and the component should render as expected.

## Test Plan

```tsx
<Svg width="400" height="400" viewBox="0 0 124 124" fill="none">
  <Rect width="124" height="124" rx="24" fill="red" filter="url(#nonExistingFilterId)"/>
</Svg>
```

## Affected platforms

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅     |
2024-07-22 16:18:12 +02:00
Maciej StosioandGitHub 567e90521a Feat: add scripts to sync archs (#2357)
Changes moved from:
https://github.com/software-mansion/react-native-screens/pull/2224

## Description

When changing native props on Fabric, codegen generates corresponding
interfaces and delegates. To make sure both implementations are
consistent, we implement those interfaces on Paper too. Currently, after
generating interfaces using codegen, developer needs to copy
corresponding files for paper manually. This task adds Gradle task, that
automates this.

## Changes
Current assumption: 
Two scripts: `check-archs-consistency` and `sync-archs`. The first one
generates codegen interfaces and compares them with what we have for
paper, the second generates and copies for paper to sync the archs.
- sync is run when staged on changes to `src/paper`
- check is run on CI when `src/paper` or
`android/src/paper/java/com/facebook/react/viewmanagers` changes

## Test code and steps to reproduce

Open `src/fabric/LineNativeComponent.ts` or/and
`src/fabric/NativeSvgRenderableModule.ts` and remove any proper form
interface. Now:
- when building paper, interface should be updated
- when committing, interface should be updated
- if committed and pushed, Test consistency between Paper & Fabric
should fail :)
Brining back the prop and repeating up should cause the interface back
and CI green.
Posting changes in other places should cause CI task to run. 

You can also run those commands yourself using `yarn
check-archs-consistency` and `yarn sync-archs`
2024-07-22 14:58:37 +02:00
Bohdan ArtiukhovandGitHub 2da02cf259 feat: add new resolve web asset function (#2334)
# Summary
Add a new function to resolve Image asset uri.

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| Web     |    ✅     |
2024-07-19 17:12:49 +02:00
Jakub GrzywaczandGitHub 657a102b5f fix: cannot set property transform of undefined (gStyle) (#2355)
# Summary

Fix bug introduced in #2189, 
if `style` is not provided, then `StyleSheet.flatten` returns
`undefined`, and we're trying to access `transform` of it.

## Test Plan

Run `example` app
2024-07-19 11:52:22 +02:00
Bohdan ArtiukhovandGitHub 26c4c73400 feat: update reanimated dependency (#2336)
# Summary
Update reanimated dependency in all example apps.
2024-07-18 12:46:20 +02:00
Bohdan ArtiukhovandGitHub 2b6ced416b feat: format project and change in test example default component (#2350)
# Summary
Format the whole project.
2024-07-18 12:45:36 +02:00
74445cc0fd fix: allow to array style prop (#2189)
# Summary
- Previously, styles in "Array" format were not being applied correctly.
- Therefore, now ensure that styles in "Array" format are correctly
applied using `StyleSheet.flatten.`


**Before: The `opacity` attribute is not correctly applied in
`gStyle`.** ❌
```tsx
const gStyle = Object.assign({}, [{ opacity: 0.5 }]);
/* { 0: {opacity: 0.5 }} */
```

**After: Now, the `opacity` attribute is correctly applied in
`gStyle`.** ✅
```tsx
const gStyle = StyleSheet.flatten([{ opacity: 0.5 }]);
/* { opacity: 0.5 } */
```

```tsx
const gStyle = StyleSheet.flatten([{ opacity: 0.5 }, { backgroundColor: 'red' }]);
/* { opacity: 0.5, backgroundColor: 'red' } */
```

## Test Plan

`0` key is not allow to `ViewStyle`

### What's required for testing (prerequisites)?

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅    |
| Android |    ✅     |

## Checklist

<!-- Check completed item, when applicable, via: [X] -->

- [x] I have tested this on a device and a simulator

---------

Co-authored-by: bohdanprog <bohdan.artiukhov@swmansion.com>
2024-07-18 11:25:08 +02:00
Bohdan ArtiukhovandGitHub b8ff336fc5 fix: remove using pattern matching in FilterView (#2354)
# Summary
Closes #2347
Fixed a problem with building an Android app, pattern matching threw an
error when we tried to build an Android app.

[Repository](https://github.com/bohdanprog/react-native-svg-error-pattern-matching)
to reproduce that error.
## Test Plan
We can easily check that build the app.

### What are the steps to reproduce (after prerequisites)?
build the app without that fix.

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| Android |    ✅     |
2024-07-18 10:52:02 +02:00
Marlene CotaandGitHub 3b360a2b58 feat: improve windows ci job (#2329)
Improves the windows build time.
2024-07-12 09:51:43 +02:00
Jakub Grzywacz 5d7f21265a Release 15.4.0 2024-07-11 15:01:30 +02:00
Jakub GrzywaczandGitHub d548750263 fix: mask and filters rendering issues (#2345)
# Summary

Fixed rendering issues on macOS and iOS after merging Mask and Filter
changes together.

## Test Plan

Example app
2024-07-11 13:40:41 +02:00
Jakub GrzywaczandGitHub 08e92074b4 feat: filters support FeColorMatrix and FilterImage (#2316)
# Summary

Introducing the long-awaited **Filters** in `react-native-svg` 🎉

### Motivation

This PR is the beginning of bringing support of SVG Filters into
`react-native-svg`.

* **related issues**: This PR series will address the following issues:
#150, #176, #635, #883, #994, #996, #1216
* **feature overview**: This PR is a boilerplate for Filters
   * introducing `Filter` component and `FeColorMatrix` as a start. 
* It also introduces a new subdirectory called
`react-native-svg/filter-image` with a `FilterImage` component.

# Usage

## Filter and Fe...

Filters are compatible with the web familiar standard, so most things
should be compatible out-of-the-box and changes will be limited to using
a capital letter as it's component.

### Example

```tsx
import React from 'react';
import { FeColorMatrix, Filter, Rect, Svg } from 'react-native-svg';

export default () => {
  return (
    <Svg height="300" width="300">
      <Filter id="myFilter">
        <FeColorMatrix type="saturate" values="0.2" />
      </Filter>
      <Rect
        x="0"
        y="0"
        width="300"
        height="300"
        fill="red"
        filter="url(#myFilter)"
      />
    </Svg>
  );
};
```

![image](https://github.com/software-mansion/react-native-svg/assets/39670088/c36fb238-95f4-455d-b0aa-2a7d4038b828)

## Filter Image

`FilterImage` is a new component that is not strictly related to SVG.
Its behavior should be the same as a regular `Image` component from
React Native with one exception - the additional prop `filters`, which
accepts an array of filters to apply to the image.

### Example

```tsx
import React from 'react';
import { StyleSheet } from 'react-native';
import { FilterImage } from 'react-native-svg/filter-image';

const myImage = require('./myImage.jpg');

export default () => {
  return (
    <FilterImage
      style={styles.image}
      source={myImage}
      filters={[
        { name: 'colorMatrix', type: 'saturate', values: 0.2 },
        {
          name: 'colorMatrix',
          type: 'matrix',
          values: [
            0.2, 0.2, 0.2, 0, 0, 0.2, 0.2, 0.2, 0, 0, 0.2, 0.2, 0.2, 0, 0, 0, 0,
            0, 1, 0,
          ],
        },
      ]}
    />
  );
};
const styles = StyleSheet.create({
  image: {
    width: 200,
    height: 200,
  },
});
```


![image](https://github.com/software-mansion/react-native-svg/assets/39670088/666ed89f-68d8-491b-b97f-1eef112b7095)

## Test Plan

**Example App**: Updated the example app with various filter effects,
showcasing real-world usage.

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅     |
| Android |    ✅     |

## Checklist

- [x] I have tested this on a device and a simulator
- [x] I added documentation in `README.md` and `USAGE.md`
- [x] I updated the typed files (typescript)
2024-07-11 11:17:35 +02:00
Tomek ZawadzkiandGitHub 1de7709176 Add missing #import <folly/dynamic.h> on RN 0.75 (#2344)
Currently, react-native-svg fails to compile on Android with react-native@0.75.0-rc.4 and new architecture enabled due to an unknown identified folly::dynamic.

This PR adds the missing import so that the identifier has a declaration.
2024-07-11 09:59:57 +02:00
Bartosz StefańczykandGitHub dd57e9e83b fix: fix format-js task to reflect changes made to folder structure (#2342)
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect -->

# Summary
Fixes following error while commiting:
```
✖ yarn format-js:
[error] No files matching the pattern were found: "./Example/src/**/*.tsx".
error Command failed with exit code 2.
```


## Test Plan

Run `yarn format-js` or do a commit so hook will get ran.

### What's required for testing (prerequisites)?
-

### What are the steps to reproduce (after prerequisites)?
See test plan

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅     |
| Android |    ✅     |

## Checklist

<!-- Check completed item, when applicable, via: [X] -->

- [X] I have tested this on a device and a simulator
- [ ] I added documentation in `README.md`
- [] I updated the typed files (typescript)
- [ ] I added a test for the API in the `__tests__` folder
2024-07-10 14:45:36 +02:00
Jakub GrzywaczandGitHub 171f3ba5d6 fix: macos mask (#2337)
# Summary

Fixed regression introduced in #2299. Now `<Mask>` is rendering properly
on MacOS.

## Test Plan

* `Test1451` in `TestsExample`
* Masking section in `example`


https://github.com/software-mansion/react-native-svg/assets/39670088/dccc937d-125d-4b60-864b-cc3b9a4179fb

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| macOS     |    ✅     |
2024-07-10 11:24:30 +02:00
Bohdan ArtiukhovandGitHub 979fb06b13 feat: extract web example (#2333)
# Summary
extract web-example from example app.
2024-07-09 11:07:31 +02:00
832522d1c1 feat: implement mask-type property (#2152)
# Summary

"mask-type: alpha" is not supported. 
resolve issue: #1790  

## Explanation

svg example:
```
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100" fill="none">
<g clip-path="url(#clip0_8_3)">
<rect width="100" height="100" fill="white"/>
<mask id="mask0_8_3" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="100" height="100">
<circle cx="50" cy="50" r="50" fill="#000000"/>
</mask>
<g mask="url(#mask0_8_3)">
<rect x="-26" y="-78" width="209" height="263" fill="#252E74"/>
</g>
</g>
<defs>
<clipPath id="clip0_8_3">
<rect width="100" height="100" fill="white"/>
</clipPath>
</defs>
</svg>
```

Current behavior: 

![image](https://github.com/software-mansion/react-native-svg/assets/17138397/2dca6f46-fe8f-48f3-80f9-799563911e8b)

Expected behavior:

![image](https://github.com/software-mansion/react-native-svg/assets/17138397/fb49cf0b-d677-491f-8215-9c9b1d69080f)

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅    |
| Android |    ✅    |

## Checklist

<!-- Check completed item, when applicable, via: [X] -->

- [x] I have tested this on a device and a simulator
- [ ] I added documentation in `README.md`
- [x] I updated the typed files (typescript)
- [ ] I added a test for the API in the `__tests__` folder

---------

Co-authored-by: Sergey <s.yurkevich@logiclike.com>
Co-authored-by: Jakub Grzywacz <jakub.grzywacz@swmansion.com>
2024-07-05 15:11:48 +02:00
Bohdan ArtiukhovandGitHub 7c1602e291 feat: change folders structure (#2319)
# Summary
extract the shared example and use it in example and fabric-example, macos-example

## Test Plan

Run those apps manually.
2024-07-05 13:00:13 +02:00
Jakub GrzywaczandGitHub 9dc024702b fix: extract opacity use percentage values (#2325)
# Summary

According to the MDN Docs `opacity` as a `<alpha-value>` can be
represented as
> A [<number>](https://developer.mozilla.org/en-US/docs/Web/CSS/number)
in the range 0.0 to 1.0, inclusive, or a
[<percentage>](https://developer.mozilla.org/en-US/docs/Web/CSS/percentage)
in the range 0% to 100%, inclusive, representing the opacity of the
channel (that is, the value of its alpha channel). Any value outside the
interval, though valid, is clamped to the nearest limit in the range.

https://developer.mozilla.org/en-US/docs/Web/CSS/opacity#alpha-value

https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-opacity#usage_notes
2024-07-05 10:48:03 +02:00
Mateusz TitzandGitHub e2d9cbf1e3 fix: add correct invalidate calls to SvgView on ios with test (#2327)
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect -->

# Summary
This is a sibling PR to:
https://github.com/software-mansion/react-native-svg/pull/2318 which
fixed missing mount/unmount methods to correctly display SVG.

This PR overrides the same `mountChildComponentView` and
`unmountChildComponentView` methods but for `RNSVGSvgView` component.
This will make the components and their behaviour aligned and more
predictable.

I included the test that specifically tests for attaching another
external svg into and already existing SVG, should catch any edge cases
with invalidation/redrawing.

## Test Plan
`TestExample` app -> `TestSvgUriUpdating` example.


https://github.com/software-mansion/react-native-svg/assets/3929868/49499914-7037-4ab0-a9a9-1e139d460117


## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅    |

## Checklist

<!-- Check completed item, when applicable, via: [X] -->

- [x] I have tested this on a device and a simulator
- [ ] I added documentation in `README.md`
- [ ] I updated the typed files (typescript)
- [ ] I added a test for the API in the `__tests__` folder
2024-07-04 15:28:47 +02:00
Bohdan ArtiukhovandGitHub fe94bd9439 fix: add check in RNSVGImage for macos platform (#2324)
# Summary
add check-in RNSVGImage for the Maco platform
2024-07-03 11:22:15 +02:00
Marlene CotaandGitHub 1ad180cba0 feat: add Example Windows build workflow (#2322)
PR adding build workflow for windows.
2024-07-03 10:02:59 +02:00
Marlene CotaandGitHub 2514ac4fdf feat(windows): add support for 74 and bump Example (#2315)
Added support for RNW 74.
Bumped windows Example to 74.
Updated README.md to remove instructions on how to import Win2D since we no longer use it.
2024-07-02 09:34:04 +02:00
9faa387a98 Fix: image onLoad props (#2317)
# Summary
Change data structure returned from the Image onLoad event.
Add fix in new arch for returned sizes.

## Test Plan

Manually test in both architectures and platforms.

### What's required for testing (prerequisites)?

### What are the steps to reproduce (after prerequisites)?

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |      ✅     |
| Android |    ✅    |

---------

Co-authored-by: Jakub Grzywacz <jakub.grzywacz@swmansion.com>
2024-07-02 09:33:25 +02:00
Jakub GrzywaczandGitHub e16a1519ba fix: new arch invalidate on mount/unmount (#2318)
# Summary

On iOS with the new architecture, when mounting or unmounting a
component, changes were not visible because `invalidate` wasn't called.
These changes override `mountChildComponentView` and
`unmountChildComponentView` to ensure that invalidate is called when
`RNSVGNode` is mounted or unmounted.

## Test Plan

`TestExample` app -> `MountUnmount` example 

```tsx
import React from 'react';
import {Button, Text, View} from 'react-native';
import {Rect, Svg} from 'react-native-svg';

export default () => {
  const [show, setShow] = React.useState(true);
  return (
    <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
      <Text>Blue rect is mounted: {show ? 'true' : 'false'}</Text>

      <Svg height="300" width="300">
        {show ? (
          <Rect x="100" y="100" width="100" height="100" fill="blue" />
        ) : null}
      </Svg>
      <Button title="Toggle" onPress={() => setShow(!show)} />
    </View>
  );
};
```


https://github.com/software-mansion/react-native-svg/assets/39670088/0eaf9a61-b47b-4f89-a7c7-a67375e2e63e


https://github.com/software-mansion/react-native-svg/assets/39670088/709feedf-63c1-47d7-b799-f3899278fe77


## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅     |
2024-07-01 16:21:18 +02:00
Bohdan ArtiukhovandGitHub fe48dfb238 feat: update needs-more-info git workflow (#2314)
# Summary
update check of react-native-svg version in GitHub workflow.
2024-06-28 09:04:45 +02:00
Bohdan ArtiukhovandGitHub c0ee3e9ca0 add onLoad prop to Image component (#2293)
# Summary

Closes #1442

We want to add new props to the Image Component.

## Test Plan

Added the Test component. 
Manually test that in Android and IOS platforms on new and old
Architectures.

### What are the steps to reproduce (after prerequisites)?

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅     |
| Android |    ✅     |
2024-06-27 16:10:28 +02:00