@@ -7,6 +7,7 @@ import { withStyles } from '@material-ui/core';
7
7
import { withTranslation } from 'react-i18next' ;
8
8
import WifiIcon from '@material-ui/icons/Wifi' ;
9
9
import WifiOffIcon from '@material-ui/icons/WifiOff' ;
10
+ import { MuiThemeProvider } from '@material-ui/core/styles' ;
10
11
import Home from './Home' ;
11
12
import VisitSpace from './components/VisitSpace' ;
12
13
import SpacesNearby from './components/SpacesNearby' ;
@@ -22,6 +23,7 @@ import SignInScreen from './components/signin/SignInScreen';
22
23
import Authorization from './components/Authorization' ;
23
24
import Classrooms from './components/classrooms/Classrooms' ;
24
25
import ImportDataScreen from './components/classrooms/ImportDataScreen' ;
26
+ import { OnlineTheme , OfflineTheme } from './themes' ;
25
27
import {
26
28
SETTINGS_PATH ,
27
29
SYNC_SPACE_PATH ,
@@ -81,6 +83,7 @@ export class App extends Component {
81
83
toastrIcon : PropTypes . string . isRequired ,
82
84
} ) . isRequired ,
83
85
connexionStatus : PropTypes . bool . isRequired ,
86
+ userMode : PropTypes . oneOf ( USER_MODES ) . isRequired ,
84
87
} ;
85
88
86
89
static defaultProps = {
@@ -155,86 +158,93 @@ export class App extends Component {
155
158
156
159
render ( ) {
157
160
const { height } = this . state ;
161
+ const { userMode, connexionStatus } = this . props ;
158
162
159
163
return (
160
- < Router >
161
- < div className = "app" style = { { height } } >
162
- < Switch >
163
- < Route exact path = { SIGN_IN_PATH } component = { SignInScreen } />
164
- < Route exact path = { HOME_PATH } component = { Authorization ( ) ( Home ) } />
165
- < Route
166
- exact
167
- path = { SAVED_SPACES_PATH }
168
- component = { Authorization ( ) ( SavedSpaces ) }
169
- />
170
- < Route
171
- exact
172
- path = { SPACES_NEARBY_PATH }
173
- component = { Authorization ( ) ( SpacesNearby ) }
174
- />
175
- < Route
176
- exact
177
- path = { VISIT_PATH }
178
- component = { Authorization ( ) ( VisitSpace ) }
179
- />
180
- < Route
181
- exact
182
- path = { LOAD_SPACE_PATH }
183
- component = { Authorization ( ) ( LoadSpace ) }
184
- />
185
- < Route
186
- exact
187
- path = { LOAD_SELECTION_SPACE_PATH }
188
- component = { Authorization ( ) ( LoadSelectionScreen ) }
189
- />
190
- < Route
191
- exact
192
- path = { SETTINGS_PATH }
193
- component = { Authorization ( ) ( Settings ) }
194
- />
195
- < Route
196
- exact
197
- path = { SYNC_SPACE_PATH }
198
- component = { Authorization ( ) ( SyncScreen ) }
199
- />
200
- < Route
201
- exact
202
- path = { buildExportSelectionPathForSpaceId ( ) }
203
- component = { Authorization ( ) ( ExportSelectionScreen ) }
204
- />
205
- < Route
206
- exact
207
- path = { SPACE_PATH }
208
- component = { Authorization ( ) ( SpaceScreen ) }
209
- />
210
- < Route
211
- exact
212
- path = { DASHBOARD_PATH }
213
- component = { Authorization ( ) ( Dashboard ) }
214
- />
215
- < Route
216
- exact
217
- path = { buildClassroomPath ( ) }
218
- component = { Authorization ( [ USER_MODES . TEACHER ] ) ( ClassroomScreen ) }
219
- />
220
- < Route
221
- exact
222
- path = { CLASSROOMS_PATH }
223
- component = { Authorization ( [ USER_MODES . TEACHER ] ) ( Classrooms ) }
224
- />
225
- < Route
226
- exact
227
- path = { buildImportDataInClassroomPath ( ) }
228
- component = { Authorization ( [ USER_MODES . TEACHER ] ) ( ImportDataScreen ) }
229
- />
230
- < Route
231
- exact
232
- path = { DEVELOPER_PATH }
233
- component = { Authorization ( ) ( DeveloperScreen ) }
234
- />
235
- </ Switch >
236
- </ div >
237
- </ Router >
164
+ < MuiThemeProvider
165
+ theme = { connexionStatus ? OnlineTheme ( userMode ) : OfflineTheme }
166
+ >
167
+ < Router >
168
+ < div className = "app" style = { { height } } >
169
+ < Switch >
170
+ < Route exact path = { SIGN_IN_PATH } component = { SignInScreen } />
171
+ < Route exact path = { HOME_PATH } component = { Authorization ( ) ( Home ) } />
172
+ < Route
173
+ exact
174
+ path = { SAVED_SPACES_PATH }
175
+ component = { Authorization ( ) ( SavedSpaces ) }
176
+ />
177
+ < Route
178
+ exact
179
+ path = { SPACES_NEARBY_PATH }
180
+ component = { Authorization ( ) ( SpacesNearby ) }
181
+ />
182
+ < Route
183
+ exact
184
+ path = { VISIT_PATH }
185
+ component = { Authorization ( ) ( VisitSpace ) }
186
+ />
187
+ < Route
188
+ exact
189
+ path = { LOAD_SPACE_PATH }
190
+ component = { Authorization ( ) ( LoadSpace ) }
191
+ />
192
+ < Route
193
+ exact
194
+ path = { LOAD_SELECTION_SPACE_PATH }
195
+ component = { Authorization ( ) ( LoadSelectionScreen ) }
196
+ />
197
+ < Route
198
+ exact
199
+ path = { SETTINGS_PATH }
200
+ component = { Authorization ( ) ( Settings ) }
201
+ />
202
+ < Route
203
+ exact
204
+ path = { SYNC_SPACE_PATH }
205
+ component = { Authorization ( ) ( SyncScreen ) }
206
+ />
207
+ < Route
208
+ exact
209
+ path = { buildExportSelectionPathForSpaceId ( ) }
210
+ component = { Authorization ( ) ( ExportSelectionScreen ) }
211
+ />
212
+ < Route
213
+ exact
214
+ path = { SPACE_PATH }
215
+ component = { Authorization ( ) ( SpaceScreen ) }
216
+ />
217
+ < Route
218
+ exact
219
+ path = { DASHBOARD_PATH }
220
+ component = { Authorization ( ) ( Dashboard ) }
221
+ />
222
+ < Route
223
+ exact
224
+ path = { buildClassroomPath ( ) }
225
+ component = { Authorization ( [ USER_MODES . TEACHER ] ) ( ClassroomScreen ) }
226
+ />
227
+ < Route
228
+ exact
229
+ path = { CLASSROOMS_PATH }
230
+ component = { Authorization ( [ USER_MODES . TEACHER ] ) ( Classrooms ) }
231
+ />
232
+ < Route
233
+ exact
234
+ path = { buildImportDataInClassroomPath ( ) }
235
+ component = { Authorization ( [ USER_MODES . TEACHER ] ) (
236
+ ImportDataScreen
237
+ ) }
238
+ />
239
+ < Route
240
+ exact
241
+ path = { DEVELOPER_PATH }
242
+ component = { Authorization ( ) ( DeveloperScreen ) }
243
+ />
244
+ </ Switch >
245
+ </ div >
246
+ </ Router >
247
+ </ MuiThemeProvider >
238
248
) ;
239
249
}
240
250
}
@@ -246,6 +256,7 @@ const mapStateToProps = ({ authentication }) => ({
246
256
'settings' ,
247
257
'geolocationEnabled' ,
248
258
] ) ,
259
+ userMode : authentication . getIn ( [ 'user' , 'settings' , 'userMode' ] ) ,
249
260
} ) ;
250
261
251
262
const mapDispatchToProps = {
0 commit comments