-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
60 lines (53 loc) · 1.79 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
import 'react-native-gesture-handler';
import 'react-native-reanimated';
import React, { useState, useEffect, useCallback } from 'react';
import { ThemeProvider } from 'styled-components/native';
import { preventAutoHideAsync, hideAsync } from 'expo-splash-screen';
import * as Font from 'expo-font';
import { View, LogBox, useColorScheme,} from 'react-native';
import Router from './src/router';
import { StatusBar } from 'expo-status-bar';
import light from '@theme/light';
import dark from '@theme/dark';
preventAutoHideAsync();
export default function App() {
const [appIsReady, setAppIsReady] = useState(false);
const theme = useColorScheme();
const selectTheme = theme === 'light' ? light : dark;
useEffect(() => {
LogBox.ignoreAllLogs(true);
//caregamento das fontes local
async function loadResourcesAndDataAsync() {
try {
await Font.loadAsync({
Font_Book: require('./assets/fonts/Inter_Book.ttf'),
Font_Medium: require('./assets/fonts/Inter_Medium.ttf'),
Font_Bold: require('./assets/fonts/Inter_Bold.ttf'),
Font_Black: require('./assets/fonts/Inter_Black.ttf'),
Voyage_Medium: require('./assets/fonts/Voyage_Medium.otf'),
Voyage_Book: require('./assets/fonts/Voyage_Book.otf'),
});
setAppIsReady(true);
} catch (e) {
console.warn(e);
}
}
loadResourcesAndDataAsync();
}, []);
const onLayoutRootView = useCallback(async () => {
if (appIsReady) {
await hideAsync();
}
}, [appIsReady]);
if (!appIsReady) {
return null;
}
return (
<View style={{ flex: 1 }} onLayout={onLayoutRootView}>
<ThemeProvider theme={selectTheme}>
<StatusBar translucent animated={true} />
<Router />
</ThemeProvider>
</View>
);
}