UNPKG

1.2 kBTypeScriptView Raw
1import React, { ReactElement } from 'react';
2import { requireNativeComponent } from 'react-native';
3import extractGradient from '../lib/extract/extractGradient';
4import { NumberProp, TransformProps } from '../lib/extract/types';
5import Shape from './Shape';
6
7export default class RadialGradient extends Shape<{
8 fx?: NumberProp;
9 fy?: NumberProp;
10 rx?: NumberProp;
11 ry?: NumberProp;
12 r?: NumberProp;
13 cx?: NumberProp;
14 cy?: NumberProp;
15 id?: string;
16 children?: ReactElement[];
17 transform?: number[] | string | TransformProps;
18 gradientTransform?: number[] | string | TransformProps;
19 gradientUnits?: 'objectBoundingBox' | 'userSpaceOnUse';
20}> {
21 static displayName = 'RadialGradient';
22
23 static defaultProps = {
24 cx: '50%',
25 cy: '50%',
26 r: '50%',
27 };
28
29 render() {
30 const { props } = this;
31 const { rx, ry, r, cx, cy, fx = cx, fy = cy } = props;
32 return (
33 <RNSVGRadialGradient
34 ref={this.refMethod}
35 fx={fx}
36 fy={fy}
37 rx={rx || r}
38 ry={ry || r}
39 cx={cx}
40 cy={cy}
41 {...extractGradient(props, this)}
42 />
43 );
44 }
45}
46
47export const RNSVGRadialGradient = requireNativeComponent(
48 'RNSVGRadialGradient',
49);