import * as React from 'react'; import Animated, { AnimatedProps } from 'react-native-reanimated'; import { Defs, LinearGradient, Stop, Path, PathProps } from 'react-native-svg'; import { LineChartDimensionsContext } from './Chart'; import { LineChartPathContext } from './LineChartPathContext'; import useAnimatedPath from './useAnimatedPath'; const AnimatedPath = Animated.createAnimatedComponent(Path); export type LineChartGradientProps = AnimatedProps & { color?: string; children?: React.ReactNode; }; let id = 0; LineChartGradient.displayName = 'LineChartGradient'; export function LineChartGradient({ color: overrideColor = undefined, children, ...props }: LineChartGradientProps) { const { area } = React.useContext(LineChartDimensionsContext); const { color: contextColor, isTransitionEnabled } = React.useContext(LineChartPathContext); const color = overrideColor || contextColor; //////////////////////////////////////////////// const { animatedProps } = useAnimatedPath({ enabled: isTransitionEnabled, path: area, }); //////////////////////////////////////////////// const localId = React.useRef(++id); //////////////////////////////////////////////// return ( <> {children ? ( {/*@ts-ignore*/} {children} ) : ( )} ); }