-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
46 lines (41 loc) · 1.54 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
import {StatusBar} from 'expo-status-bar';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {NavigationContainer} from '@react-navigation/native';
import AllPlaces from './screens/AllPlaces';
import AddPlace from './screens/AddPlace';
import {COLORS} from './constans/colors';
import Map from './screens/Map';
import {useEffect, useState} from 'react';
import {init} from './util/database';
import AppLoading from 'expo-app-loading';
import PlaceDetails from './screens/PlaceDetails';
const Stack = createNativeStackNavigator()
export default function App() {
const [dbInitialized, setDbInitialized] = useState(false)
useEffect(() => {
init().then(() => {
setDbInitialized(true)
}).catch((e) => console.log(e))
}, []);
if (!dbInitialized) {
return <AppLoading/>
}
return (
<>
<StatusBar style="auto"/>
<NavigationContainer>
<Stack.Navigator screenOptions={{
headerStyle: {backgroundColor: COLORS.primary500},
headerTintColor: COLORS.gray700,
contentStyle: {backgroundColor: COLORS.gray700}
}} initialRouteName={'AllPlaces'}>
<Stack.Screen
name={'AllPlaces'} component={AllPlaces}/>
<Stack.Screen options={{title: 'Add a new place'}} name={'AddPlace'} component={AddPlace}/>
<Stack.Screen name={'Map'} component={Map}/>
<Stack.Screen options={{title: 'Loading Place...'}} name={'PlaceDetails'} component={PlaceDetails}/>
</Stack.Navigator>
</NavigationContainer>
</>
);
}