-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathMainScreen.tsx
51 lines (45 loc) · 966 Bytes
/
MainScreen.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
import * as React from 'react';
import {
StyleSheet,
SafeAreaView,
Text,
FlatList,
Pressable,
} from 'react-native';
import { useNavigation } from '@react-navigation/native';
import { Experiment, experiments } from './experiments';
export function MainScreen() {
return (
<SafeAreaView style={styles.container}>
<FlatList
data={experiments}
renderItem={({ item }) => <ListItem item={item} />}
/>
</SafeAreaView>
);
}
interface ListItemProps {
item: Experiment;
}
function ListItem({ item }: ListItemProps) {
const navigation = useNavigation();
const handlePress = () => {
navigation.navigate(item.key);
};
return (
<Pressable style={styles.item} onPress={handlePress}>
<Text style={styles.itemTitle}>{item.title}</Text>
</Pressable>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
item: {
padding: 20,
},
itemTitle: {
fontSize: 20,
},
});