-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathProgramNode.tsx
More file actions
46 lines (42 loc) · 1.34 KB
/
ProgramNode.tsx
File metadata and controls
46 lines (42 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {
SpatialNavigationFocusableView,
SpatialNavigationFocusableViewRef,
} from 'react-tv-space-navigation';
import { ProgramInfo } from '../domain/programInfo';
import { Program } from './Program';
import { forwardRef } from 'react';
import { useRotateAnimation } from './useRotateAnimation';
import { Animated } from 'react-native';
type Props = {
programInfo: ProgramInfo;
onSelect?: () => void;
indexRange?: [number, number];
label?: string;
variant?: 'portrait' | 'landscape';
};
export const ProgramNode = forwardRef<SpatialNavigationFocusableViewRef, Props>(
({ programInfo, onSelect, indexRange, label, variant }: Props, ref) => {
const { rotate360, animatedStyle } = useRotateAnimation();
return (
<SpatialNavigationFocusableView
onSelect={onSelect}
onLongSelect={rotate360}
indexRange={indexRange}
viewProps={{ accessibilityLabel: programInfo.title }}
ref={ref}
>
{({ isFocused, isRootActive }) => (
<Animated.View style={animatedStyle}>
<Program
isFocused={isFocused && isRootActive}
programInfo={programInfo}
label={label}
variant={variant}
/>
</Animated.View>
)}
</SpatialNavigationFocusableView>
);
},
);
ProgramNode.displayName = 'ProgramNode';