Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import React, {Component} from 'react';
import {PropTypes} from 'prop-types';
import {Animated, Easing} from 'react-native';
import _ from 'lodash';
import NativeLinearGradient from 'react-native-linear-gradient';
class LinearGradient extends Component {
static propTypes = {
...NativeLinearGradient.propTypes,
};
// Generate back the colors array with all transformed props
_generateColorsArray(props) {
const propsKeys = Object.keys(props);
const colorsArray = [];
propsKeys.forEach(key => {
if (
key.indexOf('animatedColor') !== -1 &&
props[key] &&
typeof props[key] === 'string'
) {
colorsArray.push(props[key]);
}
});
const colorsArray = this._generateColorsArray(props);
const nativeLinearProps = _.omit(props, Object.keys(colorsArray));
return (
{children}
);
}
}
Animated.LinearGradient = Animated.createAnimatedComponent(LinearGradient);
class AnimatedGradientTransition extends Component {
static propTypes = {
...NativeLinearGradient.propTypes,
animation: PropTypes.shape({
toValue: PropTypes.number,
duration: PropTypes.number,
easing: PropTypes.func,
}),
};
static defaultProps = {
animation: {
toValue: 1,
duration: 500,
easing: Easing.linear,
},
};
constructor(props) {
if (animatable && params.animatedValue) {
top = params.animatedValue.interpolate({
inputRange: [0, 1000],
outputRange: [yOffset, -1000],
});
}
return (
);
}
}
Circle.propTypes = {
style: LinearGradient.propTypes.style,
animatable: PropTypes.bool,
navigation: PropTypes.shape(),
};
Circle.defaultProps = {
style: {},
animatable: false,
navigation: null,
};
export default withNavigation(Circle);