diff options
Diffstat (limited to 'components/HelloWave.tsx')
-rw-r--r-- | components/HelloWave.tsx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/components/HelloWave.tsx b/components/HelloWave.tsx new file mode 100644 index 0000000..f4b6ea5 --- /dev/null +++ b/components/HelloWave.tsx @@ -0,0 +1,37 @@ +import { StyleSheet } from 'react-native'; +import Animated, { + useSharedValue, + useAnimatedStyle, + withTiming, + withRepeat, + withSequence, +} from 'react-native-reanimated'; + +import { ThemedText } from '@/components/ThemedText'; + +export function HelloWave() { + const rotationAnimation = useSharedValue(0); + + rotationAnimation.value = withRepeat( + withSequence(withTiming(25, { duration: 150 }), withTiming(0, { duration: 150 })), + 4 // Run the animation 4 times + ); + + const animatedStyle = useAnimatedStyle(() => ({ + transform: [{ rotate: `${rotationAnimation.value}deg` }], + })); + + return ( + <Animated.View style={animatedStyle}> + <ThemedText style={styles.text}>👋</ThemedText> + </Animated.View> + ); +} + +const styles = StyleSheet.create({ + text: { + fontSize: 28, + lineHeight: 32, + marginTop: -6, + }, +}); |