import { useEffect, useRef } from 'react'; import { Animated, Easing, View, type StyleProp, type ViewStyle } from 'react-native'; import Svg, { Circle } from 'react-native-svg'; import { useTheme } from '../../hooks/useTheme'; import { SpinnerSize } from '../../utils/ThemeUtil'; import type { ColorType, SizeType } from '../../utils/TypesUtil'; import styles from './styles'; const AnimatedSvg = Animated.createAnimatedComponent(Svg); export interface LoadingSpinnerProps { size?: Exclude; color?: Exclude; style?: StyleProp; } export function LoadingSpinner({ color, style, size = 'lg' }: LoadingSpinnerProps) { const Theme = useTheme(); const spinValue = useRef(new Animated.Value(0)); const stroke = color ? Theme[color] : Theme['accent-100']; useEffect(() => { const animation = Animated.timing(spinValue.current, { toValue: 1, duration: 800, useNativeDriver: true, easing: Easing.linear }); const loop = Animated.loop(animation); loop.start(); return () => { loop.stop(); }; }, [spinValue]); const spin = spinValue.current.interpolate({ inputRange: [0, 1], outputRange: ['0deg', '360deg'] }); return ( ); }