-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.tsx
98 lines (86 loc) · 2.64 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
import "react-native-gesture-handler";
import { StatusBar } from "expo-status-bar";
import React from "react";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { Platform, View } from "react-native";
import useCachedResources from "./hooks/useCachedResources";
import useColorScheme from "./hooks/useColorScheme";
import Template from "./screens";
import { default as mapping } from "./assets/mapping.json";
import * as eva from "@eva-design/eva";
import { ApplicationProvider, IconRegistry } from "@ui-kitten/components";
import { EvaIconsPack } from "@ui-kitten/eva-icons";
import ApiContext, { MainApiContext } from "./contexts/ApiContexts";
import { positions, Provider as AlertProvider } from "react-alert";
import AlertTemplate from "react-alert-template-basic";
const options = {
timeout: 3000,
position: positions.TOP_RIGHT,
};
import "react-loader-spinner/dist/loader/css/react-spinner-loader.css";
import Loader from "react-loader-spinner";
export default function App() {
injectWebCss();
const isLoadingComplete = useCachedResources();
const colorScheme = useColorScheme();
return (
<>
<AlertProvider template={AlertTemplate} {...options}>
<IconRegistry icons={EvaIconsPack} />
<SafeAreaProvider>
<ApiContext>
<AppWithLoading colorScheme={colorScheme} />
</ApiContext>
</SafeAreaProvider>
</AlertProvider>
</>
);
}
const AppWithLoading = ({ colorScheme }) => {
const isLoadingComplete = useCachedResources();
const { settings } = React.useContext(MainApiContext);
if (!isLoadingComplete || !settings?.theme?.colors) {
return (
<View
style={{
width: "100%",
height: "100%",
justifyContent: "center",
alignItems: "center",
backgroundColor: "rgba(0,0,0,0.2)",
}}
>
<Loader type="Bars" color="white" height={60} width={150} />
</View>
);
} else {
return (
<ApplicationProvider
{...eva}
theme={{ ...eva.light, ...(settings.theme?.colors || {}) }}
customMapping={mapping}
>
<Template colorScheme={colorScheme} />
<StatusBar />
</ApplicationProvider>
);
}
};
const noGlow = `
textarea, select, input, button {
-webkit-appearance: none;
outline: none!important;
}
textarea:focus, select:focus, input:focus, button:focus {
-webkit-appearance: none;
outline: none!important;
}
`;
const injectWebCss = () => {
// Only on web
if (Platform.OS != "web") return;
// Inject style
const style = document.createElement("style");
style.textContent = noGlow;
return document.head.append(style);
};