forked from palinayarmolenka/App-isfit-23
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
256 lines (245 loc) · 6.73 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
import React, { useState, useEffect } from 'react';
import {
View,
StyleSheet,
Dimensions,
Text,
TouchableOpacity,
} 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 * as Font from 'expo-font';
import { FilterProvider } from './src/context/FilterContext';
const launchScreenColors = ['#C92332', '#FF6D8A', '#71DCFF', '#0078A3'];
const MapsStack = createStackNavigator();
function MapsStackScreen() {
return (
<MapsStack.Navigator screenOptions={{ headerShown: false }}>
<MapsStack.Screen name='MapScreen' component={MapScreen} />
<MapsStack.Screen
name='AttractionBoxScreen'
component={AttractionBoxScreen}
/>
<MapsStack.Screen name='MarkerInfoScreen' component={MarkerInfoScreen} />
</MapsStack.Navigator>
);
}
const Tab = createBottomTabNavigator();
function HomeTabs({ showAttractions, setShowAttractions }) {
return (
<Tab.Navigator initialRouteName='Home'>
<Tab.Screen
name='Events'
component={EventScreen}
options={{
headerTintColor: '#FFF5F3',
backgroundColor: '#0078A3',
headerStyle: {
backgroundColor: '#0078A3',
},
headerTitleAlign: 'center',
tabBarIcon: ({ color }) => (
<FontAwesome name='calendar' size={22} color={color} />
),
tabBarActiveTintColor: '#0078A3',
}}
/>
<Tab.Screen
name='Theme'
component={ThemeScreen}
options={{
headerTintColor: '#FFF5F3',
headerStyle: {
backgroundColor: '#C92332', // Red
},
headerTitleAlign: 'center',
tabBarIcon: ({ color }) => (
<Entypo name='megaphone' size={23} color={color} />
),
tabBarActiveTintColor: '#C92332',
}}
/>
<Tab.Screen
name='Explore'
component={MapsStackScreen}
listeners={({ navigation }) => ({
tabPress: (e) => {
setShowAttractions(false);
navigation.navigate('Explore', {
screen: 'MapScreen', // Specify the nested screen
});
},
})}
options={({ navigation }) => {
const currentRoute = navigation
.getState()
?.routes?.find((r) => r.name === 'Explore')
?.state?.routes?.slice(-1)[0]?.name;
const isOnMarkerInfoScreen = currentRoute === 'MarkerInfoScreen';
return {
headerTitle: 'Explore Trondheim',
headerTintColor: '#FFF5F3',
headerStyle: {
backgroundColor: '#FF6D8A', // Pink
},
tabBarIcon: ({ color }) => (
<Entypo name='globe' size={23} color={color} />
),
tabBarActiveTintColor: '#FF6D8A',
headerLeft: () =>
isOnMarkerInfoScreen ? (
<TouchableOpacity
onPress={() => {
navigation.navigate(
showAttractions ? 'AttractionBoxScreen' : 'MapScreen'
);
}}
style={{ marginLeft: 10 }}
>
<FontAwesome name='arrow-left' size={30} color='#FFF5F3' />
</TouchableOpacity>
) : null,
headerRight: () =>
isOnMarkerInfoScreen ? null : (
<TouchableOpacity
onPress={() => {
setShowAttractions(!showAttractions);
navigation.navigate(
showAttractions ? 'MapScreen' : 'AttractionBoxScreen'
);
}}
style={{
marginRight: 10,
backgroundColor: 'transparent', // Make the button transparent
}}
>
<Entypo name={showAttractions ? 'map' : 'list'} size={30} />
</TouchableOpacity>
),
};
}}
/>
<Tab.Screen
name='Information'
component={FAQScreen}
options={{
headerTintColor: '#FFF5F3',
headerStyle: {
backgroundColor: '#71DCFF', // Blue
},
headerTitleAlign: 'center',
tabBarIcon: ({ color }) => (
<FontAwesome5 name='question' size={20} color={color} />
),
tabBarActiveTintColor: '#71DCFF',
}}
/>
</Tab.Navigator>
);
}
const MainStack = createStackNavigator();
function App() {
const [showAttractions, setShowAttractions] = useState(false); // Default to showing MapsStackScreen
return (
<FilterProvider>
<NavigationContainer>
<MainStack.Navigator screenOptions={{ headerShown: false }}>
<MainStack.Screen name='HomeTabs'>
{() => (
<HomeTabs
showAttractions={showAttractions}
setShowAttractions={setShowAttractions}
/>
)}
</MainStack.Screen>
<MainStack.Screen
name='Info'
component={InformationScreen}
options={({ navigation }) => {
return {
headerShown: true, // Enable the header
headerTitle: 'Theme',
headerTintColor: '#FFF5F3',
headerStyle: {
backgroundColor: '#C92332', // Red
},
headerLeft: () => (
<TouchableOpacity
onPress={() => {
navigation.navigate('Theme');
}}
style={{ marginLeft: 10 }}
>
<FontAwesome name='arrow-left' size={30} color='#FFF5F3' />
</TouchableOpacity>
),
};
}}
/>
<MainStack.Screen name='Show' component={EventScreen} />
</MainStack.Navigator>
</NavigationContainer>
</FilterProvider>
);
}
function SplashScreen(props) {
const [fontLoaded, setFontLoaded] = useState(false);
useEffect(() => {
async function loadFont() {
await Font.loadAsync({
HVDRowdyRegular: require('./src/assets/fonts/HVD_Rowdy.otf'),
});
setFontLoaded(true);
}
loadFont();
const timer = setTimeout(() => {
props.setLoading(!props.loading);
}, 2000);
return () => clearTimeout(timer);
}, []);
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor:
launchScreenColors[
Math.floor(Math.random() * launchScreenColors.length)
],
}}
>
<Text
style={[fontstyles.text, fontLoaded ? fontstyles.customFont : null]}
>
isfit25{'\n'}power
</Text>
</View>
);
}
const fontstyles = StyleSheet.create({
text: {
fontSize: 96,
color: Math.random() > 0.5 ? '#141414' : '#FFF5F3',
},
customFont: {
fontFamily: 'HVDRowdyRegular',
},
});
export default () => {
const [loading, setLoading] = useState(true);
if (loading) {
return <SplashScreen loading={loading} setLoading={setLoading} />;
} else {
return <App />;
}
};