2015-04-14 05:10:00 +00:00
|
|
|
/**
|
|
|
|
* @providesModule LinearGradient
|
|
|
|
* @flow
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
2016-05-05 10:12:40 +00:00
|
|
|
import React, { PropTypes } from 'react';
|
|
|
|
import { processColor, requireNativeComponent, View } from 'react-native';
|
2015-09-29 16:43:22 +00:00
|
|
|
|
|
|
|
var LinearGradient = React.createClass({
|
2015-12-07 18:15:01 +00:00
|
|
|
propTypes: {
|
2016-01-27 13:38:15 +00:00
|
|
|
start: PropTypes.arrayOf(PropTypes.number),
|
|
|
|
end: PropTypes.arrayOf(PropTypes.number),
|
|
|
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
|
|
locations: PropTypes.arrayOf(PropTypes.number),
|
2015-12-07 18:15:01 +00:00
|
|
|
...View.propTypes,
|
|
|
|
},
|
|
|
|
|
2015-09-29 16:43:22 +00:00
|
|
|
render: function() {
|
2016-05-25 09:56:09 +00:00
|
|
|
var { 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');
|
|
|
|
}
|
|
|
|
|
2015-09-29 16:43:22 +00:00
|
|
|
return (
|
2016-05-25 09:56:09 +00:00
|
|
|
<NativeLinearGradient
|
|
|
|
{...otherProps}
|
|
|
|
colors={colors.map(processColor)}
|
|
|
|
locations={locations ? locations.slice(0, colors.length) : null}
|
|
|
|
/>
|
2015-09-29 16:43:22 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2015-03-31 17:44:16 +00:00
|
|
|
|
2016-01-27 13:38:15 +00:00
|
|
|
var NativeLinearGradient = requireNativeComponent('BVLinearGradient', null);
|
|
|
|
|
2015-03-31 17:44:16 +00:00
|
|
|
module.exports = LinearGradient;
|