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/. */
|
|
|
|
|
|
2022-03-03 15:09:18 +05:30
|
|
|
import React from 'react';
|
2020-12-24 03:21:18 +03:30
|
|
|
import {
|
2022-03-03 18:19:01 +05:30
|
|
|
BrowserRouter as Router,
|
|
|
|
|
Switch,
|
2021-05-27 05:13:01 +04:30
|
|
|
Route,
|
|
|
|
|
Redirect,
|
2020-12-24 17:19:49 +03:30
|
|
|
} from 'react-router-dom';
|
2021-10-29 20:11:23 +02:00
|
|
|
import { QueryParamProvider } from 'use-query-params';
|
2021-11-15 19:33:48 +03:30
|
|
|
import { Container } from '@mui/material';
|
2021-09-09 17:51:22 +04:30
|
|
|
import CssBaseline from '@mui/material/CssBaseline';
|
|
|
|
|
import {
|
2022-03-03 18:19:01 +05:30
|
|
|
createTheme,
|
|
|
|
|
ThemeProvider,
|
|
|
|
|
Theme,
|
|
|
|
|
StyledEngineProvider,
|
2021-09-09 17:51:22 +04:30
|
|
|
} from '@mui/material/styles';
|
2021-10-30 16:10:34 +03:30
|
|
|
import DefaultNavBar from 'components/navbar/DefaultNavBar';
|
|
|
|
|
import DarkTheme from 'components/context/DarkTheme';
|
2021-05-27 05:13:01 +04:30
|
|
|
import useLocalStorage from 'util/useLocalStorage';
|
|
|
|
|
import Settings from 'screens/Settings';
|
|
|
|
|
import About from 'screens/settings/About';
|
|
|
|
|
import Categories from 'screens/settings/Categories';
|
|
|
|
|
import Backup from 'screens/settings/Backup';
|
2021-10-30 16:16:36 +03:30
|
|
|
import Library from 'screens/Library';
|
|
|
|
|
import SourceConfigure from 'screens/SourceConfigure';
|
|
|
|
|
import Manga from 'screens/Manga';
|
|
|
|
|
import SourceMangas from 'screens/SourceMangas';
|
|
|
|
|
import Reader from 'screens/Reader';
|
|
|
|
|
import Updates from 'screens/Updates';
|
|
|
|
|
import DownloadQueue from 'screens/DownloadQueue';
|
2021-10-30 16:14:25 +03:30
|
|
|
import Browse from 'screens/Browse';
|
2021-10-30 16:34:09 +03:30
|
|
|
import Sources from 'screens/Sources';
|
|
|
|
|
import Extensions from 'screens/Extensions';
|
2022-03-03 15:09:18 +05:30
|
|
|
import NavBarContextProvider from 'components/navbar/NavBarContextProvider';
|
2022-03-03 18:19:01 +05:30
|
|
|
import LibraryOptionsContextProvider from 'components/library/LibraryOptionsProvider';
|
2022-03-12 04:46:55 +00:00
|
|
|
import SearchAll from 'screens/SearchAll';
|
2020-12-24 02:37:23 +03:30
|
|
|
|
2021-09-09 17:51:22 +04:30
|
|
|
declare module '@mui/styles/defaultTheme' {
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
2022-03-03 18:19:01 +05:30
|
|
|
interface DefaultTheme extends Theme {}
|
2021-09-09 17:51:22 +04:30
|
|
|
}
|
|
|
|
|
|
2020-12-24 16:50:50 +01:00
|
|
|
export default function App() {
|
2022-03-03 18:19:01 +05:30
|
|
|
const [darkTheme, setDarkTheme] = useLocalStorage<boolean>(
|
|
|
|
|
'darkTheme',
|
|
|
|
|
true,
|
|
|
|
|
);
|
2021-03-18 21:46:24 +03:30
|
|
|
|
2021-10-29 20:11:23 +02:00
|
|
|
const darkThemeContext = {
|
|
|
|
|
darkTheme,
|
|
|
|
|
setDarkTheme,
|
2021-03-08 21:04:42 +03:30
|
|
|
};
|
2021-01-23 01:20:16 +03:30
|
|
|
|
|
|
|
|
const theme = React.useMemo(
|
2021-09-09 18:06:09 +04:30
|
|
|
() => createTheme({
|
2021-01-23 01:20:16 +03:30
|
|
|
palette: {
|
2021-09-09 17:51:22 +04:30
|
|
|
mode: darkTheme ? 'dark' : 'light',
|
2021-01-23 01:20:16 +03:30
|
|
|
},
|
2021-09-09 18:06:09 +04:30
|
|
|
components: {
|
2021-01-23 02:53:00 +03:30
|
|
|
MuiCssBaseline: {
|
2021-09-09 18:06:09 +04:30
|
|
|
styleOverrides: `
|
|
|
|
|
*::-webkit-scrollbar {
|
|
|
|
|
width: 10px;
|
|
|
|
|
background: ${darkTheme ? '#222' : '#e1e1e1'};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*::-webkit-scrollbar-thumb {
|
|
|
|
|
background: ${darkTheme ? '#111' : '#aaa'};
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
}
|
|
|
|
|
`,
|
2021-01-23 02:53:00 +03:30
|
|
|
},
|
|
|
|
|
},
|
2021-09-09 18:06:09 +04:30
|
|
|
}),
|
2021-01-23 01:20:16 +03:30
|
|
|
[darkTheme],
|
|
|
|
|
);
|
2021-01-22 17:00:33 +03:30
|
|
|
|
2020-12-24 16:50:50 +01:00
|
|
|
return (
|
|
|
|
|
<Router>
|
2021-09-09 17:51:22 +04:30
|
|
|
<StyledEngineProvider injectFirst>
|
|
|
|
|
<ThemeProvider theme={theme}>
|
2021-10-29 20:11:23 +02:00
|
|
|
<QueryParamProvider ReactRouterRoute={Route}>
|
2022-03-03 18:19:01 +05:30
|
|
|
<LibraryOptionsContextProvider>
|
|
|
|
|
<NavBarContextProvider>
|
|
|
|
|
<CssBaseline />
|
|
|
|
|
<DefaultNavBar />
|
|
|
|
|
<Container
|
|
|
|
|
id="appMainContainer"
|
|
|
|
|
maxWidth={false}
|
|
|
|
|
disableGutters
|
|
|
|
|
sx={{
|
|
|
|
|
mt: 8,
|
|
|
|
|
ml: { sm: 8 },
|
|
|
|
|
mb: { xs: 8, sm: 0 },
|
|
|
|
|
width: 'auto',
|
|
|
|
|
overflow: 'auto',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Switch>
|
|
|
|
|
{/* General Routes */}
|
|
|
|
|
<Route
|
|
|
|
|
exact
|
|
|
|
|
path="/"
|
|
|
|
|
render={() => (
|
|
|
|
|
<Redirect to="/library" />
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<Route path="/settings/about">
|
|
|
|
|
<About />
|
|
|
|
|
</Route>
|
|
|
|
|
<Route path="/settings/categories">
|
|
|
|
|
<Categories />
|
|
|
|
|
</Route>
|
|
|
|
|
<Route path="/settings/backup">
|
|
|
|
|
<Backup />
|
|
|
|
|
</Route>
|
|
|
|
|
<Route path="/settings">
|
|
|
|
|
<DarkTheme.Provider
|
|
|
|
|
value={darkThemeContext}
|
|
|
|
|
>
|
|
|
|
|
<Settings />
|
|
|
|
|
</DarkTheme.Provider>
|
|
|
|
|
</Route>
|
|
|
|
|
|
|
|
|
|
{/* Manga Routes */}
|
|
|
|
|
|
|
|
|
|
<Route path="/sources/:sourceId/popular/">
|
|
|
|
|
<SourceMangas popular />
|
|
|
|
|
</Route>
|
|
|
|
|
<Route path="/sources/:sourceId/latest/">
|
|
|
|
|
<SourceMangas popular={false} />
|
|
|
|
|
</Route>
|
|
|
|
|
<Route path="/sources/:sourceId/configure/">
|
|
|
|
|
<SourceConfigure />
|
|
|
|
|
</Route>
|
2022-03-12 04:46:55 +00:00
|
|
|
<Route path="/sources/all/search/">
|
|
|
|
|
<SearchAll />
|
|
|
|
|
</Route>
|
2022-03-03 18:19:01 +05:30
|
|
|
<Route path="/downloads">
|
|
|
|
|
<DownloadQueue />
|
|
|
|
|
</Route>
|
|
|
|
|
<Route path="/manga/:mangaId/chapter/:chapterNum">
|
|
|
|
|
<></>
|
|
|
|
|
</Route>
|
|
|
|
|
<Route path="/manga/:id">
|
|
|
|
|
<Manga />
|
|
|
|
|
</Route>
|
|
|
|
|
<Route path="/library">
|
|
|
|
|
<Library />
|
|
|
|
|
</Route>
|
|
|
|
|
<Route path="/updates">
|
|
|
|
|
<Updates />
|
|
|
|
|
</Route>
|
|
|
|
|
<Route path="/sources">
|
|
|
|
|
<Sources />
|
|
|
|
|
</Route>
|
|
|
|
|
<Route path="/extensions">
|
|
|
|
|
<Extensions />
|
|
|
|
|
</Route>
|
|
|
|
|
<Route path="/browse">
|
|
|
|
|
<Browse />
|
|
|
|
|
</Route>
|
|
|
|
|
</Switch>
|
|
|
|
|
</Container>
|
2021-10-29 20:11:23 +02:00
|
|
|
<Switch>
|
|
|
|
|
<Route
|
2022-03-03 18:19:01 +05:30
|
|
|
path="/manga/:mangaId/chapter/:chapterIndex"
|
|
|
|
|
// passing a key re-mounts the reader when changing chapters
|
|
|
|
|
render={(props: any) => (
|
|
|
|
|
<Reader
|
|
|
|
|
key={
|
|
|
|
|
props.match.params
|
|
|
|
|
.chapterIndex
|
|
|
|
|
}
|
|
|
|
|
/>
|
2021-10-29 20:11:23 +02:00
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</Switch>
|
2022-03-03 18:19:01 +05:30
|
|
|
</NavBarContextProvider>
|
|
|
|
|
</LibraryOptionsContextProvider>
|
2021-10-29 20:11:23 +02:00
|
|
|
</QueryParamProvider>
|
2021-09-09 17:51:22 +04:30
|
|
|
</ThemeProvider>
|
|
|
|
|
</StyledEngineProvider>
|
2020-12-24 16:50:50 +01:00
|
|
|
</Router>
|
|
|
|
|
);
|
|
|
|
|
}
|