-
Notifications
You must be signed in to change notification settings - Fork 1
/
App2.tsx
107 lines (98 loc) · 3.77 KB
/
App2.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
import React from 'react';
import { Image, StyleSheet } from 'react-native';
/**
* Import createStackNavigator that we will use to create the stack navigator for the home page
We shall see below how they are used
*/
import { createStackNavigator } from '@react-navigation/stack';
/**
* Import NavigationContainer that we will use to wrap the stack we will create.
See in App component below how it is used
*/
import { NavigationContainer } from '@react-navigation/native';
/**
* Import our components that we will create screens for.
* Among them is a new Component named Home which will simply contain Button links to
* each of the other Component screens.
* See Home.tsx for implementation for the said Home Component
*/
import Home from './src/Home2';
import Component6 from './src/components/Component6';
import Component7 from './src/components/Component7';
import Component8 from './src/components/Component8';
import Component9 from './src/components/Component9';
import Component10 from './src/components/Component10';
import Component11 from './src/components/Component11';
import AppTypeORM from './src/components/typeorm_demo/AppTypeORM'
//Create the Stack object
const Stack = createStackNavigator();
//if we want to pass initial parameters to the App Stack, we can first organize the typing as we did for HomeScreen in Home.tsx
//We will then have to use initialParams in each Stack.Screen to indicate the params specified in types
//e.g. for Component1Screen would be initialParams={{demoInitialParam:string}}
/*
type AppStackParamList = {
HomeScreen: undefined; //no parameters expected to be passed to route when called
Component6Screen: undefined;
Component7Screen: undefined;
Component8Screen: undefined;
Component9Screen: undefined;
};
const Stack = createStackNavigator<AppStackParamList>();
*/
//See https://reactnavigation.org/docs/stack-navigator/ for info on the prop elements for Stack.Navigator.
//Prepare the App Stack with the Screens
const AppStack = () => {
return(
<Stack.Navigator
initialRouteName='HomeScreen'
mode='card'
headerMode='screen'
keyboardHandlingEnabled={true}
screenOptions={{
headerStyle: {
backgroundColor: 'darkblue',
height: 120
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
paddingTop: 60,
paddingBottom: 10
},
headerRight: () => (
<Image style={styles.logo}
source={require('./src/img/PAU-Logo-Website.png')}
/>
),
headerTitleAlign: 'left',
headerRightContainerStyle:{//there is also headerLeftContainerStyle if we want to use it
paddingBottom: 33
}
}}
>
<Stack.Screen name="HomeScreen" component={Home} options={{title: 'App2 Home Screen'}}/>
<Stack.Screen name="Component6Screen" component={Component6} options={{title: 'Component 6'}}/>
<Stack.Screen name="Component7Screen" component={Component7} options={{title: 'Component 7'}}/>
<Stack.Screen name="Component8Screen" component={Component8} options={{title: 'Component 8'}}/>
<Stack.Screen name="Component9Screen" component={Component9} options={{title: 'Component 9'}}/>
<Stack.Screen name="Component10Screen" component={Component10} options={{title: 'Component 10'}}/>
<Stack.Screen name="Component11Screen" component={Component11} options={{title: 'Component 11'}}/>
</Stack.Navigator>
)
}
//Pass the prepared AppStack to App wrapping it in NavigatorContainer
const App: React.FC = () => {
return (
<NavigationContainer independent={true}>
<AppStack />
</NavigationContainer>
);
}
const styles = StyleSheet.create({
logo:{
width: 133,
height: 55,
paddingBottom: 50
}
});
export default App;