-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
80 lines (67 loc) · 2.04 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
// modules
import { StatusBar } from 'expo-status-bar';
import React, { useState, useEffect } from 'react';
import { StyleSheet, Text, View, SafeAreaView, Pressable } from 'react-native';
import { AppLoading } from 'expo'
import { createStore, combineReducers } from 'redux'
import { Provider } from 'react-redux'
import {
useFonts,
PoiretOne_400Regular
} from '@expo-google-fonts/poiret-one'
import { persistStore, persistReducer } from 'redux-persist'
import AsyncStorage from '@react-native-async-storage/async-storage'
import * as ScreenOrientation from 'expo-screen-orientation'
import stockReducer from './utils/StockReducer'
import cocktailReducer from './utils/CocktailReducer'
import uiReducer from './utils/UIReducer'
// components
import Main from './components/Main'
const persistConfig = {
key: 'root',
storage: AsyncStorage
}
const persistedReducer = persistReducer(persistConfig, combineReducers({
stock: stockReducer,
cocktails: cocktailReducer,
ui: uiReducer
}))
const store = createStore(persistedReducer)
const persistor = persistStore(store)
export default function App(props) {
const [ui, setUI] = useState({})
let [fontsLoaded] = useFonts({
PoiretOne_400Regular,
})
var state = store.getState()
useEffect(()=>{
setUI(state.ui)
},[state])
store.subscribe(()=>{
state = store.getState()
setUI(state.ui)
})
// attempt to lock orientation for iPad
ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT_UP)
// console.log('\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nloading...', ui.tutorial_complete)
if(!fontsLoaded){
return <AppLoading
onFinish={() => console.log('finished loading AppLoading')}
onError={console.warn}
/>
} else {
return (
<Provider store={store}>
<SafeAreaView style={[styles.container, { fontFamily: 'PoiretOne_400Regular' }, ui.current_theme]}>
<Main></Main>
</SafeAreaView>
</Provider>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
position: 'relative'
},
});