@@ -7,23 +7,12 @@ import {
77} from 'react-native' ;
88import { NavigationContainer } from '@react-navigation/native' ;
99import { createStackNavigator } from '@react-navigation/stack' ;
10- import RiveFileLoadingExample from './pages/RiveFileLoadingExample' ;
11- import DataBindingExample from './pages/RiveDataBindingExample' ;
12- import TemplatePage from './pages/TemplatePage' ;
13- import EventsExample from './pages/RiveEventsExample' ;
14- import StateMachineInputsExample from './pages/RiveStateMachineInputsExample' ;
15- import TextRunExample from './pages/RiveTextRunExample' ;
16- import OutOfBandAssets from './pages/OutOfBandAssets' ;
10+ import { PagesList } from './PagesList' ;
1711
1812type RootStackParamList = {
1913 Home : undefined ;
20- RiveFileLoading : undefined ;
21- RiveDataBinding : undefined ;
22- RiveEvents : undefined ;
23- RiveStateMachineInputs : undefined ;
24- RiveTextRun : undefined ;
25- Template : undefined ;
26- OutOfBandAssets : undefined ;
14+ } & {
15+ [ K in ( typeof PagesList ) [ number ] [ 'id' ] ] : undefined ;
2716} ;
2817
2918const Stack = createStackNavigator < RootStackParamList > ( ) ;
@@ -33,50 +22,15 @@ function HomeScreen({ navigation }: { navigation: any }) {
3322 < ScrollView style = { styles . container } >
3423 < Text style = { styles . header } > Rive React Native Examples</ Text >
3524 < View style = { styles . buttonContainer } >
36- < TouchableOpacity
37- style = { styles . button }
38- onPress = { ( ) => navigation . navigate ( 'RiveFileLoading' ) }
39- >
40- < Text style = { styles . buttonText } > Rive File Loading Examples</ Text >
41- </ TouchableOpacity >
42- < TouchableOpacity
43- style = { styles . button }
44- onPress = { ( ) => navigation . navigate ( 'RiveDataBinding' ) }
45- >
46- < Text style = { styles . buttonText } > Rive Data Binding Example</ Text >
47- </ TouchableOpacity >
48- < TouchableOpacity
49- style = { styles . button }
50- onPress = { ( ) => navigation . navigate ( 'RiveEvents' ) }
51- >
52- < Text style = { styles . buttonText } > Rive Events Example</ Text >
53- </ TouchableOpacity >
54- < TouchableOpacity
55- style = { styles . button }
56- onPress = { ( ) => navigation . navigate ( 'RiveStateMachineInputs' ) }
57- >
58- < Text style = { styles . buttonText } >
59- Rive State Machine Inputs Example
60- </ Text >
61- </ TouchableOpacity >
62- < TouchableOpacity
63- style = { styles . button }
64- onPress = { ( ) => navigation . navigate ( 'RiveTextRun' ) }
65- >
66- < Text style = { styles . buttonText } > Rive Text Run Example</ Text >
67- </ TouchableOpacity >
68- < TouchableOpacity
69- style = { styles . button }
70- onPress = { ( ) => navigation . navigate ( 'OutOfBandAssets' ) }
71- >
72- < Text style = { styles . buttonText } > Out of band assets</ Text >
73- </ TouchableOpacity >
74- < TouchableOpacity
75- style = { styles . button }
76- onPress = { ( ) => navigation . navigate ( 'Template' ) }
77- >
78- < Text style = { styles . buttonText } > Template Page</ Text >
79- </ TouchableOpacity >
25+ { PagesList . map ( ( { id, name } ) => (
26+ < TouchableOpacity
27+ key = { id }
28+ style = { styles . button }
29+ onPress = { ( ) => navigation . navigate ( id ) }
30+ >
31+ < Text style = { styles . buttonText } > { name } </ Text >
32+ </ TouchableOpacity >
33+ ) ) }
8034 </ View >
8135 </ ScrollView >
8236 ) ;
@@ -101,41 +55,14 @@ export default function App() {
10155 component = { HomeScreen }
10256 options = { { title : 'Rive Examples' } }
10357 />
104- < Stack . Screen
105- name = "RiveFileLoading"
106- component = { RiveFileLoadingExample }
107- options = { { title : 'Rive File Loading' } }
108- />
109- < Stack . Screen
110- name = "RiveDataBinding"
111- component = { DataBindingExample }
112- options = { { title : 'Rive Data Binding' } }
113- />
114- < Stack . Screen
115- name = "RiveEvents"
116- component = { EventsExample }
117- options = { { title : 'Rive Events' } }
118- />
119- < Stack . Screen
120- name = "RiveStateMachineInputs"
121- component = { StateMachineInputsExample }
122- options = { { title : 'Rive State Machine Inputs' } }
123- />
124- < Stack . Screen
125- name = "RiveTextRun"
126- component = { TextRunExample }
127- options = { { title : 'Rive Text Runs' } }
128- />
129- < Stack . Screen
130- name = "OutOfBandAssets"
131- component = { OutOfBandAssets }
132- options = { { title : 'Out of Band Asset' } }
133- />
134- < Stack . Screen
135- name = "Template"
136- component = { TemplatePage }
137- options = { { title : 'Template' } }
138- />
58+ { PagesList . map ( ( { id, component, name } ) => (
59+ < Stack . Screen
60+ key = { id }
61+ name = { id }
62+ component = { component }
63+ options = { { title : name } }
64+ />
65+ ) ) }
13966 </ Stack . Navigator >
14067 </ NavigationContainer >
14168 ) ;
0 commit comments