Merge pull request #298 from react-native-community/5.1.7

5.1.7
This commit is contained in:
Horcrux
2017-04-04 12:48:30 +08:00
committed by GitHub
8 changed files with 20 additions and 27 deletions
@@ -89,9 +89,8 @@ public class ImageShadowNode extends RenderableShadowNode {
if (src.hasKey("width") && src.hasKey("height")) {
mImageRatio = (float)src.getInt("width") / (float)src.getInt("height");
}
else {
mImageRatio = (float)0.0;
} else {
mImageRatio = 0f;
}
mUri = Uri.parse(uriString);
}
@@ -173,7 +172,7 @@ public class ImageShadowNode extends RenderableShadowNode {
float rectRatio = rectWidth / rectHeight;
RectF renderRect;
if (mImageRatio == 0.0 || mImageRatio == rectRatio) {
if (mImageRatio == 0f || mImageRatio == rectRatio) {
renderRect = new RectF(rect);
} else if (mImageRatio < rectRatio) {
renderRect = new RectF(0, 0, (int)(rectHeight * mImageRatio), (int)rectHeight);
+2 -12
View File
@@ -1,4 +1,5 @@
import React, {PropTypes} from 'react';
import { Image } from 'react-native';
import createReactNativeComponentClass from 'react-native/Libraries/Renderer/src/renderers/native/createReactNativeComponentClass';
import {ImageAttributes} from '../lib/attributes';
import {numberProp, touchableProps, responderProps} from '../lib/props';
@@ -18,18 +19,7 @@ export default class extends Shape {
y: numberProp,
width: numberProp.isRequired,
height: numberProp.isRequired,
href: PropTypes.oneOfType([
PropTypes.number,
function(props, propName, componentName) {
if (Object.keys(props[propName]).length != 1 ||
!/^\s*data:([a-z]+\/[a-z]+(;[a-z\-]+\=[a-z\-]+)?)?(;base64)?,[a-z0-9\!\$\&\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i.test(props[propName].uri)) {
return new Error(
'Invalid prop `' + propName + '` supplied to' +
' `' + componentName + '`. Validation failed.'
);
}
}
]).isRequired,
href: Image.propTypes.source,
preserveAspectRatio: PropTypes.string
};
+2 -1
View File
@@ -1,6 +1,7 @@
import React, {Component, PropTypes} from 'react';
import Path from './Path';
import {pathProps} from '../lib/props';
import extractPolyPoints from '../lib/extract/extractPolyPoints';
export default class extends Component{
static displayName = 'Polygon';
@@ -26,7 +27,7 @@ export default class extends Component{
return <Path
ref={ele => {this.root = ele;}}
{...this.props}
d={`M${points.trim().replace(/\s+/g, 'L')}z`}
d={`M${extractPolyPoints(points)}z`}
/>;
}
}
+2 -1
View File
@@ -1,6 +1,7 @@
import React, {Component, PropTypes} from 'react';
import Path from './Path';
import {pathProps} from '../lib/props';
import extractPolyPoints from '../lib/extract/extractPolyPoints';
export default class extends Component{
static displayName = 'Polyline';
@@ -26,7 +27,7 @@ export default class extends Component{
return <Path
ref={ele => {this.root = ele;}}
{...this.props}
d={`M${points.trim().replace(/\s+/g, 'L')}`}
d={`M${extractPolyPoints(points)}`}
/>;
}
}
+5 -7
View File
@@ -26,14 +26,12 @@
_src = src;
CGImageRelease(_image);
RCTImageSource *source = [RCTConvert RCTImageSource:src];
if (source.size.width != 0 && source.size.height != 0)
{
if (source.size.width != 0 && source.size.height != 0) {
_imageRatio = source.size.width / source.size.height;
} else {
_imageRatio = 0.0;
}
else
{
_imageRatio = 0.0
}
_image = CGImageRetain([RCTConvert CGImage:src]);
[self invalidate];
}
@@ -118,7 +116,7 @@
CGFloat rectRatio = rectWidth / rectHeight;
CGRect renderRect;
if (imageRatio == 0.0 || imageRatio == rectRatio) {
if (!imageRatio || imageRatio == rectRatio) {
renderRect = rect;
} else if (imageRatio < rectRatio) {
renderRect = CGRectMake(0, 0, rectHeight * imageRatio, rectHeight);
+4
View File
@@ -0,0 +1,4 @@
export default function (polyPoints) {
return polyPoints.replace(/-/, ' -').split(/(?:\s+|\s*,\s*)/g).join(' ');
}
+1 -1
View File
@@ -105,7 +105,7 @@ export default function(props, container) {
content = childrenString;
children = null;
}
} else if (Children.count(children) > 1) {
} else if (Children.count(children) > 1 || Array.isArray(children)) {
children = Children.map(children, child => {
if (typeof child === 'string' || typeof child === 'number') {
return <TSpan>{child.toString()}</TSpan>;
+1 -1
View File
@@ -1,5 +1,5 @@
{
"version": "5.1.6",
"version": "5.1.7",
"name": "react-native-svg",
"description": "SVG library for react-native",
"repository": {