-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
101 lines (91 loc) · 2.52 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import React, { useState } from "react";
import { useColorScheme } from "react-native";
import AppLoading from "expo-app-loading";
import { Provider as ReduxProvider } from "react-redux";
import * as Font from "expo-font";
import { MaterialIcons } from "@expo/vector-icons";
import { Provider as PaperProvider, DefaultTheme } from "react-native-paper";
import { SafeAreaProvider } from "react-native-safe-area-context";
import * as SplashScreen from "expo-splash-screen";
import { Colors, darkColors } from "./src/04_external/styles/Colors";
import { rootStore } from "./src/01_entity/redux/store";
import { MainNavigator } from "./src/04_external/navigation/AppNavigator";
declare global {
namespace ReactNativePaper {
interface ThemeColors {
star: string;
secondary: string;
delete: string;
}
interface Theme {
shadow: {};
}
}
}
const theme = {
...DefaultTheme,
roundness: 2,
shadow: {
offset: 1,
},
colors: {
...Colors,
},
};
const themeDark = {
...DefaultTheme,
roundness: 2,
shadow: {
offset: 1,
},
colors: {
...darkColors,
},
};
type OuterProps = { skipLoadingScreen: boolean };
export default function App(props: OuterProps) {
const { skipLoadingScreen } = props;
const [isLoadingComplete, setLoadingComplete] = useState(false);
const scheme = useColorScheme();
const loadResourcesAsync = async () => {
await SplashScreen.preventAutoHideAsync();
await Promise.all([
Font.loadAsync({
...MaterialIcons.font,
// eslint-disable-next-line global-require
"round-mb": require("./src/04_external/assets/font/MPLUSRounded1c-Bold.ttf"),
}),
]);
};
const handleLoadingError = (error: Error) => {
// In this case, you might want to report the error to your error reporting
// service, for example Sentry
// eslint-disable-next-line no-console
console.warn(error);
};
const handleFinishLoading = async () => {
setLoadingComplete(true);
await SplashScreen.hideAsync();
};
if (!isLoadingComplete && !skipLoadingScreen) {
return (
<AppLoading
startAsync={loadResourcesAsync}
onError={handleLoadingError}
onFinish={() => {
handleFinishLoading();
}}
autoHideSplash={false}
/>
);
}
return (
<SafeAreaProvider>
<ReduxProvider store={rootStore}>
<PaperProvider theme={scheme === "dark" ? themeDark : theme}>
<MainNavigator />
</PaperProvider>
</ReduxProvider>
</SafeAreaProvider>
);
}