-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.js
71 lines (63 loc) · 1.92 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
import React, { useEffect, useState } from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { COLORS } from "./assets/constants/constants";
import { Landing } from "./src/Landing/Landing";
import { PostForm } from "./src/PostForm/PostForm";
import { ToggleView } from "./src/ToggleView/ToggleView";
import { SiteDetails } from "./src/SiteDetails/SiteDetails";
import { CommentForm } from "./src/CommentForm/CommentForm";
import { loadData } from './src/apiCalls';
// Disables warnings from displaying in app.
console.disableYellowBox = true;
const Stack = createStackNavigator();
const App = () => {
const [campsiteData, setCampsiteData] = useState([]);
useEffect(() => {
loadData(setCampsiteData);
}, []);
const brandHeader = {
title: "WilderNests",
headerStyle: {
backgroundColor: COLORS.green,
},
headerTitleStyle: {
color: "#fff",
},
headerBackTitleStyle: {
color: "#fff",
},
headerTintColor: "#fff",
};
const toggleComponent = () => <ToggleView data={campsiteData} />;
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Landing">
<Stack.Screen
name="Home"
component={Landing}
options={{ headerShown: false }}
/>
<Stack.Screen name="Post">
{props => <PostForm {...props} loadData={() => loadData(setCampsiteData)} />}
</Stack.Screen>
<Stack.Screen
name="Toggle View"
component={toggleComponent}
options={brandHeader}
/>
<Stack.Screen
name="Details"
component={SiteDetails}
options={brandHeader}
/>
<Stack.Screen
name="Comment Form"
component={CommentForm}
options={brandHeader}
/>
</Stack.Navigator>
</NavigationContainer>
);
};
export default App;