-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtvdemo.tsx
108 lines (97 loc) · 3.45 KB
/
tvdemo.tsx
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import {
SafeAreaView,
Text,
Pressable,
View,
FlatList,
TouchableHighlight,
} from 'react-native';
import '@/global.css';
import { useScreenDimensions } from '@/hooks/useScreenDimensions';
const backgroundStyle = 'bg-[--color-background] flex-1 pt-[10vh]';
const buttonStyle = `relative m-[0.5vw] bg-blue-500 w-[80vw] h-[10vh] text-white p-[1vw] font-bold overflow-hidden transition duration-500 hover:bg-blue-300 focus:bg-blue-300 active:bg-green-500`;
const buttonTextStyle = 'text-white text-[2.5vw]';
const ribbonStyle = 'ribbonstyle';
const ribbonTextStyle = 'text-white text-[1vw]';
const blockTextStyle = 'text-blue-800 font-bold text-[2.5vw] p-[1.5vw]';
const data: number[] = [...Array(10).keys()];
const TVDemo: () => React.JSX.Element = () => {
const { width, height } = useScreenDimensions();
const renderRow = ({ item }: { item: number }) => {
return (
<View key={item}>
<Text className={blockTextStyle}>{`Block ${item}`}</Text>
<Pressable
onPress={() => console.log('onPress')}
onLongPress={() => console.log('onLongPress')}
onPressIn={() => console.log('onPressIn')}
onPressOut={() => console.log('onPressOut')}
className={buttonStyle}
>
<Text className={buttonTextStyle}>Button 1</Text>
<View className={ribbonStyle}>
<Text className={ribbonTextStyle}>Press me</Text>
</View>
</Pressable>
<Pressable
onPress={() => console.log('onPress')}
onLongPress={() => console.log('onLongPress')}
onPressIn={() => console.log('onPressIn')}
onPressOut={() => console.log('onPressOut')}
tvParallaxProperties={{ enabled: false }}
className={buttonStyle}
>
<Text className={buttonTextStyle}>Button 2</Text>
<View className={ribbonStyle}>
<Text className={ribbonTextStyle}>Cool ribbon style</Text>
</View>
</Pressable>
<Pressable
onPress={() => console.log('onPress')}
onLongPress={() => console.log('onLongPress')}
onPressIn={() => console.log('onPressIn')}
onPressOut={() => console.log('onPressOut')}
tvParallaxProperties={{
enabled: false,
}}
className={buttonStyle}
>
<Text className={buttonTextStyle}>Button 3</Text>
<View className={ribbonStyle}>
<Text className={ribbonTextStyle}>ABCDEFG</Text>
</View>
</Pressable>
<TouchableHighlight
onPress={() => console.log('onPress')}
onLongPress={() => console.log('onLongPress')}
onPressIn={() => console.log('onPressIn')}
onPressOut={() => console.log('onPressOut')}
className={buttonStyle}
>
<View>
<Text className={buttonTextStyle}>TouchableHighlight</Text>
<View className={ribbonStyle}>
<Text className={ribbonTextStyle}>LMNOP</Text>
</View>
</View>
</TouchableHighlight>
</View>
);
};
return (
<View className={backgroundStyle}>
<SafeAreaView style={{ width, height }}>
<FlatList
contentContainerStyle={{
justifyContent: 'center',
alignItems: 'center',
width: '100%',
}}
data={data}
renderItem={renderRow}
></FlatList>
</SafeAreaView>
</View>
);
};
export default TVDemo;