import { useEffect, useRef } from 'react'; import { Animated, Easing, StyleSheet, View } from 'react-native'; import Svg, { Rect } from 'react-native-svg'; import useTheme from '../hooks/useTheme'; const AnimatedRect = Animated.createAnimatedComponent(Rect); interface Props { children?: React.ReactNode; imageSize?: number; showError?: boolean; } function WalletLoadingThumbnail({ children, showError }: Props) { const Theme = useTheme(); const spinValue = useRef(new Animated.Value(0)); useEffect(() => { const animation = Animated.timing(spinValue.current, { toValue: 1, duration: 1150, 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: [0, -371], }); return ( {showError && ( )} {children} ); } const styles = StyleSheet.create({ container: { alignItems: 'center', justifyContent: 'center', }, loader: { position: 'absolute', }, error: { position: 'absolute', borderWidth: 2, height: 106, width: 106, borderRadius: 31, }, }); export default WalletLoadingThumbnail;