-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
75 lines (68 loc) · 2.3 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
/** @format */
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { StatusBar } from "expo-status-bar";
import AllPlaces from "./src/screens/AllPlaces";
import AddPlace from "./src/screens/AddPlace";
import PlaceDetails from "./src/screens/PlaceDetails";
import Colors from "./src/consts/Colors";
import { Ionicons, MaterialIcons } from "@expo/vector-icons";
import Maps from "./src/screens/Maps";
import { useEffect, useState } from "react";
import { initializeDatabase } from "./src/util/Database";
import { ActivityIndicator } from "react-native";
const Stack = createStackNavigator();
export default function App() {
const [isIntDb, setIsIntDb] = useState(false);
useEffect(() => {
const intDb = async () => {
// can use then catch structure instead ,initialized database only once
setIsIntDb(true);
await initializeDatabase();
};
intDb();
}, []);
if (!isIntDb == true) {
return <ActivityIndicator size={"large"} color={Colors.primary} />;
}
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={({ navigation }) => ({
headerStyle: { backgroundColor: Colors.primary },
// title: "Your Favourite Places",
headerTitleAlign: "center",
cardStyle: { backgroundColor: Colors.primaryDark }, //app default backgroundColor
})}
>
<Stack.Screen
name="AllPlaces"
component={AllPlaces}
options={({ navigation }) => ({
title: "Your Favourite Places",
headerRight: () => {
return (
<MaterialIcons
name="add"
style={{ marginRight: 10 }}
onPress={() => navigation.navigate("AddPlace")}
size={30}
/>
);
},
})}
/>
<Stack.Screen name="AddPlace" component={AddPlace} />
<Stack.Screen name="PlaceDetails" component={PlaceDetails} />
<Stack.Screen
name="Map"
component={Maps}
options={() => ({
title: "Map",
})}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
//installed react native maps with expo to able to see google maps screen