-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
65 lines (54 loc) · 2.04 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
import React, {useCallback, useEffect, useState} from 'react';
import * as eva from '@eva-design/eva';
import {ApplicationProvider, IconRegistry, Layout} from '@ui-kitten/components';
import {EvaIconsPack} from '@ui-kitten/eva-icons';
import {NavigationContainer} from "@react-navigation/native";
import DatabaseService from "./src/services/database/DatabaseService";
import DefaultStack from "./src/stacks/default/DefaultStack";
import {Appearance, SafeAreaView, StatusBar} from "react-native";
import * as Sentry from 'sentry-expo';
import * as SplashScreen from 'expo-splash-screen';
import {AssetIconsPack} from "./src/common/AssetIcons";
Sentry.init({
dsn: 'https://[email protected]/5708282',
enableInExpoDevelopment: false
});
export default () => {
return (
<App/>
);
}
const App = () => {
const colorScheme = Appearance.getColorScheme();
const themeStatusBarStyle = colorScheme === 'light' ? 'dark-content' : 'light-content';
const [initialized, setInitialized] = useState(false);
useEffect(() => {
async function initialize() {
await SplashScreen.preventAutoHideAsync();
await DatabaseService.openDatabase();
setInitialized(true);
}
initialize();
}, []);
const onLayoutRootView = useCallback(async () => {
if (initialized) {
await SplashScreen.hideAsync();
}
}, [initialized]);
if (!initialized) {
return null;
}
return (
<NavigationContainer>
<StatusBar barStyle={themeStatusBarStyle}/>
<IconRegistry icons={[EvaIconsPack, AssetIconsPack]}/>
<ApplicationProvider {...eva} theme={colorScheme === 'dark' ? eva.dark : eva.light}>
<Layout style={{flex: 1}} onLayout={onLayoutRootView}>
<SafeAreaView style={{flex: 1}}>
<DefaultStack/>
</SafeAreaView>
</Layout>
</ApplicationProvider>
</NavigationContainer>
)
}