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.get() + 'deg'}],
21 }))
22
23 React.useEffect(() => {
24 rotation.set(() =>
25 withRepeat(withTiming(360, {duration: 500, easing: Easing.linear}), -1),
26 )
27 }, [rotation])
28
29 return (
30 <Animated.View
31 style={[
32 a.relative,
33 a.justify_center,
34 a.align_center,
35 {width: common.size, height: common.size},
36 animatedStyles,
37 ]}>
38 <Icon
39 {...props}
40 style={[
41 a.absolute,
42 a.inset_0,
43 t.atoms.text_contrast_high,
44 flatten(props.style),
45 ]}
46 />
47 </Animated.View>
48 )
49}