/* * 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 Stack from '@mui/material/Stack'; import { useTranslation } from 'react-i18next'; import Box from '@mui/material/Box'; import MenuItem from '@mui/material/MenuItem'; import { useLayoutEffect } from 'react'; import Popover from '@mui/material/Popover'; import { bindPopover, bindTrigger, usePopupState } from 'material-ui-popup-state/hooks'; import FormControl from '@mui/material/FormControl'; import InputLabel from '@mui/material/InputLabel'; import { Link } from 'react-router-dom'; import { Select } from '@/modules/core/components/inputs/Select.tsx'; import { ReaderChapterList } from '@/modules/reader/components/overlay/navigation/ReaderChapterList.tsx'; import { ReaderNavBarDesktopNextPreviousButton } from '@/modules/reader/components/overlay/navigation/desktop/ReaderNavBarDesktopNextPreviousButton.tsx'; import { getOptionForDirection } from '@/modules/theme/services/ThemeCreator.ts'; import { ReaderService } from '@/modules/reader/services/ReaderService.ts'; import { ReaderControls } from '@/modules/reader/services/ReaderControls.ts'; import { ReaderStateChapters } from '@/modules/reader/types/Reader.types.ts'; export const ReaderNavBarDesktopChapterNavigation = ({ currentChapter, previousChapter, nextChapter, chapters = [], }: Pick) => { const { t } = useTranslation(); const readerThemeDirection = ReaderService.useGetThemeDirection(); const openChapter = ReaderControls.useOpenChapter(); const popupState = usePopupState({ variant: 'popover', popupId: 'reader-nav-bar-desktop-chapter-list' }); useLayoutEffect(() => { popupState.close(); }, [currentChapter?.id]); return ( { openChapter(getOptionForDirection('previous', 'next', readerThemeDirection)); }} disabled={getOptionForDirection(!previousChapter, !nextChapter, readerThemeDirection)} /> {t('chapter.title_one')} { openChapter(getOptionForDirection('next', 'previous', readerThemeDirection)); }} disabled={getOptionForDirection(!nextChapter, !previousChapter, readerThemeDirection)} /> ); };