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
This commit is contained in:
Mikael Sand
2018-08-19 15:48:40 +03:00
78 changed files with 1444 additions and 919 deletions

View File

@@ -1,19 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Image } from 'react-native';
import createReactNativeComponentClass from '../lib/createReactNativeComponentClass';
import {ImageAttributes} from '../lib/attributes';
import {numberProp, touchableProps, responderProps} from '../lib/props';
import Shape from './Shape';
//noinspection JSUnresolvedVariable
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
import {meetOrSliceTypes, alignEnum} from '../lib/extract/extractViewBox';
import extractProps from '../lib/extract/extractProps';
import React from "react";
import PropTypes from "prop-types";
import { Image, requireNativeComponent } from "react-native";
import ImageSourcePropType from 'react-native/Libraries/Image/ImageSourcePropType';
import { ImageAttributes } from "../lib/attributes";
import { numberProp, touchableProps, responderProps } from "../lib/props";
import Shape from "./Shape";
import { meetOrSliceTypes, alignEnum } from "../lib/extract/extractViewBox";
import extractProps from "../lib/extract/extractProps";
const spacesRegExp = /\s+/;
export default class extends Shape {
static displayName = 'Image';
static displayName = "Image";
static propTypes = {
...responderProps,
...touchableProps,
@@ -21,7 +19,7 @@ export default class extends Shape {
y: numberProp,
width: numberProp.isRequired,
height: numberProp.isRequired,
href: Image.propTypes.source,
href: ImageSourcePropType,
preserveAspectRatio: PropTypes.string
};
@@ -30,7 +28,7 @@ export default class extends Shape {
y: 0,
width: 0,
height: 0,
preserveAspectRatio: 'xMidYMid meet'
preserveAspectRatio: "xMidYMid meet"
};
setNativeProps = (...args) => {
@@ -38,26 +36,29 @@ export default class extends Shape {
};
render() {
let {props} = this;
let { props } = this;
let modes = props.preserveAspectRatio.trim().split(spacesRegExp);
let meetOrSlice = meetOrSliceTypes[modes[1]] || 0;
let align = alignEnum[modes[0]] || 'xMidYMid';
let align = alignEnum[modes[0]] || "xMidYMid";
return <RNSVGImage
ref={ele => {this.root = ele;}}
{...extractProps({...props, x: null, y: null}, this)}
x={props.x.toString()}
y={props.y.toString()}
imagewidth={props.width.toString()}
imageheight={props.height.toString()}
meetOrSlice={meetOrSlice}
align={align}
src={resolveAssetSource(props.href)}
/>;
return (
<RNSVGImage
ref={ele => {
this.root = ele;
}}
{...extractProps({ ...props, x: null, y: null }, this)}
x={props.x.toString()}
y={props.y.toString()}
imagewidth={props.width.toString()}
imageheight={props.height.toString()}
meetOrSlice={meetOrSlice}
align={align}
src={Image.resolveAssetSource(props.href)}
/>
);
}
}
const RNSVGImage = createReactNativeComponentClass('RNSVGImage', () => ({
validAttributes: ImageAttributes,
uiViewClassName: 'RNSVGImage'
}));
const RNSVGImage = requireNativeComponent("RNSVGImage", null, {
nativeOnly: ImageAttributes
});