mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import Animated, {
3 Easing,
4 useAnimatedStyle,
5 useSharedValue,
6 withRepeat,
7 withTiming,
8} from 'react-native-reanimated'
9
10import {atoms as a, flatten, useTheme} from '#/alf'
11import {Props, useCommonSVGProps} from '#/components/icons/common'
12import {Loader_Stroke2_Corner0_Rounded as Icon} from '#/components/icons/Loader'
13
14export function Loader(props: Props) {
15 const t = useTheme()
16 const common = useCommonSVGProps(props)
17 const rotation = useSharedValue(0)
18
19 const animatedStyles = useAnimatedStyle(() => ({
20 transform: [{rotate: rotation.value + 'deg'}],
21 }))
22
23 React.useEffect(() => {
24 rotation.value = withRepeat(
25 withTiming(360, {duration: 500, easing: Easing.linear}),
26 -1,
27 )
28 }, [rotation])
29
30 return (
31 <Animated.View
32 style={[
33 a.relative,
34 a.justify_center,
35 a.align_center,
36 {width: common.size, height: common.size},
37 animatedStyles,
38 ]}>
39 <Icon
40 {...props}
41 style={[
42 a.absolute,
43 a.inset_0,
44 t.atoms.text_contrast_high,
45 flatten(props.style),
46 ]}
47 />
48 </Animated.View>
49 )
50}