import React, { useEffect } from 'react'; import { StyleProp, StyleSheet, ViewStyle } from 'react-native'; import Animated, { Easing, useAnimatedStyle, useSharedValue, withRepeat, withTiming, } from 'react-native-reanimated'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; import { Loading } from '../../icons/loading'; export type SpinnerProps = { height?: number; style?: StyleProp; width?: number; }; export const Spinner = (props: SpinnerProps) => { const rotation = useSharedValue(0); const { height, style, width } = props; const { theme: { spinner, semantics }, } = useTheme(); const animatedStyle = useAnimatedStyle(() => ({ transform: [ { rotate: `${rotation.value}deg`, }, ], })); useEffect(() => { rotation.value = withRepeat( withTiming(360, { duration: 800, easing: Easing.linear, }), -1, ); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return ( ); }; Spinner.displayName = 'Spinner{spinner}'; const styles = StyleSheet.create({ spinner: { height: 16, justifyContent: 'center', margin: 5, width: 16, }, });