/* * 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 MenuItem from '@mui/material/MenuItem'; import { memo, useMemo } from 'react'; import FormControl from '@mui/material/FormControl'; import InputLabel from '@mui/material/InputLabel'; import { Select } from '@/base/components/inputs/Select.tsx'; import { getNextIndexFromPage, getPage } from '@/features/reader/overlay/progress-bar/ReaderProgressBar.utils.tsx'; import { ReaderControls } from '@/features/reader/services/ReaderControls.ts'; import { useGetOptionForDirection } from '@/features/theme/services/ThemeCreator.ts'; import { ReaderService } from '@/features/reader/services/ReaderService.ts'; import { ReaderNavBarDesktopNextPreviousButton } from '@/features/reader/overlay/navigation/desktop/components/ReaderNavBarDesktopNextPreviousButton.tsx'; import { READING_DIRECTION_TO_THEME_DIRECTION } from '@/features/reader/settings/ReaderSettings.constants.tsx'; import { IReaderSettings } from '@/features/reader/Reader.types.ts'; import { withPropsFrom } from '@/base/hoc/withPropsFrom.tsx'; import { useReaderStoreShallow } from '@/features/reader/ReaderStore.ts'; const BaseReaderNavBarDesktopPageNavigation = ({ readingDirection, openPage, }: Pick & { openPage: ReturnType; }) => { const { t } = useTranslation(); const getOptionForDirection = useGetOptionForDirection(); const { currentPageIndex, pages } = useReaderStoreShallow((state) => ({ currentPageIndex: state.pages.currentPageIndex, pages: state.pages.pages, })); const currentPage = useMemo(() => getPage(currentPageIndex, pages), [currentPageIndex, pages]); const direction = READING_DIRECTION_TO_THEME_DIRECTION[readingDirection]; return ( openPage('previous', undefined, false)} /> {t('reader.page_info.label.page')} openPage('next', undefined, false)} /> ); }; export const ReaderNavBarDesktopPageNavigation = withPropsFrom( memo(BaseReaderNavBarDesktopPageNavigation), [() => ({ openPage: ReaderControls.useOpenPage() }), ReaderService.useSettingsWithoutDefaultFlag], ['readingDirection', 'openPage'], );