import React from 'react';
import PropTypes, { instanceOf } from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import Typography from '@material-ui/core/Typography';
import IconButton from '@material-ui/core/IconButton';
import Hidden from '@material-ui/core/Hidden';
import Divider from '@material-ui/core/Divider';
import MenuIcon from '@material-ui/icons/Menu';
import HomeIcon from '@material-ui/icons/Home';
import EmailIcon from '@material-ui/icons/Email';
import PhotoLibraryIcon from '@material-ui/icons/PhotoLibrary';
import AssignmentIcon from '@material-ui/icons/Assignment';
import MapIcon from '@material-ui/icons/Map';
import InfoIcon from '@material-ui/icons/Info';
import ListIcon from '@material-ui/icons/List';
import SlideshowIcon from '@material-ui/icons/Slideshow';
import Home from '../pages/Home';
import ViewMap from '../pages/ViewMap';
import About from '../pages/About';
import Quiz from '../pages/QuizPage';
import Contact from '../pages/Contact';
import SightingList from '../pages/SightingList';
import Report from '../pages/Report';
import CssBaseline from '@material-ui/core/CssBaseline';
import ExpandLess from '@material-ui/icons/ExpandLess';
import ExpandMore from '@material-ui/icons/ExpandMore';
import Collapse from '@material-ui/core/Collapse';
import FlameLinkCollectionGallery from '../components/flamelink/FlameLinkCollectionGallery';
import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';
import ThemeSwitch from '@material-ui/core/Switch';
import { withCookies, Cookies } from 'react-cookie';
import {
BrowserRouter as Router,
Route,
Link,
Switch
} from 'react-router-dom';
const drawerWidth = 240;
const styles = theme => ({
root: {
display: 'flex',
},
drawer: {
[theme.breakpoints.up('sm')]: {
width: drawerWidth,
flexShrink: 0,
},
},
nested: {
paddingLeft: theme.spacing.unit * 4,
},
appBar: {
marginLeft: drawerWidth,
[theme.breakpoints.up('sm')]: {
width: `calc(100% - ${drawerWidth}px)`,
},
},
menuButton: {
marginRight: 20,
[theme.breakpoints.up('sm')]: {
display: 'none',
},
},
toolbar: theme.mixins.toolbar,
drawerPaper: {
width: drawerWidth,
},
content: {
flexGrow: 1,
width: '60%'
},
});
class ResponsiveDrawer extends React.Component {
componentWillMount() {
const { cookies } = this.props;
var newName, newTheme, newChecked;
if (cookies.get('themeName') === undefined) {
newName = 'light'
newTheme = createMuiTheme({
typography: {
useNextVariants: true,
},
palette: {
type: 'light'
}
});
newChecked = true;
cookies.set('themeName', newName, { path: '/' });
} else {
if (cookies.get('themeName') === 'light') {
newName = 'light'
newTheme = createMuiTheme({
typography: {
useNextVariants: true,
},
palette: {
type: 'light'
}
});
newChecked = true;
} else {
newName = 'dark'
newTheme = createMuiTheme({
typography: {
useNextVariants: true,
},
palette: {
type: 'dark'
}
});
newChecked = false;
}
}
this.setState({
mobileOpen: false,
open: false,
open2: false,
theme: newTheme,
themeName: newName,
themeChecked: newChecked
});
}
handleDrawerToggle = () => {
this.setState(state => ({ mobileOpen: !state.mobileOpen }));
}
handleClick = () => {
this.setState(state => ({ open: !state.open, open2: false }));
}
handleClick2 = () => {
this.setState(state => ({ open2: !state.open2, open: false }));
}
handleChange = name => event => {
const { cookies } = this.props;
this.setState({ [name]: event.target.checked });
var newTheme, newName;
if (this.state.themeName === 'light') {
newTheme = createMuiTheme({
typography: {
useNextVariants: true,
},
palette: {
type: 'dark'
}
});
newName = 'dark';
} else {
newTheme = createMuiTheme({
typography: {
useNextVariants: true,
},
palette: {
type: 'light'
}
});
newName = 'light';
}
this.setState({
themeName: newName,
theme: newTheme
})
cookies.set('themeName', newName, { path: '/' });
};
render() {
const { classes } = this.props;
const drawer = (
{this.state.open ? : }
{this.state.open2 ? : }
);
return (
Marten Tracker
);
}
}
ResponsiveDrawer.propTypes = {
classes: PropTypes.object.isRequired,
container: PropTypes.object,
theme: PropTypes.object.isRequired,
cookies: instanceOf(Cookies).isRequired,
};
export default withStyles(styles, { withTheme: true })(withCookies(ResponsiveDrawer));