-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
113 lines (102 loc) · 2.81 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import React, { Component, useEffect } from 'react'
import {
createAppContainer,
createDrawerNavigator,
createStackNavigator
} from 'react-navigation'
import { createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import createSagaMiddleware from 'redux-saga'
import SplashScreen from 'react-native-splash-screen'
import { statsMiddleware } from './services/reduxMiddleware/statsMiddleware'
import Chat from './containers/Chat'
import constants from './constants'
import FlashMessage from 'react-native-flash-message'
import Home from './containers/Home'
import Messages from './containers/Messages'
import NavigationDrawer from './containers/NavigationDrawer'
import NavigationService from './services/navigationService'
import PastChat from './containers/PastChat'
import Profile from './containers/Profile'
import ProfileOther from './containers/ProfileOther'
import reducers from './ducks/reducers'
import rootSaga from './ducks/sagas'
const sagaMiddleware = createSagaMiddleware()
const homeStackScreen = createStackNavigator({
[constants.NAVIGATION_NAMES.home]: {
screen: Home
},
[constants.NAVIGATION_NAMES.messages]: {
screen: Messages
},
[constants.NAVIGATION_NAMES.profile]: {
screen: Profile
},
[constants.NAVIGATION_NAMES.profileOther]: {
screen: ProfileOther
}
})
const chatStackScreen = createStackNavigator({
[constants.NAVIGATION_NAMES.chat]: {
screen: Chat
}
})
const pastChatStackScreen = createStackNavigator({
[constants.NAVIGATION_NAMES.pastChat]: {
screen: PastChat
}
})
const MainNavigator = createDrawerNavigator(
{
[constants.NAVIGATION_NAMES.quit]: {
screen: homeStackScreen,
navigationOptions: ({ navigation }) => ({
drawerLockMode: 'locked-closed'
})
},
[constants.NAVIGATION_NAMES.chat]: {
screen: chatStackScreen,
navigationOptions: ({ navigation }) => {
return {
drawerLabel: () => null
}
}
},
[constants.NAVIGATION_NAMES.pastChat]: {
screen: pastChatStackScreen,
navigationOptions: ({ navigation }) => {
return {
drawerLabel: () => null
}
}
}
},
{
contentComponent: function contentComponent (props) {
return <NavigationDrawer {...props} />
}
}
)
const store = createStore(
reducers,
applyMiddleware(statsMiddleware, sagaMiddleware)
)
const Navigation = createAppContainer(MainNavigator)
sagaMiddleware.run(rootSaga)
export default class App extends Component<{}> {
componentDidMount () {
SplashScreen.hide()
}
render () {
return (
<Provider store={store}>
<Navigation
ref={navigatorRef => {
NavigationService.setTopLevelNavigator(navigatorRef)
}}
/>
<FlashMessage position='top' />
</Provider>
)
}
}