Commit Graph

338 Commits

Author SHA1 Message Date
Mikael Sand
fc63635f3c Implement basic support for Pattern element 2018-09-02 16:06:44 +03:00
Mikael Sand
7bb1e748b7 [android] Fix clipping path on Android < Kitkat (API 19) 2018-09-01 16:41:03 +03:00
Mikael Sand
a1097b8594 Fix spec conformance of clipping path with multiple child elements.
https://www.w3.org/TR/SVG11/masking.html#EstablishingANewClippingPath

The raw geometry of each child element exclusive of rendering properties such as ‘fill’, ‘stroke’, ‘stroke-width’ within a ‘clipPath’ conceptually defines a 1-bit mask (with the possible exception of anti-aliasing along the edge of the geometry) which represents the silhouette of the graphics associated with that element. Anything outside the outline of the object is masked out. If a child element is made invisible by ‘display’ or ‘visibility’ it does not contribute to the clipping path. When the ‘clipPath’ element contains multiple child elements, the silhouettes of the child elements are logically OR'd together to create a single silhouette which is then used to restrict the region onto which paint can be applied. Thus, a point is inside the clipping path if it is inside any of the children of the ‘clipPath’.

For a given graphics element, the actual clipping path used will be the intersection of the clipping path specified by its ‘clip-path’ property (if any) with any clipping paths on its ancestors, as specified by the ‘clip-path’ property on the ancestor elements, or by the ‘overflow’ property on ancestor elements which establish a new viewport. Also, see the discussion of the initial clipping path.)

Fixes issues highlighted by https://github.com/react-native-community/react-native-svg/issues/752
Fix https://github.com/react-native-community/react-native-svg/issues/280
Fix https://github.com/react-native-community/react-native-svg/issues/517

[android] Fix https://github.com/react-native-community/react-native-svg/issues/766
`Region.Op.REPLACE` is deprecated in API level 28
Replace with clipPath (Path path) to Intersect instead.
2018-09-01 02:55:36 +03:00
Mikael Sand
8e0420fc2d [android] Fix caching of text 2018-08-25 01:06:45 +03:00
Mikael Sand
ce602c1d62 Fix dynamic null handling 2018-08-22 15:29:28 +03:00
Mikael Sand
41134b8636 Improve width and height calculation 2018-08-19 21:49:49 +03:00
Mikael Sand
e98b0fe1d1 Merge branch 'master' into NativeAnimation
# Conflicts:
#	android/src/main/java/com/horcrux/svg/RenderableShadowNode.java
#	android/src/main/java/com/horcrux/svg/SvgViewShadowNode.java
#	elements/Image.js
#	elements/Rect.js
#	elements/Use.js
#	lib/attributes.js
2018-08-19 15:48:40 +03:00
Mikael Sand
211afecf3a Fix null exception. 2018-08-19 15:26:59 +03:00
Mikael Sand
34d4051aa9 Fix early predicate. 2018-08-18 15:04:58 +03:00
Mikael Sand
3879c90bd8 Support native animation of fill and stroke 2018-08-17 22:09:47 +03:00
Hexer
e7a7937bc8 fix NullPointerException 2018-08-03 11:36:51 +08:00
colorfulberry
62a72e12ac Update build.gradle
compile should instead implemention
2018-07-27 17:21:30 +08:00
Mikael Sand
890d4d9d45 Merge remote-tracking branch 'yeomann/patch-1' 2018-07-26 23:53:26 +03:00
Mikael Sand
f969b9ebe9 Merge remote-tracking branch 'philoinc/master' 2018-07-26 23:53:06 +03:00
Mikael Sand
d3bd2e3d9f Merge remote-tracking branch 'rghorbani/master' 2018-07-26 23:52:23 +03:00
Danish
22bdfa930e Update obsolete compile to implemenation
Hi, as React native 0.56.0 is released with MAJOR android changes such as:

-Gradle 3.5.1
-Compile using Android SDK 26
-Google Maven repo
-etc

more about Change log, specially of Android Here, https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md#android-projects-are-now-compiled-using-the-android-26-sdk
and https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md#android-specific-changes

Aslo as Per Google new "Google Play's target API level requirement", mentioned here  https://developer.android.com/distribute/best-practices/develop/target-sdk

"Google Play will require that new apps target at least Android 8.0 (API level 26) from August 1, 2018, and that app updates target Android 8.0 from November 1, 2018."

It's clear that Android would be moving to new Gradle and new SDK changes, Thus creating a new type of error that is:

"Configuration 'compile' is obsolete and has been replaced with 'implementation' or 'Api'" 

more about the Old and new configuration please see this https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration?utm_source=android-studio#new_configurations 
at the heading of "Use the new dependency configurations"

Therefore, all old "compile" should be now "implementation" or "provided" should be "compileOnly"

I have tested the with "compile" and "implementation" in my current release ready product and also by "renaming" "compile" to "implementation".
Also tested with higher andorid SDK configs such as of below:

```
ext {
    buildToolsVersion = "27.0.3"
    minSdkVersion = 19
    compileSdkVersion = 27
    targetSdkVersion = 27
    supportLibVersion = "27.1.1"
}
```

so SDK 27 was also compiled successully. test on Android phone with ADK 23 all looks good. Thus, `react-native-svg` was working just fine as intended. thank you so much for this package btw. Love this package so much :)

Therefore, Please would it be possible to merge as i am sure many new projects and old one are going to update specially Gradle and SDK as of Google new requirements. 

related mention of Upgrading issue mention here https://github.com/facebook/react-native/issues/20273#issuecomment-405959030


Moreover, if someone still have any issue after upgrading everything successfully, then he should use following in build.gradle under `andorid/build.gradle`

```

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 27
                buildToolsVersion '27.0.3'
                supportLibVersion = "27.1.1"
            }
        }
    }
}
```
2018-07-19 20:28:05 +03:00
Seth Madison
149259de64 Fix memory leak: remove references to SvgViews in onDetachedFromWindow
It looks like onDropViewInstance does not get called when the entire react
instance is shut down from the native side. To gaurantee that we do not
leak memory, we need to remove the reference to the view in onDetachedFromWindow().
2018-07-18 16:06:36 -07:00
Reza
89ae631c95 upgrade SDK Build Tools 2018-07-06 01:10:42 +04:30
ExoMemphiz
5a5fff8b2a Fixed NullPointerException 2018-07-04 13:37:57 +02:00
Mikael Sand
d982130316 [android] fix text hit test 2018-07-02 06:00:22 +03:00
Mikael Sand
a454fe3490 [android] fix inherited attributes 2018-07-02 05:26:39 +03:00
Mikael Sand
2fa029035c [android] fix rendering of nested svg 2018-07-02 05:25:20 +03:00
Mikael Sand
b395697853 Merge pull request #716 from isnotgood/master
[android] Handle gracefully gradients with only one stop
2018-07-02 05:20:11 +03:00
Lukas Weber
b1462e08f5 [android] Handle gracefully gradients with only one stop
Handles erroneous gradient which contains only one stop or two
stops at the same place, but merged into one stop by extractGradient().
2018-06-14 14:54:30 +02:00
Maksym Komarychev
9e73ffe0f0 [android] initial CTM is identity 2018-06-10 11:39:07 +03:00
Maksym Komarychev
ba7bef6ce8 [android] fire onLayout 2018-06-09 00:20:27 +03:00
Mikael Sand
f28a343a8d Merge remote-tracking branch 'EmentoDev/master' 2018-06-08 01:16:29 +03:00
Mikael Sand
01452d7354 Merge remote-tracking branch 'max/touches-group-use' 2018-06-07 21:20:35 +03:00
Mikael Sand
3866c64092 Merge remote-tracking branch 'Crash--/patch-1' 2018-06-07 20:42:10 +03:00
davidpricedev
15dd172e58 Fixes android arc 2018-06-04 12:29:14 -05:00
Rasmus Fredensborg Jensen
c16a9ed4c0 Removing check for cachedClipPath when getting clipPath in VirtualNode, as it hinders image clip path update, when animating the clip path itself 2018-06-01 10:15:04 +02:00
Quentin Valmori
6a63989f73 drawOutput() only when Layout is != 0 2018-04-30 12:25:47 +02:00
Maksym Komarychev
3440d72277 [android] hitTest for Use 2018-04-14 19:38:11 +03:00
Mikael Sand
13fcdf6f15 Merge remote-tracking branch 'msand/NestedSvg' into merge-test
# Conflicts:
#	ios/Elements/RNSVGGroup.m
#	ios/RNSVGNode.h
#	ios/RNSVGNode.m
2018-03-19 00:27:01 +02:00
Mikael Sand
40a17c838d Merge remote-tracking branch 'uxbert/5.5.1-load-image-from-url' into fix-display-none
# Conflicts:
#	android/src/main/java/com/horcrux/svg/ImageShadowNode.java
#	ios/Elements/RNSVGImage.m
2018-03-18 23:14:29 +02:00
Mikael Sand
0eb501d5e8 Alternative approach without TextureView. 2018-03-18 22:39:44 +02:00
Mikael Sand
7deabf8287 Add RenderableView, fix names. Allow percentages in nested SVG (iOS). 2018-03-17 23:22:40 +02:00
Bilal Syed
77ebefb650 Load Image from URL 2018-03-15 19:00:58 +03:00
Mikael Sand
a3c9aa2872 Add remaining properties to view managers. 2018-03-04 22:00:48 +02:00
Mikael Sand
3a59dfbba9 Simplify shadow node lookup and drawing after update transaction. 2018-03-04 20:52:10 +02:00
Mikael Sand
fbd6591251 Experiment to allow animating fillOpacity of Rect using native driver.
import React, { Component } from 'react';
import { StyleSheet, View, Dimensions, Animated } from 'react-native';
import { Svg, Rect } from 'react-native-svg';

const { width, height } = Dimensions.get('window');
const AnimatedRect = Animated.createAnimatedComponent(Rect);

export default class App extends Component {
  state = {
    anim: new Animated.Value(0),
  };

  componentDidMount() {
    Animated.timing(this.state.anim, {
      toValue: 1,
      duration: 3000,
      useNativeDriver: true,
    }).start();
  }

  render() {
    const { anim } = this.state;
    return (
      <View style={styles.container}>
        <Svg width={width} height={height} viewBox="0 0 100 100">
          <AnimatedRect
            x="5"
            y="5"
            width="90"
            height="90"
            fill="green"
            fillOpacity={anim}
          />
        </Svg>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    backgroundColor: '#ecf0f1',
  },
});
2018-02-24 23:45:42 +02:00
Mikael Sand
f3ea54cd26 Use TextureView instead of Bitmap in SvgView on Android
Mirror ReactNativeART https://github.com/facebook/react-native/pull/9486
2018-02-23 14:43:02 +02:00
Mikael Sand
47fe6beedf Organize import, fix stale width and height cache. 2018-02-23 01:00:00 +02:00
Mikael Sand
14c3b4f867 Lazily construct hitTest Region on demand. 2018-02-23 00:49:14 +02:00
Mikael Sand
cd43fc151e Optimize hit testing. 2018-02-23 00:19:10 +02:00
Mikael Sand
149f460108 Improve path caching on android 2018-02-22 02:24:11 +02:00
Mikael Sand
aed804776a Fix linting 2018-02-21 20:58:12 +02:00
Mikael Sand
f7b195a5a0 Allow nesting React-Native View components inside svg (Android, poc wip) 2018-02-21 16:50:04 +02:00
Mikael Sand
ee1d1f78cc First attempt at nested svg support. 2018-02-21 12:17:12 +02:00
Mikael Sand
31c137ca40 Commit missing files. 2018-02-03 23:22:21 +02:00