/* * Copyright (C) Contributors to the Suwayomi project * * This Source Code Form is subject to the terms of the Mozilla Public * 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/. */ import Typography from '@mui/material/Typography'; import Stack from '@mui/material/Stack'; import { useTranslation } from 'react-i18next'; import Button from '@mui/material/Button'; import { Link } from 'react-router-dom'; import { useReaderScrollbarContext } from '@/modules/reader/contexts/ReaderScrollbarContext.tsx'; import { useReaderStateChaptersContext } from '@/modules/reader/contexts/state/ReaderStateChaptersContext.tsx'; import { ChapterScanlatorInfo } from '@/modules/chapter/services/Chapters.ts'; import { TChapterReader } from '@/modules/chapter/Chapter.types.ts'; import { IReaderSettings, ReaderPageScaleMode, ReaderTransitionPageMode, ReadingMode, } from '@/modules/reader/types/Reader.types.ts'; import { isTransitionPageVisible } from '@/modules/reader/utils/ReaderPager.utils.tsx'; import { useBackButton } from '@/modules/core/hooks/useBackButton.ts'; import { useReaderStateMangaContext } from '@/modules/reader/contexts/state/ReaderStateMangaContext.tsx'; import { applyStyles } from '@/modules/core/utils/ApplyStyles.ts'; import { isContinuousReadingMode } from '@/modules/reader/utils/ReaderSettings.utils.tsx'; import { useNavBarContext } from '@/modules/navigation-bar/contexts/NavbarContext.tsx'; import { AppRoutes } from '@/modules/core/AppRoute.constants.ts'; const ChapterInfo = ({ title, chapter, }: { title: string; chapter?: Pick & ChapterScanlatorInfo; }) => { if (!chapter) { return null; } return ( {title} {chapter.name} {chapter.scanlator && ( {chapter.scanlator} )} ); }; export const ReaderTransitionPage = ({ type, mode, readingMode, pageScaleMode, }: Pick & { type: Exclude; mode: ReaderTransitionPageMode; }) => { const { t } = useTranslation(); const handleBack = useBackButton(); const { manga } = useReaderStateMangaContext(); const { currentChapter, nextChapter, previousChapter } = useReaderStateChaptersContext(); const { scrollbarXSize, scrollbarYSize } = useReaderScrollbarContext(); const { readerNavBarWidth } = useNavBarContext(); const isPreviousType = type === ReaderTransitionPageMode.PREVIOUS; const isNextType = type === ReaderTransitionPageMode.NEXT; const isFirstChapter = !!currentChapter && !previousChapter; const isLastChapter = !!currentChapter && !nextChapter; const isFitWidthPageScaleMode = [ReaderPageScaleMode.SCREEN, ReaderPageScaleMode.WIDTH].includes(pageScaleMode); if (!isTransitionPageVisible(type, mode, readingMode)) { return null; } return ( {isPreviousType && isFirstChapter && ( {t('reader.transition_page.first_chapter')} )} {isPreviousType && !isFirstChapter && ( )} {!!currentChapter && ( )} {isNextType && !isLastChapter && ( )} {isNextType && isLastChapter && ( {t('reader.transition_page.last_chapter')} )} {((isPreviousType && isFirstChapter) || (isNextType && isLastChapter)) && ( )} ); };