-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.js
363 lines (339 loc) · 10.4 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
import * as React from 'react';
import { Text, View, TouchableOpacity, StyleSheet,
PermissionsAndroid, Modal, Image, Dimensions } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createStackNavigator } from '@react-navigation/stack';
import Map from './app/components/map/map';
import Maps from './app/components/map/maps';
import Statistics from './app/components/statistics/statistics';
import Resources from './app/components/resources/resources';
import Icon from 'react-native-ionicons'
import Ionicons from 'react-native-vector-icons/Ionicons';
import SideMenu from 'react-native-side-menu';
// import Menu from './app/components/sideMenu/sideMenu';
import MenuContainer from './app/components/menu/menuContainer';
import { Appbar, DefaultTheme, Drawer, Provider as PaperProvider } from 'react-native-paper'
import About from './app/components/menu/about';
import PrivacyPolicy from './app/components/menu/privacyPolicy';
import Notification from './app/components/menu/notifications';
import Language from './app/components/menu/language';
import Faq from './app/components/menu/faq';
const width = Dimensions.get('window').width;
const height = Dimensions.get('window').height;
const Tab = createBottomTabNavigator();
const Stack = createStackNavigator();
// TODO: Remember to remove this so warnings reappear.
console.disableYellowBox = true;
const requestFineLocationPermission = async() => {
try {
const granted = await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,
],
{
title: "Location Permissions",
message:
"CIAT wants to show you COVID -19 cases in " +
"your current location.",
buttonNeutral: "Ask Me Later",
buttonNegative: "Cancel",
buttonPositive: "OK"
}
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("Fine Location Permission Granted");
} else {
console.log("Fine Location Permission Denied");
}
} catch (error) {
console.warn(error);
}
}
class App extends React.Component {
constructor(props) {
super(props);
this.removeSplash = this.removeSplash.bind(this);
this.state = {
sideMenuOpen: false,
selectedItem: 'About',
latitudeCoordinate: '',
longitudeCoordinate: '',
menuVisible: false,
menuViewToShow: 'None',
showSplash: true,
}
requestFineLocationPermission();
}
componentDidMount() {
this.removeSplash();
// Start the bluetooth thread for contact tracing
// this.handleBluetoothThread();
}
// handleBluetoothThread = () => {
// bluetoothThread.startTracing();
// // Listen for any call backs here
// }
onMenuButtonPressed = () => {
// console.log('menu pressed');
this.setState({
sideMenuOpen: !this.state.sideMenuOpen,
});
}
onMenuItemSelected = (item) => {
this.setState({
sideMenuOpen: false,
selectedItem: item,
});
}
updateMenuState(sideMenuOpen) {
this.setState({ sideMenuOpen });
}
onClickMenuItem = () => {
console.log('on ckick view')
}
Menu = () => {
// const [active, setActive] = React.useState(false);
return(
<PaperProvider theme = {theme}>
<Drawer.Section title=" ">
<Drawer.Item
label="About CIAT"
onPress={() =>{
this.setState({
menuVisible: true,
menuViewToShow: 'About',
})
}}
/>
<Drawer.Item
label="Notifications"
onPress={() =>{
this.setState({
menuVisible: true,
menuViewToShow: 'Notifications',
})
}}
/>
<Drawer.Item
label="Language"
onPress={() =>{
this.setState({
menuVisible: true,
menuViewToShow: 'Language',
})
}}
/>
<Drawer.Item
label="FAQ"
// active={active === 'faq'}
// onPress={() => setActive('faq')}
onPress={() =>{
this.setState({
menuVisible: true,
menuViewToShow: 'FAQ',
})
}}
/>
<Drawer.Item
label="Privacy Policy"
onPress={() =>{
this.setState({
menuVisible: true,
menuViewToShow: 'Privacy Policy',
})
}}
/>
<Drawer.Item
label="Terms & Conditions"
onPress={() =>{
alert('Coming Soon');
}}
/>
<Drawer.Item
label="Contact Us"
// active={active === 'cu'}
// onPress={() => setActive('cu')}
/>
<Drawer.Item
label="Follow Us"
// active={active === 'fu'}
// onPress={() => setActive('fu')}
/>
</Drawer.Section>
</PaperProvider>
);
}
ShowMenu = () => {
switch(this.state.menuViewToShow) {
case "About":
return (<About/>);
case "Privacy Policy":
return (<PrivacyPolicy/>);
case "Language":
return (<Language/>);
case "FAQ":
return <Faq/>;
case "Notifications":
return (<Notification/>);
}
}
closeMenu(){
if (this.state.menuVisible) {
this.setState({
menuVisible: false
});
}
}
removeSplash = () => {
setTimeout(() => {
this.setState({
showSplash: false,
})
}, 2000)
}
render() {
const menu = this.Menu();
function Home() {
return (
<Tab.Navigator
initialRouteName="Map"
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let iosIconName;
let androidIconName;
let iconColor;
if (route.name === 'Resources') {
iosIconName = focused ? 'ios-paper' : 'ios-paper-outline';
androidIconName = focused ? 'md-paper': 'md-paper';
iconColor = focused ? '#088A85': '#848484';
} else if (route.name === 'Map') {
iosIconName = focused ? 'ios-globe' : 'ios-globe-outline';
androidIconName = focused ? 'md-globe': 'md-globe';
iconColor = focused ? '#088A85': '#848484';
} else if (route.name === 'Statistics') {
iosIconName = focused ? 'ios-stats' : 'ios-stats';
androidIconName = focused ? 'md-stats': 'md-stats';
iconColor = focused ? '#088A85': '#848484';
}
// You can return any component that you like here!
return (
<Icon ios={iosIconName} android={androidIconName} color={iconColor}/>
);
// #088A85
// #848484
},
})}
tabBarOptions={{
activeTintColor: '#088A85',
inactiveTintColor: 'gray',
}}
>
<Tab.Screen name="Resources" component={Resources} />
<Tab.Screen name="Map" component={Map} />
<Tab.Screen name="Statistics" component={Statistics} />
</Tab.Navigator>
);
}
return (
<PaperProvider theme = {theme}>
<SideMenu isOpen = {this.state.sideMenuOpen} onChange={isOpen => this.updateMenuState(isOpen)}
menu = {menu}>
<Appbar.Header>
<TouchableOpacity onPress={this.onMenuButtonPressed}>
<Icon ios="ios-menu" android="md-menu" color="#088A85"/>
</TouchableOpacity>
<Appbar.Content
title = "CIAT"
/>
</Appbar.Header>
<Modal
animationType="slide"
transparent={true}
visible={this.state.menuVisible}
>
<View style={styles.modalView}>
<TouchableOpacity onPress={() => this.closeMenu()}>
<Icon ios="ios-close-circle" android="md-close-circle" color="grey"
style={{padding: 10}} />
</TouchableOpacity>
{this.ShowMenu()}
</View>
</Modal>
{ this.state.showSplash &&
<Modal
animationType='none'
transparent={false}
visible={true}
>
<View style={styles.splashModal}>
<Image
style={styles.splashLogoStyles}
source={require('./logo_ciat.png')}
/>
</View>
</Modal>
}
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerShown: false
}}
>
<Stack.Screen name = "Home" component ={Home}/>
<Stack.Screen name = "Menu" component = {MenuContainer}/>
</Stack.Navigator>
</NavigationContainer>
</SideMenu>
</PaperProvider>
);
}
}
const styles = StyleSheet.create({
iconView:{
backgroundColor: '#107E7D',
opacity: 10,
},
menuView: {
flex: 1,
justifyContent: "center",
alignItems: "center",
marginTop: 22
},
modalView: {
marginTop: 56,
height: '100%',
backgroundColor: "white",
padding: 20,
// shadowColor: "#000",
// shadowOffset: {
// width: 0,
// height: 2
// },
// shadowOpacity: 0.25,
// shadowRadius: 3.84,
// elevation: 5
},
splashModal: {
height: height,
width: width,
// backgroundColor: "white",
justifyContent: 'center',
alignItems: 'center',
},
splashLogoStyles: {
width: width * 0.7,
height: height * 0.7,
borderRadius: 10,
resizeMode: 'contain'
}
})
const theme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
primary: 'white',
accent: '#b49935'
},
};
export default App;