-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
98 lines (89 loc) · 3.66 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
import 'react-native-gesture-handler';
import { createStackNavigator } from '@react-navigation/stack';
import React, { useState, useEffect } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { View, StyleSheet, Image } from 'react-native';
import * as Font from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import HomeScreen from './screens/HomeScreen.js';
import PostConfirmationScreen from './screens/PostConfirmationScreen.js';
import PostScreen from './screens/PostScreen.js';
import NavBar from './components/NavBar.js';
import LoginScreen from './screens/LoginScreen.js';
import RegistrationScreen from './screens/RegistrationScreen.js';
import ListingScreen from './screens/ListingScreen.js';
import FilterScreen from './screens/FilterScreen.js';
import EditProfileScreen from './screens/EditProfileScreen.js';
import EditListingScreen from './screens/EditListingScreen.js';
import MapScreen from './screens/MapScreen.js';
const Stack = createStackNavigator();
const loadFontsAndAssets = async () => {
await Font.loadAsync({
'NotoSansTaiTham-Bold': require('./assets/fonts/NotoSansTaiTham-Bold.ttf'),
'NotoSansTaiTham-Medium': require('./assets/fonts/NotoSansTaiTham-Medium.ttf'),
'NotoSansTaiTham-Regular': require('./assets/fonts/NotoSansTaiTham-Regular.ttf'),
'NotoSansTaiTham-SemiBold': require('./assets/fonts/NotoSansTaiTham-SemiBold.ttf'),
'NotoSansTaiTham-Variable': require('./assets/fonts/NotoSansTaiTham-VariableFont_wght.ttf'),
});
};
SplashScreen.preventAutoHideAsync();
function App() {
const [isReady, setIsReady] = useState(false);
useEffect(() => {
const prepareResources = async () => {
try {
await loadFontsAndAssets();
} catch (e) {
console.warn(e);
} finally {
setIsReady(true);
SplashScreen.hideAsync();
}
};
prepareResources();
}, []);
if (!isReady) {
return (
<View style={styles.loadingContainer}>
<Image source={require('./assets/shuttle.png')} style={styles.loadingImage} />
</View>
);
}
return (
<View style={styles.container}>
<NavigationContainer>
<Stack.Navigator lazy={true}>
<Stack.Screen name="Login" component={LoginScreen} />
<Stack.Screen name="Registration" component={RegistrationScreen} />
<Stack.Screen name="Tab" component={NavBar} options={{ headerShown: false }} />
<Stack.Screen name="HomeScreen" component={HomeScreen} options={{ headerShown: false}} />
<Stack.Screen name="PostScreen" component={PostScreen} options={{ headerShown: false }}/>
<Stack.Screen name="PostConfirmationScreen" component={PostConfirmationScreen} options={{ headerShown: false }}/>
<Stack.Screen name="Listing" component={ListingScreen} options={{ headerShown: false }} />
<Stack.Screen name="EditListingScreen" component={EditListingScreen} options={{ headerShown: false }} />
<Stack.Screen name="MapScreen" component={MapScreen} options={{ headerShown: false }} />
<Stack.Screen name="FilterScreen" component={FilterScreen} options={{ headerShown: false }} />
<Stack.Screen name="EditProfile" component={EditProfileScreen} options={{ headerShown: false }} />
</Stack.Navigator>
</NavigationContainer>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#ffffff',
},
loadingContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#ffffff',
},
loadingImage: {
width: 350,
height: 350,
resizeMode: 'contain',
},
});
export default App;