-
Notifications
You must be signed in to change notification settings - Fork 5
/
App.js
99 lines (89 loc) · 2.96 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import React, { Component } from "react";
import PropTypes from "prop-types";
import { Provider } from "react-redux";
import { PersistGate } from "redux-persist/es/integration/react";
import { Platform, StatusBar, View } from "react-native";
import { AppLoading, Asset, Font, Notifications } from "expo";
import { Feather } from "@expo/vector-icons";
import Sentry from "sentry-expo";
import { NotificationChannels } from "./constants/notificationsConstants";
import configureStore from "./configureStore";
import RootNavigation from "./navigation/RootNavigation";
import Styles from "./styles/Containers";
if (!__DEV__) {
Sentry.config(
"https://51d1644cf70f40b9af7d1e1416dac247@sentry.io/300408",
).install();
}
class App extends Component {
static propTypes = {
skipLoadingScreen: PropTypes.bool,
};
static defaultProps = {
skipLoadingScreen: false,
};
constructor(props) {
super(props);
this.state = {
isLoadingComplete: false,
store: configureStore(),
};
}
componentDidMount() {
if (Platform.OS === "android") {
Object.keys(NotificationChannels).forEach(key => {
const channel = NotificationChannels[key];
Notifications.createChannelAndroidAsync(channel.id, channel.options);
});
}
}
loadResourcesAsync = async () =>
Promise.all([
Asset.loadAsync([
require("./assets/images/undraw_calendar.png"),
require("./assets/images/undraw_relaxation.png"),
require("./assets/images/undraw_graduation.png"),
require("./assets/images/undraw_building_blocks.png"),
]),
Font.loadAsync({
// This is the font that we are using for our tab bar
...Feather.font,
// We include SpaceMono because we use it in HomeScreen.js. Feel free
// to remove this if you are not using it in your app
"space-mono": require("./assets/fonts/SpaceMono-Regular.ttf"),
apercu: require("./assets/fonts/somerandomfont.otf"),
"apercu-bold": require("./assets/fonts/somerandomfont-Bold.otf"),
"apercu-light": require("./assets/fonts/somerandomfont-Light.otf"),
}),
]);
handleLoadingError = error => {
// TODO: Setup remote error logging
console.warn(error); // eslint-disable-line no-console
};
handleFinishLoading = () => {
this.setState({ isLoadingComplete: true });
};
render() {
if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
return (
<AppLoading
startAsync={this.loadResourcesAsync}
onError={this.handleLoadingError}
onFinish={this.handleFinishLoading}
/>
);
}
const { store, persistor } = this.state.store;
return (
<Provider store={store}>
<PersistGate persistor={persistor}>
<View style={Styles.app}>
<StatusBar barStyle="light-content" hidden={false} />
<RootNavigation />
</View>
</PersistGate>
</Provider>
);
}
}
export default App;