649 Commits

Author SHA1 Message Date
Mikael Sand 3fd2523412 Fix #1017 2019-07-16 13:23:21 +03:00
Mikael Sand b9267fba3a Fix #1029 2019-07-16 13:23:21 +03:00
Mikael Sand 81f817eca3 Fix linting 2019-06-09 14:31:25 +03:00
Mikael Sand 7e8d7428f3 Fix gradle 2019-06-09 13:07:41 +03:00
SaeedZhiany d32b661e7b Merge branch 'master' into patch-1 2019-05-01 17:22:42 +04:30
Mikael Sand fde018b8aa [android] Clear path cache to fix fill rule when > 1 Use with same href 2019-04-01 20:02:48 +03:00
Mikael Sand 76b8b824e2 Implement support for Use element inside ClipPath
```jsx
import React from 'react';
import { View } from 'react-native';
import Svg, {
  Defs,
  ClipPath,
  Path,
  Rect,
  G,
  Text,
  Polygon,
  Use,
} from 'react-native-svg';

const SvgComponent = props => (
  <Svg width="100%" height="30%" viewBox="0 0 140 110" {...props}>
    <Defs>
      <Path
        id="prefix__a"
        d="M25 10a20 20 0 1 0 0 40 20 20 1 1 0 0-40m20 0a20 20 0 1 0 0 40 20 20 1 1 0 0-40"
      />
      <ClipPath id="prefix__b" clipRule="nonzero">
        <Use xlinkHref="#prefix__a" clipRule="nonzero" />
      </ClipPath>
      <ClipPath id="prefix__c" clipRule="evenodd">
        <Path
          id="prefix__a"
          y={50}
          d="M25 10a20 20 0 1 0 0 40 20 20 1 1 0 0-40m20 0a20 20 0 1 0 0 40 20 20 1 1 0 0-40"
        />
      </ClipPath>
      <ClipPath id="prefix__d" clipRule="evenodd">
        <Use xlinkHref="#prefix__a" clipRule="evenodd" y={50} />
      </ClipPath>
    </Defs>
    <Path clipPath="url(#prefix__b)" fill="#6495ed" d="M0 5h70v50H0z" />
    <Text x={15} y={54} fontSize={5} fill="#fff">
      {'non-zero clip-rule'}
    </Text>
    <Use xlinkHref="#prefix__a" x={70} stroke="#6495ed" />
    <Text x={86} y={54} fontSize={5} fill="#fff">
      {'non-zero fill-rule'}
    </Text>
    <G>
      <Path clipPath="url(#prefix__d)" fill="#daa520" d="M0 55h70v50H0z" />
      <Text x={14} y={105} fontSize={5} fill="#fff">
        {'even-odd clip-rule'}
      </Text>
    </G>
    <G>
      <Use
        fillRule="evenodd"
        xlinkHref="#prefix__a"
        x={70}
        y={50}
        stroke="#daa520"
      />
      <Text x={85} y={105} fontSize={5} fill="#fff">
        {'even-odd fill-rule'}
      </Text>
    </G>
  </Svg>
);

const SvgComponent2 = props => (
  <Svg height="90" width="100" viewBox="0 0 100 90">
    <Defs>
      <Path d="M50,0 21,90 98,35 2,35 79,90z" id="star" fill="white" />
      <ClipPath id="emptyStar" clipRule="evenodd">
        <Use href="#star" clipRule="evenodd" />
      </ClipPath>
      <ClipPath id="filledStar" clipRule="nonzero">
        <Use href="#star" clipRule="nonzero" />
      </ClipPath>
    </Defs>
    <Rect clipPath="url(#emptyStar)" width="50" height="90" fill="blue" />
    <Rect
      clipPath="url(#filledStar)"
      width="50"
      height="90"
      x="50"
      fill="red"
    />
  </Svg>
);

const SvgComponent3 = ({ clipRule = 'nonzero' }) => (
  <Svg width="50%" height="500">
    <Defs>
      <ClipPath id="windowClip" clipRule={clipRule}>
        <G>
          <Rect x={30} y={50} height={100} width={100} />
          <Text x={30} y={70} fontSize={40}>
            Hello world
          </Text>
          <Rect x={30} y={200} height={100} width={100} />
          <Rect x={100} y={250} height={100} width={100} />
          <Rect x={30} y={370} height={100} width={100} />
          <Polygon
            transform="translate(70,400)"
            points="0,0 0,100 100,120 120,0"
          />
        </G>
      </ClipPath>
    </Defs>
    <Rect height="100%" width="100%" fill="#0af" clipPath="url(#windowClip)" />
  </Svg>
);

export default class App extends React.Component {
  render() {
    return (
      <View
        style={{
          flex: 1,
          alignContent: 'center',
          justifyContent: 'center',
          backgroundColor: '#ecf0f1',
        }}
      >
        <SvgComponent />
        <SvgComponent2 />
        <View
          style={{
            flex: 1,
            flexDirection: 'row',
          }}
        >
          <SvgComponent3 />
          <SvgComponent3 clipRule="evenodd" />
        </View>
      </View>
    );
  }
}
```
2019-04-01 04:36:42 +03:00
Mikael Sand 9321aa504a [android] Fix clearing of cached glyph advance on add/remove children
#977
2019-03-22 21:47:59 +02:00
Mikael Sand 70ac80b297 Improved anchored text chunk logic #570 2019-03-21 18:21:40 +02:00
Mikael Sand eaec9b9988 [android] Fix calculation / clearing of cached glyph advance
#977
2019-03-21 02:49:36 +02:00
Mikael Sand 0e48d439f1 [android] Fix SVG.toDataURL exception #948 2019-03-18 20:45:26 +02:00
Mikael Sand 9a30e47ab9 Fix #961
### java compiler error
error: package com.facebook.infer.annotation does not exist
2019-03-11 04:37:52 +02:00
Mikael Sand 6bd27dfeba [bugfix] Fix calling toDataUrl early and with options
Enable calling toDataUrl as soon as you get a ref to the svg root.
Fix invalidation and rendering with options for width and height.
2019-03-11 02:43:06 +02:00
Mikael Sand ffb04c8414 [android] Implement vectorEffect nonScalingStroke / non-scaling-stroke 2019-02-27 21:16:20 +02:00
Mikael Sand 0a282f1073 Ignore non-array transforms, align transform handling with react-native 2019-02-27 21:10:27 +02:00
Mikael Sand 0b1f53698b [android] Make SvgView.drawChildren synchronized
Fix race-condition
https://github.com/react-native-community/react-native-svg/issues/948
Refactor toDataUrl
2019-02-27 21:09:50 +02:00
Mikael Sand fdd8f93dac [android] Make SvgView.drawChildren synchronized
Fix race-condition
https://github.com/react-native-community/react-native-svg/issues/948
2019-02-20 22:15:46 +02:00
Mikael Sand 9b1ccf0e7f Implement basic support for native animation of font size 2019-02-17 03:29:59 +02:00
Mikael Sand ccb8026462 [android] Fix text onPress handling, improve caching #941 2019-02-16 03:08:01 +02:00
Mikael Sand bc6f46c713 [android] Fix text onPress handling, #941 2019-02-15 23:19:26 +02:00
SaeedZhiany f0223ab881 Update build.gradle
Upgrade android gradle plugin to latest version
2019-02-13 08:26:34 +03:30
Mikael Sand b4c8985b81 Sync version used in build.gradle with react-native master
Add gradleBuildTools configuration to override gradle classpath
2019-02-11 15:34:10 +02:00
Mikael Sand 131ddb6a1a Implement version of toDataURL with width and height options
https://github.com/react-native-community/react-native-svg/issues/855
2019-02-10 03:42:18 +02:00
Mikael Sand e69d2320b2 Improve text subtree advance calculation caching 2019-02-10 02:52:15 +02:00
Mikael Sand d5fa136a0f Fix text-anchor subtree advance/extent calculation for letter-spacing
Related to
https://github.com/react-native-community/react-native-svg/issues/570
2019-02-10 01:47:46 +02:00
Mikael Sand 60a7b1fd53 [Android] Attempt to fix text-anchor subtree advance/extent calculation
Related to
https://github.com/react-native-community/react-native-svg/issues/600
https://github.com/react-native-community/react-native-svg/issues/570
2019-02-09 22:51:22 +02:00
Mikael Sand 61100e05b8 Merge branch 'ios-touch-CGPathContainsPoint-bug' 2019-02-09 04:01:50 +02:00
Mikael Sand 119e04eb4c Merge branch 'master' into patch-1 2019-02-09 03:56:51 +02:00
Mikael Sand abb17bc7f0 Fix re-rendering of emoji when path data is cached, closes #927 2019-02-08 03:19:21 +02:00
Mark Lord 727a2d0937 During a LayoutAnimation.spring animation it's possible for the SvgView to have negative layout dimensions when used with 100% width/height. Check for negative dimensions before calling Bitmap.createBitmap. 2019-02-06 11:06:11 +00:00
Caleb Chiesa 9a250c0608 Prevents early rendering.
Related to #921.
2019-02-04 11:53:01 -08:00
Mikael Sand 14791652ee [android] fix hit testing of nested svg and invalidation on changes. 2019-02-04 01:38:13 +02:00
Mikael Sand 0f0a43f842 [android] Fix rendering of images, matrix transform applied twice 2019-02-03 04:07:13 +02:00
Mikael Sand 9de1d186a3 [android] Fix double rendering of nested svg 2019-02-03 04:06:42 +02:00
Mikael Sand 1c518c9896 Allow int32ARGBColor and use it to represent colors instead of rgbaArray
int32ARGBColor is 0xaarrggbb format to allow no processing

Optimize default fill handling
Improve gradient input validation
Simplify gradient extraction
Use a single array to represent gradient, with two numbers per stop
Reuse transform props in extractProps, short circuit identity transform.

[android] Refactor ImageView, fix mLoading
2019-02-02 02:20:26 +02:00
Mikael Sand e90f5423fa [android] Fix handling of strokeDasharray 2019-01-28 16:15:06 +02:00
Mikael Sand 599f8d1e9f [android] Fix handling of missing width and height when using flex 2019-01-26 17:29:27 +02:00
Mikael Sand 5551ff2bfa Fix #840
Implement support for patternUnits="objectBoundingBox"
 seems to work well on both platforms
Implement support for patternContentUnits="objectBoundingBox"
 Android has issues with small paths
2019-01-25 04:23:33 +02:00
Mikael Sand 76fb495920 Fix #844
Handle svg root width/height attribute strings containing px on iOS
Inherit fill/stroke attributes from Mask elements
Set default bounding box of mask to fill viewport / allow missing x, y, width, height on mask element
2019-01-24 20:27:45 +02:00
Mikael Sand 2a5dcdcd85 Fix crash on missing viewBox attribute on Pattern element 2019-01-24 05:10:40 +02:00
Mikael Sand b3d29c9045 Remove string conversion of svg bounds, allow style arrays more widely 2019-01-24 02:44:28 +02:00
Mikael Sand 2c04da063b [android] Fix dynamically loaded font compatibility
Fixes #905
Adds support for react-native-dynamic-fonts
2019-01-23 15:16:06 +02:00
Mikael Sand 3dc6b80953 [android] Fix Use element spec conformance (x and y interpretation) 2019-01-14 15:44:00 +02:00
Mikael Sand 030bc6c2dc [android] Limit early exit shortcut to RenderableView 2019-01-08 04:24:10 +02:00
Mikael Sand 9a32d2255e [android] Implement cache invalidation early exit shortcut 2019-01-08 04:06:48 +02:00
Mikael Sand 30cbc31c67 [android] Fix cache invalidation 2019-01-08 02:12:40 +02:00
Mikael Sand eb4e314681 [android] Cache group paths. 2019-01-06 21:10:45 +02:00
Mikael Sand b559e73dbc [android] Cache text groups. Refactor Svg root group structure. 2019-01-06 20:02:14 +02:00
Mikael Sand c370f228c3 (android) Fix numeric font size handling. 2019-01-06 17:56:03 +02:00
Mikael Sand 3286005cb9 [android] Add null check after getting referenced mask, closes #871 2018-12-11 21:18:45 +02:00