-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.windows.js
70 lines (66 loc) · 1.79 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* @providesModule LinearGradient
* @flow
*/
import React, { Component } from 'react';
import { processColor, View } from 'react-native';
import NativeLinearGradient,{ type Props } from './common';
const convertPoint = (name, point) => {
if (Array.isArray(point)) {
console.warn(
`LinearGradient '${name}' property should be an object with fields 'x' and 'y', ` +
'Array type is deprecated.'
);
}
// TODO: Update Android native code to receive a {x, y} object, not an array
console.log("point.x======>"+point.x);
console.log("point.y======>"+point.y);
return {
x: point[0],
y: point[1]
};
return point;
};
// TODO: Update Windows native code + update Props to share the same API with iOS/android
// type Props = {
// start?: number[];
// end?: number[];
// colors: string[];
// locations?: number[];
// } & typeof(View);
export default class LinearGradient extends Component<Props> {
props: Props;
gradientRef: any;
static defaultProps = {
start: { x: 0.5, y: 0.0 },
end: { x: 0.5, y: 1.0 },
};
setNativeProps(props: Props) {
this.gradientRef.setNativeProps(props);
}
render() {
const {
colors,
locations,
start,
end,
useAngle,
angleCenter,
angle,
...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}
startPoint={start}
endPoint={ end}
colors={colors.map(processColor)}
locations={locations ? locations.slice(0, colors.length) : null}
/>
);
}
}