-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
184 lines (166 loc) · 4.33 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React, {createContext} from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {Image, TouchableOpacity} from 'react-native';
import {createStackNavigator} from '@react-navigation/stack';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import Icon from 'react-native-vector-icons/MaterialIcons';
Icon.loadFont();
// Screens
import HomeScreen from './src/screens/Home/index';
import ProfileScreen from './src/screens/Profile/index';
import TopScreen from './src/screens/toplist/index';
import OnboardScreen from './src/screens/Onboard/index';
import ControllerScreen from './src/screens/ControllerScreen/index';
import AddDonationScreen from './src/screens/AddDonation/index';
const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
// Context
import {KVProvider} from './src/core/context';
const AppContext = createContext();
function LogoTitle() {
return (
<Image
style={{width: 200, height: 50, resizeMode: 'center'}}
source={require('./src/assets/img/logo.png')}
/>
);
}
const MainStack = () => {
return (
<Stack.Navigator>
<Stack.Screen
name="Main"
component={HomeScreen}
options={{
headerTitle: (props) => <LogoTitle {...props} />,
headerStyle: {
backgroundColor: '#FF2744',
},
}}
/>
<Stack.Screen
name="Add"
component={AddDonationScreen}
options={{
headerTitle: (props) => <LogoTitle {...props} />,
headerStyle: {
backgroundColor: '#FF2744',
},
}}
/>
</Stack.Navigator>
);
};
const ProfileStack = () => {
return (
<Stack.Navigator>
<Stack.Screen
name="Profile"
component={ProfileScreen}
options={{
headerTitle: (props) => <LogoTitle {...props} />,
headerStyle: {
backgroundColor: '#FF2744',
},
}}
/>
</Stack.Navigator>
);
};
const TopStack = () => {
return (
<Stack.Navigator>
<Stack.Screen
name="TopList"
component={TopScreen}
options={{
headerTitle: (props) => <LogoTitle {...props} />,
headerStyle: {
backgroundColor: '#FF2744',
},
}}
/>
</Stack.Navigator>
);
};
const LoggedInStack = () => {
return (
<Tab.Navigator
screenOptions={({route}) => ({
tabBarIcon: ({focused, color, size}) => {
let iconName;
if (route.name === 'Home') {
iconName = focused ? 'home' : 'home';
} else if (route.name === 'Profile') {
iconName = focused ? 'account-box' : 'account-box';
} else if (route.name === 'Top List') {
iconName = focused ? 'star' : 'star';
}
return <Icon name={iconName} size={size} color={color} />;
},
})}
tabBarOptions={{
activeTintColor: '#FF2744',
inactiveTintColor: 'gray',
}}>
<Tab.Screen name="Home" component={MainStack} />
<Tab.Screen name="Top List" component={TopStack} />
<Tab.Screen name="Profile" component={ProfileStack} />
</Tab.Navigator>
);
};
const LoggedOutStack = () => {
return (
<Stack.Navigator>
<Stack.Screen
name="Onboard"
component={OnboardScreen}
options={{
headerShown: false,
}}
/>
</Stack.Navigator>
);
};
const AppStack = () => {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Controller" component={ControllerScreen} />
<Stack.Screen
options={{
headerShown: false,
}}
name="LoggedOut"
component={LoggedOutStack}
/>
<Stack.Screen
options={{
headerTitle: (props) => <LogoTitle {...props} />,
headerLeft: null,
headerStyle: {
backgroundColor: '#FF2744',
},
}}
name="LoggedIn"
component={LoggedInStack}
/>
</Stack.Navigator>
</NavigationContainer>
);
};
const App: () => React$Node = () => {
return (
<>
<KVProvider>{AppStack()}</KVProvider>
</>
);
};
export default App;