mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2025-01-25 23:11:17 +01:00
handle reader types
This commit is contained in:
parent
5f23691e20
commit
a62ee8f8c3
@ -23,6 +23,8 @@ import { Switch } from '@material-ui/core';
|
|||||||
import List from '@material-ui/core/List';
|
import List from '@material-ui/core/List';
|
||||||
import ListItem from '@material-ui/core/ListItem';
|
import ListItem from '@material-ui/core/ListItem';
|
||||||
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
||||||
|
import MenuItem from '@material-ui/core/MenuItem';
|
||||||
|
import Select from '@material-ui/core/Select';
|
||||||
import ListItemText from '@material-ui/core/ListItemText';
|
import ListItemText from '@material-ui/core/ListItemText';
|
||||||
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
|
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
|
||||||
import Collapse from '@material-ui/core/Collapse';
|
import Collapse from '@material-ui/core/Collapse';
|
||||||
@ -141,6 +143,7 @@ export const defaultReaderSettings = () => ({
|
|||||||
staticNav: false,
|
staticNav: false,
|
||||||
showPageNumber: true,
|
showPageNumber: true,
|
||||||
continuesPageGap: false,
|
continuesPageGap: false,
|
||||||
|
readerType: 'ContinuesVertical',
|
||||||
} as IReaderSettings);
|
} as IReaderSettings);
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
@ -165,7 +168,7 @@ export default function ReaderNavBar(props: IProps) {
|
|||||||
const [drawerVisible, setDrawerVisible] = useState(false || settings.staticNav);
|
const [drawerVisible, setDrawerVisible] = useState(false || settings.staticNav);
|
||||||
const [hideOpenButton, setHideOpenButton] = useState(false);
|
const [hideOpenButton, setHideOpenButton] = useState(false);
|
||||||
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
||||||
const [settingsCollapseOpen, setSettingsCollapseOpen] = useState(false);
|
const [settingsCollapseOpen, setSettingsCollapseOpen] = useState(true);
|
||||||
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const classes = useStyles(settings)();
|
const classes = useStyles(settings)();
|
||||||
@ -199,7 +202,6 @@ export default function ReaderNavBar(props: IProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ClickAwayListener onClickAway={() => (drawerVisible && setDrawerOpen(false))}>
|
|
||||||
<Slide
|
<Slide
|
||||||
direction="right"
|
direction="right"
|
||||||
in={drawerOpen}
|
in={drawerOpen}
|
||||||
@ -276,14 +278,18 @@ export default function ReaderNavBar(props: IProps) {
|
|||||||
</ListItemSecondaryAction>
|
</ListItemSecondaryAction>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemText primary="Continues Page gap" />
|
<ListItemText primary="Reader Type" />
|
||||||
<ListItemSecondaryAction>
|
<Select
|
||||||
<Switch
|
value={settings.readerType}
|
||||||
edge="end"
|
onChange={(e) => setSettingValue('readerType', e.target.value)}
|
||||||
checked={settings.continuesPageGap}
|
>
|
||||||
onChange={(e) => setSettingValue('continuesPageGap', e.target.checked)}
|
<MenuItem value="SingleLTR">Left to right</MenuItem>
|
||||||
/>
|
<MenuItem value="SingleRTL">Right to left(WIP)</MenuItem>
|
||||||
</ListItemSecondaryAction>
|
<MenuItem value="SingleVertical">Vertical(WIP)</MenuItem>
|
||||||
|
<MenuItem value="Webtoon">Webtoon</MenuItem>
|
||||||
|
<MenuItem value="ContinuesVertical">Continues Vertical</MenuItem>
|
||||||
|
<MenuItem value="ContinuesHorizontal">Horizontal(WIP)</MenuItem>
|
||||||
|
</Select>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</List>
|
</List>
|
||||||
</Collapse>
|
</Collapse>
|
||||||
@ -335,7 +341,6 @@ export default function ReaderNavBar(props: IProps) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Slide>
|
</Slide>
|
||||||
</ClickAwayListener>
|
|
||||||
<Zoom in={!drawerOpen}>
|
<Zoom in={!drawerOpen}>
|
||||||
<Fade in={!hideOpenButton}>
|
<Fade in={!hideOpenButton}>
|
||||||
<IconButton
|
<IconButton
|
||||||
|
@ -27,7 +27,7 @@ const useStyles = (settings: IReaderSettings) => makeStyles({
|
|||||||
},
|
},
|
||||||
image: {
|
image: {
|
||||||
display: 'block',
|
display: 'block',
|
||||||
marginBottom: settings.continuesPageGap ? '15px' : 0,
|
marginBottom: settings.readerType === 'ContinuesVertical' ? '15px' : 0,
|
||||||
minWidth: '50vw',
|
minWidth: '50vw',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
maxWidth: '100%',
|
maxWidth: '100%',
|
||||||
|
@ -14,14 +14,7 @@ const useStyles = makeStyles({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
interface IProps {
|
export default function PagedReader(props: IReaderProps) {
|
||||||
pages: Array<IReaderPage>
|
|
||||||
setCurPage: React.Dispatch<React.SetStateAction<number>>
|
|
||||||
curPage: number
|
|
||||||
settings: IReaderSettings
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function SinglePageReader(props: IProps) {
|
|
||||||
const {
|
const {
|
||||||
pages, settings, setCurPage, curPage,
|
pages, settings, setCurPage, curPage,
|
||||||
} = props;
|
} = props;
|
@ -13,13 +13,7 @@ const useStyles = makeStyles({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
interface IProps {
|
export default function VerticalReader(props: IReaderProps) {
|
||||||
pages: Array<IReaderPage>
|
|
||||||
setCurPage: React.Dispatch<React.SetStateAction<number>>
|
|
||||||
settings: IReaderSettings
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function VerticalReader(props: IProps) {
|
|
||||||
const { pages, settings, setCurPage } = props;
|
const { pages, settings, setCurPage } = props;
|
||||||
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
@ -13,7 +13,7 @@ import { useParams } from 'react-router-dom';
|
|||||||
import HorizontalReader from '../components/reader/HorizontalReader';
|
import HorizontalReader from '../components/reader/HorizontalReader';
|
||||||
import Page from '../components/reader/Page';
|
import Page from '../components/reader/Page';
|
||||||
import PageNumber from '../components/reader/PageNumber';
|
import PageNumber from '../components/reader/PageNumber';
|
||||||
import SinglePageReader from '../components/reader/SinglePageReader';
|
import PagedReader from '../components/reader/PagedReader';
|
||||||
import VerticalReader from '../components/reader/VerticalReader';
|
import VerticalReader from '../components/reader/VerticalReader';
|
||||||
import ReaderNavBar, { defaultReaderSettings } from '../components/ReaderNavBar';
|
import ReaderNavBar, { defaultReaderSettings } from '../components/ReaderNavBar';
|
||||||
import NavbarContext from '../context/NavbarContext';
|
import NavbarContext from '../context/NavbarContext';
|
||||||
@ -30,6 +30,31 @@ const useStyles = (settings: IReaderSettings) => makeStyles({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getReaderComponent = (readerType: ReaderType) => {
|
||||||
|
switch (readerType) {
|
||||||
|
case 'ContinuesVertical':
|
||||||
|
return VerticalReader;
|
||||||
|
break;
|
||||||
|
case 'Webtoon':
|
||||||
|
return VerticalReader;
|
||||||
|
break;
|
||||||
|
case 'SingleVertical':
|
||||||
|
return PagedReader;
|
||||||
|
break;
|
||||||
|
case 'SingleRTL':
|
||||||
|
return PagedReader;
|
||||||
|
break;
|
||||||
|
case 'SingleLTR':
|
||||||
|
return PagedReader;
|
||||||
|
break;
|
||||||
|
case 'ContinuesHorizontal':
|
||||||
|
return HorizontalReader;
|
||||||
|
default:
|
||||||
|
return VerticalReader;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const range = (n:number) => Array.from({ length: n }, (value, key) => key);
|
const range = (n:number) => Array.from({ length: n }, (value, key) => key);
|
||||||
const initialChapter = () => ({ pageCount: -1, index: -1, chapterCount: 0 });
|
const initialChapter = () => ({ pageCount: -1, index: -1, chapterCount: 0 });
|
||||||
|
|
||||||
@ -98,6 +123,8 @@ export default function Reader() {
|
|||||||
src: `${serverAddress}/api/v1/manga/${mangaId}/chapter/${chapterIndex}/page/${index}`,
|
src: `${serverAddress}/api/v1/manga/${mangaId}/chapter/${chapterIndex}/page/${index}`,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const ReaderComponent = getReaderComponent(settings.readerType);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<PageNumber
|
<PageNumber
|
||||||
@ -105,18 +132,9 @@ export default function Reader() {
|
|||||||
curPage={curPage}
|
curPage={curPage}
|
||||||
pageCount={chapter.pageCount}
|
pageCount={chapter.pageCount}
|
||||||
/>
|
/>
|
||||||
{/* <VerticalReader
|
<ReaderComponent
|
||||||
pages={pages}
|
|
||||||
setCurPage={setCurPage}
|
|
||||||
settings={settings}
|
|
||||||
/> */}
|
|
||||||
{/* <HorizontalReader
|
|
||||||
pages={pages}
|
|
||||||
setCurPage={setCurPage}
|
|
||||||
settings={settings}
|
|
||||||
/> */}
|
|
||||||
<SinglePageReader
|
|
||||||
pages={pages}
|
pages={pages}
|
||||||
|
pageCount={chapter.pageCount}
|
||||||
setCurPage={setCurPage}
|
setCurPage={setCurPage}
|
||||||
curPage={curPage}
|
curPage={curPage}
|
||||||
settings={settings}
|
settings={settings}
|
||||||
|
18
webUI/react/src/typings.d.ts
vendored
18
webUI/react/src/typings.d.ts
vendored
@ -88,13 +88,29 @@ interface INavbarOverride {
|
|||||||
value: any
|
value: any
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ReaderType =
|
||||||
|
'ContinuesVertical'|
|
||||||
|
'Webtoon' |
|
||||||
|
'SingleVertical' |
|
||||||
|
'SingleRTL' |
|
||||||
|
'SingleLTR' |
|
||||||
|
'ContinuesHorizontal';
|
||||||
|
|
||||||
interface IReaderSettings{
|
interface IReaderSettings{
|
||||||
staticNav: boolean
|
staticNav: boolean
|
||||||
showPageNumber: boolean
|
showPageNumber: boolean
|
||||||
continuesPageGap: boolean
|
readerType: ReaderType
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IReaderPage {
|
interface IReaderPage {
|
||||||
index: number
|
index: number
|
||||||
src: string
|
src: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IReaderProps {
|
||||||
|
pages: Array<IReaderPage>
|
||||||
|
pageCount: number
|
||||||
|
setCurPage: React.Dispatch<React.SetStateAction<number>>
|
||||||
|
curPage: number
|
||||||
|
settings: IReaderSettings
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user