import React from 'react'; import { Animated, View } from 'react-native'; import Svg, { Defs, LinearGradient as SVGLinearGradient, Rect, Stop, } from 'react-native-svg'; import { getColorList, getAnglePercentageObject, getGradientFromName, } from '../../utils'; import type { CoOrdinateProp, ColorListProp, GradientDataProp, } from '../../utils'; import type { LinearGradientProps } from './LinearGradientTypes'; import { SpinnerButtonStyle } from '../../styles'; const AnimatedRect: Animated.AnimatedComponent = Animated.createAnimatedComponent(Rect); const LinearGradient: React.FC = ({ animatedStyles, children, angle, gradientRadialRadius, gradientColoroffset = [], gradientColors = [], gradientButtonHeight, gradientName, }: LinearGradientProps) => { const rectWidth: Animated.AnimatedInterpolation = animatedStyles.width; const gradientData: GradientDataProp | null = gradientName ? getGradientFromName(gradientName) : null; const angleObj: CoOrdinateProp = typeof gradientData?.angle === 'number' ? getAnglePercentageObject(gradientData?.angle) : typeof angle === 'number' ? getAnglePercentageObject(angle) : { x1: 0, x2: 0, y1: 0, y2: 0, }; const colorList: ColorListProp[] = getColorList( gradientData?.offset || gradientColoroffset, gradientData?.colors || gradientColors ); return ( {colorList.map((value, index) => ( ))} {children ? children : <>} ); }; export default LinearGradient;