diff --git a/src/client/component/contentinfo.tsx b/src/client/component/contentinfo.tsx index 901e8fd..6e58843 100644 --- a/src/client/component/contentinfo.tsx +++ b/src/client/component/contentinfo.tsx @@ -102,8 +102,7 @@ export const ContentInfo = (props: { allTag = allTag.filter(x => !x.startsWith("artist:")); return ( @@ -111,7 +110,6 @@ export const ContentInfo = (props: { {content.title} diff --git a/src/client/component/headline.tsx b/src/client/component/headline.tsx index 9bbcb92..a1f4115 100644 --- a/src/client/component/headline.tsx +++ b/src/client/component/headline.tsx @@ -106,8 +106,11 @@ const useStyles = makeStyles((theme: Theme) => ({ export const Headline = (prop: { children?: React.ReactNode, - navListItem?: React.ReactNode, isLogin?: boolean, + classes?:{ + content?:string, + toolbar?:string, + }, menu: React.ReactNode }) => { const [v, setv] = useState(false); @@ -174,7 +177,7 @@ export const Headline = (prop: { color="inherit"> - : + : } @@ -194,8 +197,8 @@ export const Headline = (prop: { -
-
+
+
{prop.children}
); diff --git a/src/client/page/contentinfo.tsx b/src/client/page/contentinfo.tsx index e178dc4..a20aee9 100644 --- a/src/client/page/contentinfo.tsx +++ b/src/client/page/contentinfo.tsx @@ -4,7 +4,7 @@ import ContentAccessor, { Content } from '../accessor/contents'; import { LoadingCircle } from '../component/loading'; import { Link, Paper, makeStyles, Theme, Box, useTheme, Typography } from '@material-ui/core'; import {ArrowBack as ArrowBackIcon } from '@material-ui/icons'; -import { MangaReader } from './reader/manga'; +import { getPresenter } from './reader/reader'; import { ContentInfo, Headline, NavItem, NavList } from '../component/mod'; import {BackLinkContext} from '../state'; @@ -16,6 +16,18 @@ type ContentState = { notfound: boolean, } +const useStyles = makeStyles((theme:Theme)=>({ + noPaddingContent:{ + display:'flex', + flexDirection: 'column', + flexGrow: 1, + }, + noPaddingToolbar:{ + flex: '0 1 auto', + ...theme.mixins.toolbar, + } +})); + export const ContentAbout = (prop: { match: MatchType }) => { const match = useRouteMatch<{id:string}>("/doc/:id"); if (match == null) { @@ -36,7 +48,7 @@ export const ContentAbout = (prop: { match: MatchType }) => { ); - + useEffect(() => { (async () => { console.log("mount content about"); @@ -47,6 +59,8 @@ export const ContentAbout = (prop: { match: MatchType }) => { })() return ()=>{console.log("unmount content about")} }, []); + const classes = useStyles(); + if (isNaN(id)) { return ( @@ -68,17 +82,19 @@ export const ContentAbout = (prop: { match: MatchType }) => { ); } else{ - + const ReaderPage = getPresenter(info.content); return ( - - - + + diff --git a/src/client/page/reader/manga.tsx b/src/client/page/reader/manga.tsx index 9eb9f3e..c1c857d 100644 --- a/src/client/page/reader/manga.tsx +++ b/src/client/page/reader/manga.tsx @@ -1,8 +1,6 @@ import React, {useState, useEffect} from 'react'; -import {Redirect, Route ,Switch,useHistory, useRouteMatch, match as MatchType, Link as RouterLink} from 'react-router-dom'; -import { LoadingCircle } from '../../component/loading'; -import { Link, Paper, makeStyles, Theme, Box, Typography } from '@material-ui/core'; -import { Content, makeThumbnailUrl } from '../../accessor/contents'; +import { Typography, useTheme } from '@material-ui/core'; +import { Content } from '../../accessor/contents'; type MangaType = "manga"|"artist cg"|"donjinshi"|"western" @@ -16,13 +14,35 @@ export type PresentableTag = { } export const MangaReader = (props:{content:Content})=>{ + const theme = useTheme(); const additional = props.content.additional; + const [curPage,setCurPage] = useState(0); if(!('page' in additional)){ console.error("invalid content : page read fail : "+ JSON.stringify(additional)); return Error. DB error. page restriction } + const PageDown = ()=>setCurPage(Math.max(curPage - 1 , 0)); + const PageUP = ()=>setCurPage(Math.min(curPage + 1, page - 1)); const page:number = additional['page'] as number; - return (
{[...Array(page).keys()].map(x=>())}
); + const onKeyUp = (e: KeyboardEvent)=>{ + if(e.code === "ArrowLeft"){ + PageDown(); + } + else if(e.code === "ArrowRight"){ + PageUP(); + } + } + useEffect(()=>{ + document.addEventListener("keydown",onKeyUp); + return ()=>{ + document.removeEventListener("keydown",onKeyUp); + } + }); + //theme.mixins.toolbar.minHeight; + return (
+ +
); } export default MangaReader; \ No newline at end of file diff --git a/src/client/page/reader/reader.tsx b/src/client/page/reader/reader.tsx index 22414c6..8ec4e41 100644 --- a/src/client/page/reader/reader.tsx +++ b/src/client/page/reader/reader.tsx @@ -1,21 +1,31 @@ +import { Typography } from '@material-ui/core'; import React from 'react'; import { Content, makeThumbnailUrl } from '../../accessor/contents'; import {MangaReader} from './manga'; +import {VideoReader} from './video' -export type PresenterCollection = { - ReaderPage: (props:{content:Content,className?:string})=> JSX.Element; -}; +export interface PagePresenterProp{ + content:Content, + className?:string +} +interface PagePresenter{ + (prop:PagePresenterProp):JSX.Element +} -export const getPresenter = (content:Content):PresenterCollection=>{ - return { - ReaderPage:MangaReader - }; +export const getPresenter = (content:Content):PagePresenter => { + switch (content.content_type) { + case "manga": + return MangaReader; + case "video": + return VideoReader; + } + return ()=>Not implemented reader; } export const ThumbnailContainer = (props:{content:Content, className?:string})=>{ const thumbnailurl = makeThumbnailUrl(props.content); if(props.content.content_type === "video"){ - return () + return () } else return () } \ No newline at end of file diff --git a/src/client/page/reader/video.tsx b/src/client/page/reader/video.tsx index e69de29..caa546e 100644 --- a/src/client/page/reader/video.tsx +++ b/src/client/page/reader/video.tsx @@ -0,0 +1,7 @@ +import React from 'react'; +import { Content } from '../../accessor/contents'; + +export const VideoReader = (props:{content:Content})=>{ + const id = props.content.id; + return ; +} \ No newline at end of file