-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.tsx
55 lines (50 loc) · 1.71 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
import React, { useEffect } from "react";
import { SafeAreaProvider } from "react-native-safe-area-context";
import useCachedResources from "./src/hooks/useCachedResources";
import { NavigationContainer, DefaultTheme } from "@react-navigation/native";
import {
Provider as PaperProvider,
DefaultTheme as PaperLightTheme,
DarkTheme as PaperDarkTheme,
} from "react-native-paper";
import { Provider as ReactReduxProvider } from "react-redux";
import rootReducer from "./src/slices/rootSlice";
import { applyMiddleware, createStore } from "redux";
import createSagaMiddleware from "redux-saga";
import rootWatcher from "./src/sagas/rootSaga";
import InsideApp from "./src/InsideApp";
export default function App() {
const isLoadingComplete = useCachedResources();
const [theme, setTheme] = React.useState(DefaultTheme);
const sagaMiddleware = createSagaMiddleware();
const store = createStore(rootReducer, applyMiddleware(sagaMiddleware));
sagaMiddleware.run(rootWatcher);
useEffect(() => {
console.log("isLoadingComplete:", isLoadingComplete);
}, [isLoadingComplete]);
const paperTheme = React.useMemo(() => {
const t = theme.dark ? PaperDarkTheme : PaperLightTheme;
return {
...t,
colors: {
...t.colors,
...theme.colors,
surface: theme.colors.card,
accent: theme.dark ? "rgb(255, 55, 95)" : "rgb(255, 45, 85)",
},
};
}, [theme.colors, theme.dark]);
if (!isLoadingComplete) {
return null;
} else {
return (
<SafeAreaProvider>
<ReactReduxProvider store={store}>
<PaperProvider theme={paperTheme}>
<InsideApp />
</PaperProvider>
</ReactReduxProvider>
</SafeAreaProvider>
);
}
}