forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
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, useTheme} from '#/alf'
11import {type 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={[a.absolute, a.inset_0, t.atoms.text_contrast_high, props.style]}
41 />
42 </Animated.View>
43 )
44}