2015-04-13 22:10:00 -07:00
|
|
|
/**
|
|
|
|
* @providesModule LinearGradient
|
|
|
|
* @flow
|
|
|
|
*/
|
2016-06-13 13:22:34 +02:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
2016-05-05 13:12:40 +03:00
|
|
|
import { processColor, requireNativeComponent, View } from 'react-native';
|
2015-09-29 12:43:22 -04:00
|
|
|
|
2016-06-13 13:22:34 +02:00
|
|
|
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,
|
|
|
|
};
|
2016-06-12 16:21:55 -04:00
|
|
|
|
2016-06-13 13:22:34 +02:00
|
|
|
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');
|
|
|
|
}
|
2016-05-25 12:56:09 +03:00
|
|
|
|
2016-06-13 13:22:34 +02:00
|
|
|
return (
|
|
|
|
<NativeLinearGradient
|
|
|
|
{...otherProps}
|
|
|
|
colors={colors.map(processColor)}
|
|
|
|
locations={locations ? locations.slice(0, colors.length) : null}
|
|
|
|
/>
|
|
|
|
);
|
2015-09-29 12:43:22 -04:00
|
|
|
}
|
2016-06-06 17:38:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const NativeLinearGradient = requireNativeComponent('BVLinearGradient', null);
|