UNPKG

react-native-svg

Version:
41 lines (35 loc) 1.2 kB
import React, {PropTypes, Component} from 'react'; import {numberProp} from '../lib/props'; import extractGradient from '../lib/extract/extractGradient'; import createReactNativeComponentClass from 'react-native/Libraries/Renderer/src/renderers/native/createReactNativeComponentClass'; import {LinearGradientAttributes} from '../lib/attributes'; export default class extends Component{ static displayName = 'LinearGradient'; static propTypes = { x1: numberProp.isRequired, x2: numberProp.isRequired, y1: numberProp.isRequired, y2: numberProp.isRequired, id: PropTypes.string.isRequired }; static defaultProps = { x1: '0%', y1: '0%', x2: '100%', y2: '0%' }; render() { let {props} = this; return <RNSVGLinearGradient x1={props.x1.toString()} y1={props.y1.toString()} x2={props.x2.toString()} y2={props.y2.toString()} {...extractGradient(this.props)} />; } } const RNSVGLinearGradient = createReactNativeComponentClass({ validAttributes: LinearGradientAttributes, uiViewClassName: 'RNSVGLinearGradient' });