-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathApp.tsx
63 lines (56 loc) · 2.15 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
import { BottomSheetModalProvider } from "@gorhom/bottom-sheet";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import quarterOfYear from "dayjs/plugin/quarterOfYear";
import utc from "dayjs/plugin/utc";
import * as Font from "expo-font";
import { StatusBar } from "expo-status-bar";
import React, { useEffect, useState } from "react";
import ErrorBoundary from "react-native-error-boundary";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { ToastBannerProvider, ToastBannerPresenter } from "react-native-toast-banner";
import { SplashtagContext, useTheme } from "./components";
import "./i18n";
import { ok } from "./utils/promise";
import { ErrorView, MainView } from "./views";
dayjs.extend(duration);
dayjs.extend(quarterOfYear);
dayjs.extend(utc);
const App = () => {
const theme = useTheme();
const [fontsLoaded] = Font.useFonts({
Lucide: require("lucide-static/font/lucide.ttf"),
MPLUSRounded1cExtraBold: require("@expo-google-fonts/m-plus-rounded-1c/MPLUSRounded1c_800ExtraBold.ttf"),
});
const [splatfont, setSplatfont] = useState(false);
useEffect(() => {
ok(
// HACK: use jsDelivr to avoid any network issue in China Mainland.
Font.loadAsync({
Splatfont:
"https://cdn.jsdelivr.net/gh/frozenpandaman/frozenpandaman.github.io/Splatoon1.otf",
})
).then((res) => {
setSplatfont(res);
});
});
return (
<SafeAreaProvider style={theme.backgroundStyle}>
<ErrorBoundary FallbackComponent={ErrorView}>
<StatusBar style={theme.colorScheme === "light" ? "dark" : "light"} />
<ToastBannerProvider>
<SplashtagContext.Provider value={{ splatfont }}>
<GestureHandlerRootView style={{ flex: 1 }}>
<BottomSheetModalProvider>
{fontsLoaded && <MainView />}
<ToastBannerPresenter />
</BottomSheetModalProvider>
</GestureHandlerRootView>
</SplashtagContext.Provider>
</ToastBannerProvider>
</ErrorBoundary>
</SafeAreaProvider>
);
};
export default App;