hyperspace-desktop-client-w.../src/App.tsx

64 lines
2.1 KiB
TypeScript
Raw Normal View History

2019-03-25 20:53:33 +01:00
import React, { Component } from 'react';
2019-03-30 22:13:49 +01:00
import {MuiThemeProvider, CssBaseline, withStyles } from '@material-ui/core';
import { setHyperspaceTheme, darkMode } from './utilities/themes';
2019-03-26 02:37:02 +01:00
import AppLayout from './components/AppLayout';
import {styles} from './App.styles';
2019-03-27 01:35:30 +01:00
import {Route} from 'react-router-dom';
import AboutPage from './pages/About';
import Settings from './pages/Settings';
import { getUserDefaultBool, getUserDefaultTheme } from './utilities/settings';
2019-03-28 21:46:19 +01:00
import ProfilePage from './pages/ProfilePage';
2019-03-30 22:13:49 +01:00
import HomePage from './pages/Home';
import LocalPage from './pages/Local';
import PublicPage from './pages/Public';
2019-04-01 03:56:41 +02:00
import Conversation from './pages/Conversation';
2019-03-31 22:49:09 +02:00
import NotificationsPage from './pages/Notifications';
2019-04-02 23:28:04 +02:00
import SearchPage from './pages/Search';
2019-04-04 02:01:54 +02:00
import Composer from './pages/Compose';
2019-04-02 23:28:04 +02:00
2019-03-30 22:13:49 +01:00
import {withSnackbar} from 'notistack';
let theme = setHyperspaceTheme(getUserDefaultTheme());
2019-03-28 00:24:52 +01:00
2019-03-25 22:01:39 +01:00
class App extends Component<any, any> {
2019-03-26 02:37:02 +01:00
2019-03-30 22:13:49 +01:00
offline: any;
constructor(props: any) {
super(props);
this.state = {
theme: theme
}
}
componentWillMount() {
let newTheme = darkMode(this.state.theme, getUserDefaultBool('darkModeEnabled'));
this.setState({ theme: newTheme });
}
2019-03-25 20:53:33 +01:00
render() {
2019-03-25 22:01:39 +01:00
const { classes } = this.props;
2019-03-30 22:13:49 +01:00
2019-03-25 20:53:33 +01:00
return (
<MuiThemeProvider theme={this.state.theme}>
2019-03-26 02:37:02 +01:00
<CssBaseline/>
<AppLayout/>
2019-03-30 22:13:49 +01:00
<Route exact path="/" component={HomePage}/>
<Route path="/home" component={HomePage}/>
<Route path="/local" component={LocalPage}/>
<Route path="/public" component={PublicPage}/>
2019-03-27 17:42:04 +01:00
<Route path="/messages"/>
2019-03-31 22:49:09 +02:00
<Route path="/notifications" component={NotificationsPage}/>
2019-03-30 22:13:49 +01:00
<Route path="/profile/:profileId" render={props => <ProfilePage {...props}></ProfilePage>}/>
2019-04-01 03:56:41 +02:00
<Route path="/conversation/:conversationId" component={Conversation}/>
2019-04-02 23:28:04 +02:00
<Route path="/search" component={SearchPage}/>
<Route path="/settings" component={Settings}/>
<Route path="/about" component={AboutPage}/>
2019-04-04 02:01:54 +02:00
<Route path="/compose" component={Composer}/>
2019-03-25 22:01:39 +01:00
</MuiThemeProvider>
2019-03-25 20:53:33 +01:00
);
}
}
2019-03-30 22:13:49 +01:00
export default withStyles(styles)(withSnackbar(App));