-
Notifications
You must be signed in to change notification settings - Fork 39
/
App.js
168 lines (155 loc) · 4.35 KB
/
App.js
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import React from 'react';
import { View, TouchableOpacity } from 'react-native';
import { createSwitchNavigator, createAppContainer } from 'react-navigation';
import { createMaterialTopTabNavigator } from 'react-navigation-tabs';
import { createDrawerNavigator } from 'react-navigation-drawer';
import { createStackNavigator } from 'react-navigation-stack';
import { Ionicons } from '@expo/vector-icons';
// Auth stack screen imports
import AuthLoadingScreen from './src/components/screens/AuthLoadingScreen';
import WelcomeScreen from './src/components/screens/WelcomeScreen';
import SignUpScreen from './src/components/screens/SignUpScreen';
import SignInScreen from './src/components/screens/SignInScreen';
import ForgetPasswordScreen from './src/components/screens/ForgetPasswordScreen';
// App stack screen imports
import HomeScreen from './src/components/screens/HomeScreen';
import SettingsScreen from './src/components/screens/SettingsScreen';
import ProfileScreen from './src/components/screens/ProfileScreen';
// Amplify imports and config
import Amplify from '@aws-amplify/core';
import awsmobile from './aws-exports';
Amplify.configure(awsmobile);
// Configurations and options for the AppTabNavigator
const configurations = {
Home: {
screen: HomeScreen,
navigationOptions: {
tabBarLabel: 'Home',
tabBarIcon: ({ tintColor }) => (
<Ionicons style={{ fontSize: 26, color: tintColor }} name="ios-home" />
),
},
},
Profile: {
screen: ProfileScreen,
navigationOptions: {
tabBarLabel: 'Profile',
tabBarIcon: ({ tintColor }) => (
<Ionicons
style={{ fontSize: 26, color: tintColor }}
name="ios-person"
/>
),
},
},
Settings: {
screen: SettingsScreen,
navigationOptions: {
tabBarLabel: 'Settings',
tabBarIcon: ({ tintColor }) => (
<Ionicons
style={{ fontSize: 26, color: tintColor }}
name="ios-settings"
/>
),
},
},
};
const options = {
tabBarPosition: 'bottom',
swipeEnabled: true,
animationEnabled: true,
navigationOptions: {
tabBarVisible: true,
},
tabBarOptions: {
showLabel: true,
activeTintColor: '#fff',
inactiveTintColor: '#fff9',
style: {
backgroundColor: '#f16f69',
},
labelStyle: {
fontSize: 12,
fontWeight: 'bold',
marginBottom: 12,
marginTop: 12,
},
indicatorStyle: {
height: 0,
},
showIcon: true,
},
};
// Bottom App tabs
const AppTabNavigator = createMaterialTopTabNavigator(configurations, options);
// Making the common header title dynamic in AppTabNavigator
AppTabNavigator.navigationOptions = ({ navigation }) => {
let { routeName } = navigation.state.routes[navigation.state.index];
let headerTitle = routeName;
return {
headerTitle,
};
};
const AppStackNavigator = createStackNavigator({
Header: {
screen: AppTabNavigator,
// Set the header icon
navigationOptions: ({ navigation }) => ({
headerLeft: (
<TouchableOpacity onPress={() => navigation.toggleDrawer()}>
<View style={{ paddingHorizontal: 10 }}>
<Ionicons size={24} name="md-menu" />
</View>
</TouchableOpacity>
),
}),
},
});
// App stack for the drawer
const AppDrawerNavigator = createDrawerNavigator({
Tabs: AppStackNavigator, // defined above
Home: HomeScreen,
Profile: ProfileScreen,
Settings: SettingsScreen,
});
// Auth stack
const AuthStackNavigator = createStackNavigator({
Welcome: {
screen: WelcomeScreen,
navigationOptions: () => ({
title: `Welcome to this App`, // for the header screen
headerBackTitle: 'Back',
}),
},
SignUp: {
screen: SignUpScreen,
navigationOptions: () => ({
title: `Create a new account`,
}),
},
SignIn: {
screen: SignInScreen,
navigationOptions: () => ({
title: `Log in to your account`,
}),
},
ForgetPassword: {
screen: ForgetPasswordScreen,
navigationOptions: () => ({
title: `Create a new password`,
}),
},
});
// Application nav stack
const appNav = createSwitchNavigator({
Authloading: AuthLoadingScreen,
Auth: AuthStackNavigator, // the Auth stack
App: AppDrawerNavigator, // the App stack
});
const AppContainer = createAppContainer(appNav);
export default class App extends React.Component {
render() {
return <AppContainer />;
}
}