-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
75 lines (65 loc) · 1.82 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
import 'expo-dev-client';
import * as SystemUI from 'expo-system-ui';
import 'react-native-gesture-handler';
import 'react-native-url-polyfill/auto';
import {
Poppins_300Light,
Poppins_400Regular,
Poppins_500Medium,
Poppins_600SemiBold,
Poppins_700Bold,
Poppins_800ExtraBold,
Poppins_900Black,
useFonts,
} from '@expo-google-fonts/poppins';
import { NavigationContainer } from '@react-navigation/native';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { StatusBar } from 'expo-status-bar';
import { useEffect, useState } from 'react';
import Loading from './src/components/Loading';
import { FirebaseAuthProvider } from './src/contexts/useFirebaseAuth';
import { init } from './src/database/database';
import Routes from './src/routes';
export default function App() {
const [dbInitialized, setDbInitialized] = useState(false);
const [fontsLoaded] = useFonts({
Poppins_300Light,
Poppins_400Regular,
Poppins_500Medium,
Poppins_600SemiBold,
Poppins_700Bold,
Poppins_800ExtraBold,
Poppins_900Black,
});
const queryClient = new QueryClient();
async function initializeDatabase() {
try {
await init();
} catch (error) {
setDbInitialized(false);
console.log(error);
} finally {
setDbInitialized(true);
}
}
async function SetBackgroundColor() {
await SystemUI.setBackgroundColorAsync('#F50057');
}
useEffect(() => {
initializeDatabase();
SetBackgroundColor();
}, []);
if (!fontsLoaded || !dbInitialized) {
return <Loading />;
}
return (
<QueryClientProvider client={queryClient}>
<NavigationContainer>
<FirebaseAuthProvider>
<StatusBar style="dark" />
<Routes />
</FirebaseAuthProvider>
</NavigationContainer>
</QueryClientProvider>
);
}