-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
202 lines (187 loc) · 5.88 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
import React, { useState, useEffect } from "react";
import { View, StyleSheet, Image, Dimensions, Platform } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { createStackNavigator } from "@react-navigation/stack";
import { FontAwesome5, Entypo, FontAwesome } from "@expo/vector-icons";
import EventScreen from "./src/screens/EventScreen";
import MapScreen from "./src/screens/MapScreen";
import ThemeScreen from "./src/screens/ThemeScreen";
import FAQScreen from "./src/screens/FAQScreen";
import InformationScreen from "./src/screens/InformationScreen";
import MarkerInfoScreen from "./src/screens/MarkerInfoScreen";
import AttractionBoxScreen from "./src/screens/AttractionBoxScreen";
import AttractionBoxInfoScreen from "./src/screens/AttractionBoxInfoScreen";
const width = Dimensions.get("screen").width;
const height = Dimensions.get("screen").height;
const MapsStack = createStackNavigator();
//Make to have a visible tabbar on these screens
function MapsStackScreen() {
return (
<MapsStack.Navigator screenOptions={{ headerShown: false }}>
<MapsStack.Screen name="MapsScreen" component={MapScreen} />
<MapsStack.Screen name="MarkerInfoScreen" component={MarkerInfoScreen} />
</MapsStack.Navigator>
);
}
const AttractionStack = createStackNavigator();
function AttractionStackScreen() {
return (
<AttractionStack.Navigator screenOptions={{ headerShown: false }}>
<AttractionStack.Screen name="AttractionBoxScreen" component={AttractionBoxScreen} />
<AttractionStack.Screen name="AttractionBoxInfoScreen" component={AttractionBoxInfoScreen} />
</AttractionStack.Navigator>
);
}
const Tab = createBottomTabNavigator();
function HomeTabs() {
return (
<Tab.Navigator initialRouteName="Home">
<Tab.Screen
name="Events"
component={EventScreen}
options={{
headerTintColor: "#FFFF",
backgroundColor: "#2596BE",
headerStyle: {
backgroundColor: "#E63872",
},
tabBarIcon: ({ color }) => (
<FontAwesome name="calendar" size={22} color={color} />
),
tabBarActiveTintColor: "#E63872",
}}
/>
<Tab.Screen
name="Theme"
component={ThemeScreen}
options={{
headerTintColor: "#FFFF",
headerStyle: {
backgroundColor: "#F78D1F",
},
tabBarIcon: ({ color }) => (
<Entypo name="megaphone" size={23} color={color} />
),
tabBarActiveTintColor: "#F78D1F",
}}
/>
{/* Map is bugged on Android */}
{Platform.OS === 'ios' ? (
<Tab.Screen
name="Explore"
component={MapsStackScreen}
options={{
headerTitle: "Explore Trondheim",
headerTintColor: "#FFFF",
headerStyle: {
backgroundColor: "#99499C",
},
tabBarIcon: ({ color }) => (
<Entypo name="globe" size={23} color={color} />
),
tabBarActiveTintColor: "#99499C",
}}
/>
) : (
<Tab.Screen
name="Explore"
component={AttractionStackScreen}
options={{
headerTitle: "Explore Trondheim",
headerTintColor: "#FFFF",
headerStyle: {
backgroundColor: "#99499C",
},
tabBarIcon: ({ color }) => (
<Entypo name="globe" size={23} color={color} />
),
tabBarActiveTintColor: "#99499C",
}}
/>
)}
<Tab.Screen
name="Information"
component={FAQScreen}
options={{
headerTintColor: "#FFFFFF",
headerStyle: {
backgroundColor: "#0197CC",
},
tabBarIcon: ({ color }) => (
<FontAwesome5 name="question" size={20} color={color} />
),
tabBarActiveTintColor: "#0197CC",
}}
/>
</Tab.Navigator>
);
}
//creates the main stack navigation for the app and removes the default header
const MainStack = createStackNavigator();
//get white default backgroundcolor on all pages
function App() {
return (
<NavigationContainer>
<MainStack.Navigator screenOptions={{ headerShown: false }}>
<MainStack.Screen name="HomeTabs" component={HomeTabs} />
<MainStack.Screen name="Info" component={InformationScreen} />
<MainStack.Screen name="Show" component={EventScreen} />
</MainStack.Navigator>
</NavigationContainer>
);
}
//Own splashscreen that renders for 2 sek.
function SplashScreen(props) {
useEffect(() => {
const timer = setTimeout(() => {
props.setLoading(!props.loading);
}, 2000);
return () => clearTimeout(timer);
}, []);
return (
<View style={{ backgroundColor: "#99499C", flex: 1 }}>
<View>
<Image
style={styles.picture}
source={require("./src/assets/launch_screen.png")}
/>
</View>
</View>
);
}
export default () => {
const [loading, setLoading] = useState(true);
if (loading) {
return <SplashScreen loading={loading} setLoading={setLoading} />;
} else {
return (
<NavigationContainer>
<MainStack.Navigator screenOptions={{ headerShown: false }}>
<MainStack.Screen name="HomeTabs" component={HomeTabs} />
<MainStack.Screen name="Info" component={InformationScreen} />
<MainStack.Screen name="Show" component={EventScreen} />
</MainStack.Navigator>
</NavigationContainer>
);
}
};
const styles = StyleSheet.create({
titletext: {
fontSize: 20,
color: "white",
fontWeight: "bold",
},
randomText: {
paddingTop: height * 0.01,
fontSize: 16,
color: "white",
},
picture: {
alignSelf: "center",
margin: width * 0.6,
height: height * 0.26,
size: 2,
resizeMode: "contain",
},
});