@@ -3,15 +3,17 @@ import PropTypes from 'prop-types';
3
3
import { connect } from 'react-redux' ;
4
4
import ReduxToastr from 'react-redux-toastr' ;
5
5
import { HashRouter as Router , Route , Switch } from 'react-router-dom' ;
6
- import { MuiThemeProvider , createMuiTheme } from '@material-ui/core/styles' ;
6
+ import { MuiThemeProvider } from '@material-ui/core/styles' ;
7
7
import { withTranslation } from 'react-i18next' ;
8
+ import { Detector } from 'react-detect-offline' ;
8
9
import Home from './Home' ;
9
10
import VisitSpace from './components/VisitSpace' ;
10
11
import SpacesNearby from './components/SpacesNearby' ;
11
12
import Settings from './components/Settings' ;
12
13
import LoadSpace from './components/LoadSpace' ;
13
14
import SpaceScreen from './components/space/SpaceScreen' ;
14
15
import DeveloperScreen from './components/developer/DeveloperScreen' ;
16
+ import { OnlineTheme , OfflineTheme } from './themes' ;
15
17
import {
16
18
SETTINGS_PATH ,
17
19
SPACE_PATH ,
@@ -31,16 +33,6 @@ import {
31
33
import { DEFAULT_LANGUAGE } from './config/constants' ;
32
34
import './App.css' ;
33
35
34
- const theme = createMuiTheme ( {
35
- typography : {
36
- useNextVariants : true ,
37
- } ,
38
- palette : {
39
- primary : { light : '#5050d2' , main : '#5050d2' , dark : '#5050d2' } ,
40
- secondary : { light : '#eeeeee' , main : '#eeeeee' , dark : '#eeeeee' } ,
41
- } ,
42
- } ) ;
43
-
44
36
export class App extends Component {
45
37
state = { height : 0 } ;
46
38
@@ -107,29 +99,42 @@ export class App extends Component {
107
99
108
100
render ( ) {
109
101
const { height } = this . state ;
102
+
110
103
return (
111
- < MuiThemeProvider theme = { theme } >
112
- < div >
113
- < ReduxToastr
114
- transitionIn = "fadeIn"
115
- preventDuplicates
116
- transitionOut = "fadeOut"
117
- />
118
- </ div >
119
- < Router >
120
- < div className = "app" style = { { height } } >
121
- < Switch >
122
- < Route exact path = { HOME_PATH } component = { Home } />
123
- < Route exact path = { SPACES_NEARBY_PATH } component = { SpacesNearby } />
124
- < Route exact path = { VISIT_PATH } component = { VisitSpace } />
125
- < Route exact path = { LOAD_SPACE_PATH } component = { LoadSpace } />
126
- < Route exact path = { SETTINGS_PATH } component = { Settings } />
127
- < Route exact path = { SPACE_PATH } component = { SpaceScreen } />
128
- < Route exact path = { DEVELOPER_PATH } component = { DeveloperScreen } />
129
- </ Switch >
130
- </ div >
131
- </ Router >
132
- </ MuiThemeProvider >
104
+ < Detector
105
+ render = { ( { online } ) => (
106
+ < MuiThemeProvider theme = { online ? OnlineTheme : OfflineTheme } >
107
+ < div >
108
+ < ReduxToastr
109
+ transitionIn = "fadeIn"
110
+ preventDuplicates
111
+ transitionOut = "fadeOut"
112
+ />
113
+ </ div >
114
+ < Router >
115
+ < div className = "app" style = { { height } } >
116
+ < Switch >
117
+ < Route exact path = { HOME_PATH } component = { Home } />
118
+ < Route
119
+ exact
120
+ path = { SPACES_NEARBY_PATH }
121
+ component = { SpacesNearby }
122
+ />
123
+ < Route exact path = { VISIT_PATH } component = { VisitSpace } />
124
+ < Route exact path = { LOAD_SPACE_PATH } component = { LoadSpace } />
125
+ < Route exact path = { SETTINGS_PATH } component = { Settings } />
126
+ < Route exact path = { SPACE_PATH } component = { SpaceScreen } />
127
+ < Route
128
+ exact
129
+ path = { DEVELOPER_PATH }
130
+ component = { DeveloperScreen }
131
+ />
132
+ </ Switch >
133
+ </ div >
134
+ </ Router >
135
+ </ MuiThemeProvider >
136
+ ) }
137
+ />
133
138
) ;
134
139
}
135
140
}
@@ -147,10 +152,7 @@ const mapDispatchToProps = {
147
152
dispatchGetGeolocationEnabled : getGeolocationEnabled ,
148
153
} ;
149
154
150
- const ConnectedApp = connect (
151
- mapStateToProps ,
152
- mapDispatchToProps
153
- ) ( App ) ;
155
+ const ConnectedApp = connect ( mapStateToProps , mapDispatchToProps ) ( App ) ;
154
156
155
157
const TranslatedApp = withTranslation ( ) ( ConnectedApp ) ;
156
158
0 commit comments