-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathApp.jsx
More file actions
89 lines (76 loc) · 2.34 KB
/
App.jsx
File metadata and controls
89 lines (76 loc) · 2.34 KB
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
import React, { Component } from 'react'
import { ActivityIndicator, NativeModules, View, LogBox } from 'react-native'
import { applyMiddleware, combineReducers, createStore } from 'redux'
import { getTheme, ThemeContext } from 'react-native-material-ui'
import * as Analytics from 'expo-firebase-analytics'
import { loadAsync } from 'expo-font'
import { Provider } from 'react-redux'
import thunk from 'redux-thunk'
import { setCustomText } from 'react-native-global-props'
import { activity } from './src/shared/styles'
import { initApp, initTheme } from './src/database/db'
import Router from './src/router'
import tasksReducer from './src/store/reducers/tasks'
import listsReducer from './src/store/reducers/lists'
import cateReducer from './src/store/reducers/categories'
import themeReducer from './src/store/reducers/theme'
import profileReducer from './src/store/reducers/profile'
import settingsReducer from './src/store/reducers/settings'
import configReducer from './src/store/reducers/config'
const { UIManager } = NativeModules
const rootReducer = combineReducers({
tasks: tasksReducer,
lists: listsReducer,
categories: cateReducer,
theme: themeReducer,
profile: profileReducer,
settings: settingsReducer,
config: configReducer,
})
export const store = createStore(rootReducer, applyMiddleware(thunk))
class App extends Component {
state = {
uiTheme: false,
ready: false,
}
async componentDidMount() {
await loadAsync({
Ubuntu: require('./src/assets/fonts/Ubuntu.ttf'),
})
// Setting default styles for all Text components.
const customTextProps = {
style: { fontFamily: 'Ubuntu' },
}
setCustomText(customTextProps)
initApp(() => {
initTheme((state) => {
Analytics.logEvent('successStartedApp', {
name: 'startedApp',
})
this.setState(state)
})
})
}
UNSAFE_componentWillMount() {
if (UIManager.setLayoutAnimationEnabledExperimental) {
UIManager.setLayoutAnimationEnabledExperimental(true)
}
}
render() {
const { uiTheme, ready } = this.state
// TODO: only ignore known logs
LogBox.ignoreAllLogs(true)
return ready ? (
<Provider store={store}>
<ThemeContext.Provider value={getTheme(uiTheme)}>
<Router />
</ThemeContext.Provider>
</Provider>
) : (
<View style={activity}>
<ActivityIndicator size='large' color='#f4511e' />
</View>
)
}
}
export default App