-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
118 lines (109 loc) · 3.09 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import React, { useCallback, useEffect, useState } from "react";
import { NativeBaseProvider, Box, extendTheme } from "native-base";
import { StatusBar, View } from "react-native";
import "react-native-gesture-handler";
import StackNavigator from "./app/navigation/StackNavigator";
import { NavigationContainer } from '@react-navigation/native';
import * as SplashScreen from 'expo-splash-screen';
import useFont from "./app/hooks/useFont";
import { AuthContextProvider } from "./app/context/AuthContext";
import { DataContextProvider } from "./app/context/DataContext";
export default function App() {
const [appIsReady, setAppIsReady] = useState(false);
const defaultTheme = extendTheme();
const [theme, setTheme] = useState(defaultTheme);
useEffect(() => {
async function prepare() {
try {
await SplashScreen.preventAutoHideAsync();
await useFont();
} catch (e) {
console.warn("Errror", e);
} finally {
setAppIsReady(true);
}
}
prepare();
}, []);
const onLayoutRootView = useCallback(async () => {
if (appIsReady) {
const theme = extendTheme({
colors: {
primary: {
50: "#DE2A26",
100: '#DE2A26',
200: '#DE2A26',
300: '#DE2A26',
400: '#DE2A26',
500: '#DE2A26',
600: '#DE2A26',
700: '#DE2A26',
800: '#DE2A26',
900: '#DE2A26',
}
},
fontConfig: {
Poppins: {
100: {
normal: "Poppins-Light",
italic: "Poppins-LightItalic",
},
200: {
normal: "Poppins-Light",
italic: "Poppins-LightItalic",
},
300: {
normal: "Poppins-Light",
italic: "Poppins-LightItalic",
},
400: {
normal: "Poppins-Regular",
},
500: {
normal: "Poppins-Medium",
},
600: {
normal: "Poppins-Medium",
italic: "Poppins-MediumItalic",
},
700: {
normal: 'Poppins-Bold',
},
800: {
normal: 'Poppins-Bold',
italic: 'Poppins-BoldItalic',
},
900: {
normal: 'Poppins-Bold',
italic: 'Poppins-BoldItalic',
},
},
},
fonts: {
heading: "Poppins",
body: "Poppins",
mono: "Poppins",
},
});
setTheme(theme);
await SplashScreen.hideAsync();
}
}, [appIsReady]);
if (!appIsReady) {
return null;
}
return (
<View style={{ flex: 1 }} onLayout={onLayoutRootView}>
<NativeBaseProvider theme={theme}>
<AuthContextProvider>
<DataContextProvider>
<NavigationContainer>
<StatusBar barStyle={"default"} />
<StackNavigator />
</NavigationContainer>
</DataContextProvider>
</AuthContextProvider>
</NativeBaseProvider>
</View>
);
}