-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathApp.tsx
More file actions
98 lines (93 loc) · 2.16 KB
/
App.tsx
File metadata and controls
98 lines (93 loc) · 2.16 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
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
import {
View,
Text,
StyleSheet,
TouchableOpacity,
ScrollView,
} from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { PagesList } from './PagesList';
type RootStackParamList = {
Home: undefined;
} & {
[K in (typeof PagesList)[number]['id']]: undefined;
};
const Stack = createStackNavigator<RootStackParamList>();
function HomeScreen({ navigation }: { navigation: any }) {
return (
<ScrollView style={styles.container}>
<Text style={styles.header}>Rive React Native Examples</Text>
<View style={styles.buttonContainer}>
{PagesList.map(({ id, name }) => (
<TouchableOpacity
key={id}
style={styles.button}
onPress={() => navigation.navigate(id)}
>
<Text style={styles.buttonText}>{name}</Text>
</TouchableOpacity>
))}
</View>
</ScrollView>
);
}
export default function App() {
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerStyle: {
backgroundColor: '#323232',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
}}
>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{ title: 'Rive Examples' }}
/>
{PagesList.map(({ id, component, name }) => (
<Stack.Screen
key={id}
name={id}
component={component}
options={{ title: name }}
/>
))}
</Stack.Navigator>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
header: {
fontSize: 28,
fontWeight: 'bold',
textAlign: 'center',
marginTop: 40,
marginBottom: 30,
},
buttonContainer: {
padding: 20,
},
button: {
backgroundColor: '#007AFF',
padding: 15,
borderRadius: 10,
marginBottom: 15,
},
buttonText: {
color: '#fff',
fontSize: 16,
fontWeight: 'bold',
textAlign: 'center',
},
});