-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
76 lines (66 loc) · 2.13 KB
/
App.js
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
import React from "react";
import { KeyboardAvoidingView } from "react-native";
import { Provider } from "react-redux";
import { configureStore } from "@reduxjs/toolkit";
import { Provider as PaperProvider, ThemeProvider } from "react-native-paper";
import { StatusBar } from "expo-status-bar";
import ErrorBoundary from "react-native-error-boundary";
import { AppConfirmDialog } from "appComponents/AppConfirmDialog";
import { AppMessageDialog } from "appComponents/AppMessageDialog";
import { JobMonitorDialog } from "appComponents/JobMonitorDialog";
import { AppToast } from "appComponents/AppToast";
import { ErrorFallbackComponent } from "appComponents/ErrorFallbackComponent";
import { AppStack } from "navigation/AppStack";
import { rootReducer } from "state/reducers";
import { useEffectiveTheme } from "hooks";
import { BaseStyles, Environment } from "utils";
import { AppInitializer } from "./src/AppInitializer";
const store = configureStore({ reducer: rootReducer });
const AppInnerContainer = () => {
if (__DEV__) {
console.log(`rendering AppInnerContainer`);
}
const theme = useEffectiveTheme();
const onError = (error, stackTrace) => {
console.log(stackTrace, error);
};
const internalContainer = (
<AppInitializer>
<AppStack />
</AppInitializer>
);
return (
<PaperProvider theme={theme}>
<ThemeProvider theme={theme}>
<ErrorBoundary
onError={onError}
FallbackComponent={ErrorFallbackComponent}
>
<StatusBar style={theme.dark ? "light" : "dark"} />
{Environment.isIOS ? (
<KeyboardAvoidingView behavior="height" style={BaseStyles.flexOne}>
{internalContainer}
</KeyboardAvoidingView>
) : (
internalContainer
)}
</ErrorBoundary>
<AppMessageDialog />
<AppConfirmDialog />
<JobMonitorDialog />
<AppToast />
</ThemeProvider>
</PaperProvider>
);
};
const App = () => {
if (__DEV__) {
console.log(`rendering App`);
}
return (
<Provider store={store}>
<AppInnerContainer />
</Provider>
);
};
export default App;