2021-03-26 04:17:02 +04:30
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
2021-01-26 23:32:12 +03:30
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
2020-12-24 16:50:50 +01:00
|
|
|
import React from 'react';
|
2021-09-09 17:51:22 +04:30
|
|
|
import makeStyles from '@mui/styles/makeStyles';
|
|
|
|
|
import Drawer from '@mui/material/Drawer';
|
|
|
|
|
import List from '@mui/material/List';
|
|
|
|
|
import ListItem from '@mui/material/ListItem';
|
|
|
|
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
|
|
|
import CollectionsBookmarkIcon from '@mui/icons-material/CollectionsBookmark';
|
|
|
|
|
import CollectionsBookmarkOutlinedIcon from '@mui/icons-material/CollectionsBookmarkOutlined';
|
|
|
|
|
import VideoLibraryOutlinedIcon from '@mui/icons-material/VideoLibraryOutlined';
|
|
|
|
|
import ExploreIcon from '@mui/icons-material/Explore';
|
|
|
|
|
import ExtensionIcon from '@mui/icons-material/Extension';
|
|
|
|
|
import GetAppIcon from '@mui/icons-material/GetApp';
|
|
|
|
|
import ListItemText from '@mui/material/ListItemText';
|
|
|
|
|
import SettingsIcon from '@mui/icons-material/Settings';
|
2020-12-24 16:50:50 +01:00
|
|
|
import { Link } from 'react-router-dom';
|
2021-08-10 09:40:43 +04:30
|
|
|
import useLocalStorage from 'util/useLocalStorage';
|
2020-12-24 16:50:50 +01:00
|
|
|
|
|
|
|
|
const useStyles = makeStyles({
|
|
|
|
|
list: {
|
|
|
|
|
width: 250,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
|
drawerOpen: boolean
|
2020-12-25 06:36:34 +03:30
|
|
|
|
2021-05-15 17:18:57 +04:30
|
|
|
setDrawerOpen: React.Dispatch<React.SetStateAction<boolean>>
|
2020-12-24 16:50:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function TemporaryDrawer({ drawerOpen, setDrawerOpen }: IProps) {
|
|
|
|
|
const classes = useStyles();
|
2021-09-09 17:51:22 +04:30
|
|
|
const [workingMode, setWorkingMode] = useLocalStorage<'manga' | 'anime'>('workingMode', 'manga');
|
2021-08-10 09:40:43 +04:30
|
|
|
|
|
|
|
|
const otherMode = () => {
|
|
|
|
|
if (workingMode === 'manga') return 'Anime';
|
|
|
|
|
return 'Manga';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const switchMode = () => {
|
|
|
|
|
if (workingMode === 'manga') setWorkingMode('anime');
|
|
|
|
|
else setWorkingMode('manga');
|
|
|
|
|
};
|
2020-12-24 16:50:50 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<Drawer
|
|
|
|
|
open={drawerOpen}
|
|
|
|
|
anchor="left"
|
|
|
|
|
onClose={() => setDrawerOpen(false)}
|
|
|
|
|
>
|
2021-03-18 21:46:24 +03:30
|
|
|
<div
|
|
|
|
|
className={classes.list}
|
|
|
|
|
role="presentation"
|
|
|
|
|
onClick={() => setDrawerOpen(false)}
|
|
|
|
|
onKeyDown={() => setDrawerOpen(false)}
|
|
|
|
|
>
|
|
|
|
|
<List>
|
2021-08-10 09:40:43 +04:30
|
|
|
{workingMode === 'manga'
|
|
|
|
|
&& (
|
|
|
|
|
<Link to="/library" style={{ color: 'inherit', textDecoration: 'none' }}>
|
|
|
|
|
<ListItem button key="Library">
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<CollectionsBookmarkIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary="Library" />
|
|
|
|
|
</ListItem>
|
|
|
|
|
</Link>
|
|
|
|
|
)}
|
|
|
|
|
<Link to={`/${workingMode}/extensions`} style={{ color: 'inherit', textDecoration: 'none' }}>
|
2021-03-18 21:46:24 +03:30
|
|
|
<ListItem button key="Extensions">
|
|
|
|
|
<ListItemIcon>
|
2021-05-23 13:48:02 +04:30
|
|
|
<ExtensionIcon />
|
2021-03-18 21:46:24 +03:30
|
|
|
</ListItemIcon>
|
2021-07-31 04:14:48 +04:30
|
|
|
<ListItemText primary="Extensions" />
|
2021-05-27 05:13:01 +04:30
|
|
|
</ListItem>
|
|
|
|
|
</Link>
|
2021-08-10 09:40:43 +04:30
|
|
|
<Link to={`/${workingMode}/sources`} style={{ color: 'inherit', textDecoration: 'none' }}>
|
2021-03-18 21:46:24 +03:30
|
|
|
<ListItem button key="Sources">
|
|
|
|
|
<ListItemIcon>
|
2021-05-23 13:48:02 +04:30
|
|
|
<ExploreIcon />
|
2021-03-18 21:46:24 +03:30
|
|
|
</ListItemIcon>
|
2021-07-31 04:14:48 +04:30
|
|
|
<ListItemText primary="Sources" />
|
2021-05-27 17:13:22 +04:30
|
|
|
</ListItem>
|
|
|
|
|
</Link>
|
2021-08-10 09:40:43 +04:30
|
|
|
{workingMode === 'manga'
|
|
|
|
|
&& (
|
|
|
|
|
<Link to="/manga/downloads" style={{ color: 'inherit', textDecoration: 'none' }}>
|
|
|
|
|
<ListItem button key="Manga Download Queue">
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<GetAppIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary="Downloads" />
|
|
|
|
|
</ListItem>
|
|
|
|
|
</Link>
|
|
|
|
|
)}
|
2021-03-18 21:46:24 +03:30
|
|
|
<Link to="/settings" style={{ color: 'inherit', textDecoration: 'none' }}>
|
|
|
|
|
<ListItem button key="settings">
|
|
|
|
|
<ListItemIcon>
|
2021-05-23 13:48:02 +04:30
|
|
|
<SettingsIcon />
|
2021-03-18 21:46:24 +03:30
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary="Settings" />
|
|
|
|
|
</ListItem>
|
|
|
|
|
</Link>
|
2021-08-10 09:40:43 +04:30
|
|
|
<ListItem button key="SwitchMode" onClick={switchMode}>
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
{workingMode === 'manga' && <VideoLibraryOutlinedIcon />}
|
|
|
|
|
{workingMode === 'anime' && <CollectionsBookmarkOutlinedIcon />}
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={`Switch to ${otherMode()}`} />
|
|
|
|
|
</ListItem>
|
2021-03-18 21:46:24 +03:30
|
|
|
</List>
|
|
|
|
|
</div>
|
2020-12-24 16:50:50 +01:00
|
|
|
</Drawer>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|