From 0732041a91f034889523b5aa64b0e4a069dad4ef Mon Sep 17 00:00:00 2001 From: Jakub Grzywacz Date: Wed, 2 Oct 2024 17:03:36 +0200 Subject: [PATCH] test: add example/test case --- apps/test-examples/index.tsx | 1 + apps/test-examples/src/Test2471.tsx | 108 ++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 apps/test-examples/src/Test2471.tsx diff --git a/apps/test-examples/index.tsx b/apps/test-examples/index.tsx index 05d853456..06527e5e7 100644 --- a/apps/test-examples/index.tsx +++ b/apps/test-examples/index.tsx @@ -33,6 +33,7 @@ import Test2403 from './src/Test2403'; import Test2407 from './src/Test2407'; import Test2417 from './src/Test2417'; import Test2455 from './src/Test2455'; +import Test2471 from './src/Test2471'; export default function App() { return ; diff --git a/apps/test-examples/src/Test2471.tsx b/apps/test-examples/src/Test2471.tsx new file mode 100644 index 000000000..ab5b5f154 --- /dev/null +++ b/apps/test-examples/src/Test2471.tsx @@ -0,0 +1,108 @@ +import React, {useEffect, useRef} from 'react'; +import {Animated, Text, View} from 'react-native'; +import Reanimated, { + interpolateColor, + useAnimatedProps, + useSharedValue, + withRepeat, + withTiming, +} from 'react-native-reanimated'; +import {Circle, Path, Svg} from 'react-native-svg'; + +const AnimatedPath = Animated.createAnimatedComponent(Path); +const AnimatedCircle = Animated.createAnimatedComponent(Circle); +const AnimatedTest = (): JSX.Element => { + const animColor = useRef(new Animated.Value(0)).current; + useEffect(() => { + Animated.loop( + Animated.sequence([ + Animated.timing(animColor, { + toValue: 1, + duration: 1000, + useNativeDriver: true, + }), + Animated.timing(animColor, { + toValue: 0, + duration: 1000, + useNativeDriver: true, + }), + ]), + ).start(); + }, []); + return ( + + + + + ); +}; + +const ReanimatedPath = Reanimated.createAnimatedComponent(Path); +const ReanimatedCircle = Reanimated.createAnimatedComponent(Circle); +const ReanimatedTest = (): JSX.Element => { + const progress = useSharedValue(0); + useEffect(() => { + progress.value = withRepeat(withTiming(1, {duration: 1000}), -1, true); + }, []); + + const animatedProps = useAnimatedProps(() => ({ + fill: interpolateColor(progress.value, [0, 1], ['red', 'green']), + stroke: interpolateColor(progress.value, [0, 1], ['blue', 'yellow']), + })); + const animatedProps2 = useAnimatedProps(() => ({ + fill: interpolateColor(progress.value, [0, 1], ['blue', 'red']), + color: interpolateColor(progress.value, [0, 1], ['pink', 'black']), + })); + + return ( + + + + + ); +}; + +export default () => { + return ( + + Animated test + + Reanimated test + + + ); +};