-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
58 lines (50 loc) · 1.5 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
import React, { useState } from "react";
import { SafeAreaView, StatusBar } from "react-native";
import { AppLoading } from "expo";
import * as Font from "expo-font";
import { createStore, combineReducers, applyMiddleware } from 'redux'
import ReduxThunk from 'redux-thunk';
import { Provider } from 'react-redux'
import { init } from './helpers/db'
import scoreReducer from './store/score-reducers'
import historyReducer from './store/history-reducers'
import AppNavigator from "./navigation/AppNavigation";
import Colors from './constants/colors'
init()
.then(() => console.log("initialized DB"))
.catch((err) => console.log("initialized Fail", err));
const fetchFonts = () => {
return Font.loadAsync({
openSans: require("./assets/fonts/OpenSans-Bold.ttf"),
});
};
const rootReducer = combineReducers({
score: scoreReducer,
history: historyReducer
})
const store = createStore(rootReducer, applyMiddleware(ReduxThunk))
export default function App() {
const [isLoaded, setIsLoaded] = useState(false);
if (!isLoaded) {
return (
<SafeAreaView style={{ flex: 1 }}>
<AppLoading
startAsync={fetchFonts}
onFinish={() => setIsLoaded(true)}
onError={(err) => console.log(err)}
/>
</SafeAreaView>
);
}
return (
<Provider store={store} >
<SafeAreaView style={{ flex: 1 }}>
<StatusBar
barStyle='light-content'
backgroundColor={Colors.bgColor}
/>
<AppNavigator />
</SafeAreaView>
</Provider>
);
}