-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
86 lines (71 loc) · 2.29 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
import 'react-native-gesture-handler';
import React, { useState } from 'react';
import AppLoading from 'expo-app-loading';
import * as Font from 'expo-font';
import { enableScreens } from 'react-native-screens';
import AppNavigator from './src/navigation/AppNavigator';
//redux
import { createStore, combineReducers, applyMiddleware, compose } from "redux";
import { Provider } from "react-redux";
import ReduxThunk from "redux-thunk";
//Redux-Offline
// import { offline } from "@redux-offline/redux-offline";
// import offlineConfig from "@redux-offline/redux-offldefaultsine/lib/";
//Reducers
import tipsReducer from "./src/store/reducers/tips";
import challengesReducer from "./src/store/reducers/challenge";
import userReducer from "./src/store/reducers/user";
import evaluationReducer from "./src/store/reducers/evaluation";
import recordReducer from './src/store/reducers/record';
import achievementReducer from './src/store/reducers/achievement';
import optionsReducer from './src/store/reducers/options';
import { LOGOUT } from "./src/store/actions/user";
enableScreens();
const fetchFonts = () => {
return Font.loadAsync({
"montserrat": require("./assets/fonts/Montserrat-Regular.ttf"),
"montserrat-bold": require("./assets/fonts/Montserrat-Bold.ttf"),
"open-sans": require("./assets/fonts/OpenSans-Regular.ttf"),
"open-sans-bold": require("./assets/fonts/OpenSans-Bold.ttf"),
});
};
const appReducer = combineReducers({
user: userReducer,
tips: tipsReducer,
challenges: challengesReducer,
evaluation: evaluationReducer,
record: recordReducer,
achievement: achievementReducer,
options: optionsReducer,
});
const rootReducer = (state, action) => {
if (action.type === LOGOUT) {
// for all keys defined in your persistConfig(s)
//AsyncStorage.removeItem('persist:root')
// storage.removeItem('persist:otherKey')
state = undefined;
}
return appReducer(state, action);
};
const store = createStore(
rootReducer,
compose(applyMiddleware(ReduxThunk))
);
export default function App() {
const [fontLoaded, setFontLoaded] = useState(false);
if (!fontLoaded) {
return (
<AppLoading
startAsync={fetchFonts}
onFinish={() => setFontLoaded(true)}
onError={err => console.log(err)}
/>
)
} else {
return (
<Provider store={store}>
<AppNavigator />
</Provider>
);
}
}