mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-06 00:12:21 +00:00
complete basic shapes(ios)
This commit is contained in:
+20
-18
@@ -2,30 +2,32 @@ import React, {
|
||||
Component,
|
||||
PropTypes
|
||||
} from 'react-native';
|
||||
import Path from './Path';
|
||||
import Shape, {LINE} from './Shape';
|
||||
import {lineProps, pathProps} from '../lib/props';
|
||||
|
||||
let propType = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
||||
|
||||
class Line extends Component{
|
||||
class Line extends Shape{
|
||||
static displayName = 'Line';
|
||||
static propTypes = {
|
||||
x1: propType,
|
||||
x2: propType,
|
||||
y1: propType,
|
||||
y2: propType,
|
||||
strokeLinecap: PropTypes.oneOf(['butt', 'square', 'round'])
|
||||
...pathProps,
|
||||
...lineProps
|
||||
};
|
||||
|
||||
static getPath = (props) => (
|
||||
`M${props.x1},${props.y1} L${props.x2},${props.y2}`
|
||||
);
|
||||
static defaultProps = {
|
||||
x1: 0,
|
||||
x2: 0,
|
||||
y1: 0,
|
||||
y2: 0
|
||||
};
|
||||
|
||||
render() {
|
||||
return <Path
|
||||
{...this.props}
|
||||
d={Line.getPath(this.props)}
|
||||
/>;
|
||||
}
|
||||
static contextTypes = {
|
||||
...lineProps,
|
||||
isInGroup: PropTypes.bool
|
||||
};
|
||||
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.type = LINE;
|
||||
};
|
||||
}
|
||||
|
||||
export default Line;
|
||||
|
||||
Reference in New Issue
Block a user