Skip to content

Commit 04c951c

Browse files
committed
chore: flip bunnies
1 parent 035ba77 commit 04c951c

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

packages/example/src/modules/program/view/ProgramNode.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { Program } from './Program';
55
import { forwardRef } from 'react';
66
import { SpatialNavigationNodeRef } from '../../../../../lib/src/spatial-navigation/types/SpatialNavigationNodeRef';
77

8+
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
9+
810
type Props = {
911
programInfo: ProgramInfo;
1012
onSelect?: () => void;
@@ -15,20 +17,35 @@ type Props = {
1517

1618
export const ProgramNode = forwardRef<SpatialNavigationNodeRef, Props>(
1719
({ programInfo, onSelect, indexRange, label, variant }: Props, ref) => {
20+
const rotationZ = useSharedValue(0);
21+
22+
const rotate360 = () => {
23+
rotationZ.value = withTiming(rotationZ.value + 360);
24+
};
25+
26+
const animatedStyle = useAnimatedStyle(() => {
27+
return {
28+
transform: [{ rotateZ: `${rotationZ.value}deg` }],
29+
};
30+
});
31+
1832
return (
1933
<SpatialNavigationFocusableView
2034
onSelect={onSelect}
35+
onLongSelect={rotate360}
2136
indexRange={indexRange}
2237
viewProps={{ accessibilityLabel: programInfo.title }}
2338
ref={ref}
2439
>
2540
{({ isFocused, isRootActive }) => (
26-
<Program
27-
isFocused={isFocused && isRootActive}
28-
programInfo={programInfo}
29-
label={label}
30-
variant={variant}
31-
/>
41+
<Animated.View style={animatedStyle}>
42+
<Program
43+
isFocused={isFocused && isRootActive}
44+
programInfo={programInfo}
45+
label={label}
46+
variant={variant}
47+
/>
48+
</Animated.View>
3249
)}
3350
</SpatialNavigationFocusableView>
3451
);

0 commit comments

Comments
 (0)