-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
88 lines (83 loc) · 2.93 KB
/
App.tsx
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
// @ts-nocheck
import { createNativeStackNavigator } from '@react-navigation/native-stack'
import { NavigationContainer } from '@react-navigation/native'
import { ThemeProvider } from '@rneui/themed'
import { QueryClient, QueryClientProvider } from 'react-query'
import { RootNavigation } from './types/Navigator'
import { useTheme } from '@rneui/themed'
import Screens from './src/views/Screens'
import * as SplashScreen from 'expo-splash-screen'
import * as Font from 'expo-font'
import City from './src/views/City'
import { Entypo } from '@expo/vector-icons'
import React, { useState, useEffect, useCallback } from 'react'
import { useFonts, LibreBarcode39Text_400Regular } from '@expo-google-fonts/libre-barcode-39-text'
import { View } from 'react-native'
const queryClient = new QueryClient()
const Stack = createNativeStackNavigator<RootNavigation>()
export default function App() {
const { theme } = useTheme()
const [appIsReady, setAppIsReady] = useState(false)
let [fontsLoaded] = useFonts({
LibreBarcode39Text_400Regular
})
useEffect(() => {
async function prepare() {
try {
// Keep the splash screen visible while we fetch resources
await SplashScreen.preventAutoHideAsync()
// Pre-load fonts, make any API calls you need to do here
await Font.loadAsync(Entypo.font)
} catch (e) {
console.warn(e)
} finally {
// Tell the application to render
await SplashScreen.hideAsync()
setAppIsReady(true)
}
}
prepare()
}, [fontsLoaded])
const onLayoutRootView = useCallback(async () => {
if (appIsReady) {
// This tells the splash screen to hide immediately! If we call this after
// `setAppIsReady`, then we may see a blank screen while the app is
// loading its initial state and rendering its first pixels. So instead,
// we hide the splash screen once we know the root view has already
// performed layout.
await SplashScreen.hideAsync()
}
}, [appIsReady])
if (!appIsReady) {
return null
}
return (
<NavigationContainer>
<QueryClientProvider client={queryClient}>
<ThemeProvider>
<View
style={{
flex: 1,
justifyContent: 'center',
alignContent: 'center',
height: '100%',
backgroundColor: theme.colors.grey2
}}
onLayout={onLayoutRootView}
>
<Stack.Navigator
screenOptions={{
headerStyle: { backgroundColor: `${theme.colors.secondary}` },
headerTintColor: '#fff',
headerTitleStyle: { fontWeight: 'bold' }
}}
>
<Stack.Screen name="CityPop" component={Screens} />
<Stack.Screen name="Details" component={City} />
</Stack.Navigator>
</View>
</ThemeProvider>
</QueryClientProvider>
</NavigationContainer>
)
}