-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
44 lines (37 loc) · 903 Bytes
/
index.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
import React from 'react';
import ReactNative from 'react-native';
const {
requireNativeComponent,
processColor,
Platform,
View,
} = ReactNative;
let RNOpacityGradient = null;
if (Platform.OS === 'ios') {
RNOpacityGradient = requireNativeComponent('RNOpacityGradient',null);
}
export default function OpacityGradientView(props) {
const { colors, locations, start, end, ...other } = props;
let content;
if (RNOpacityGradient) {
content = (
<RNOpacityGradient
{...other}
colors={colors.map(processColor)}
locations={locations}
startPoint={convertPoint(start)}
endPoint={convertPoint(end)}
/>
);
} else {
content = <View {...other} />;
}
return content;
}
function convertPoint(point) {
let ret;
if (point && point.x !== undefined && point.y !== undefined) {
ret = [point.x, point.y];
}
return ret;
}