-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.windows.js
51 lines (45 loc) · 1.35 KB
/
index.windows.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* @providesModule LinearGradient
* @flow
*/
import React, { Component, PropTypes } from 'react';
import { processColor, requireNativeComponent, View } from 'react-native';
type PropsType = {
start?: Array<number>;
end?: Array<number>;
colors: Array<string>;
locations?: Array<number>;
} & typeof(View);
export default class LinearGradient extends Component {
static propTypes = {
start: PropTypes.arrayOf(PropTypes.number),
end: PropTypes.arrayOf(PropTypes.number),
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
locations: PropTypes.arrayOf(PropTypes.number),
...View.propTypes,
};
props: PropsType;
gradientRef: any;
setNativeProps(props: PropsType) {
this.gradientRef.setNativeProps(props);
}
render() {
const {
colors,
locations,
...otherProps
} = this.props;
if ((colors && locations) && (colors.length !== locations.length)) {
console.warn('LinearGradient colors and locations props should be arrays of the same length');
}
return (
<NativeLinearGradient
ref={(component) => { this.gradientRef = component; }}
{...otherProps}
colors={colors.map(processColor)}
locations={locations ? locations.slice(0, colors.length) : null}
/>
);
}
}
const NativeLinearGradient = requireNativeComponent('BVLinearGradient', null);