-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
87 lines (78 loc) · 2.29 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
import { StatusBar } from "expo-status-bar";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import Home from "screens/Home";
import { Provider } from "react-redux";
import store from "store";
import {
PaperProvider,
MD3LightTheme as DefaultTheme,
} from "react-native-paper";
import { RootSiblingParent } from "react-native-root-siblings";
import fonts from "config/fonts";
import * as Font from "expo-font";
import * as SplashScreen from "expo-splash-screen";
import { useCallback, useEffect, useState } from "react";
import { Album } from "screens";
import { RootStackParamList } from "types";
export default function App() {
const [isReady, setIsReady] = useState(false);
const loadAssets = async () => {
await Font.loadAsync({
"Roboto-Bold": require("./src/assets/fonts/Roboto_Bold.ttf"),
"Roboto-Medium": require("./src/assets/fonts/Roboto_Medium.ttf"),
"Roboto-Regular": require("./src/assets/fonts/Roboto_Regular.ttf"),
Pacifico: require("./src/assets/fonts/Pacifico.ttf"),
});
};
const Stack = createNativeStackNavigator<RootStackParamList>();
const theme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
},
};
useEffect(() => {
const prepare = async () => {
try {
await loadAssets();
} catch (error) {
console.warn(error);
} finally {
setIsReady(true);
}
};
prepare();
}, []);
useCallback(async () => {
if (isReady) {
await SplashScreen.hideAsync();
}
}, [isReady]);
if (!isReady) {
return null;
}
return (
<PaperProvider theme={{ ...theme, fonts }}>
<Provider store={store}>
<RootSiblingParent>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Home"
component={Home}
options={{ headerShown: false }}
/>
<Stack.Screen
name="Album"
component={Album}
options={{ headerShown: false }}
/>
</Stack.Navigator>
<StatusBar style="auto" />
</NavigationContainer>
</RootSiblingParent>
</Provider>
</PaperProvider>
);
}