import clsx from 'clsx'; import React from 'react'; import { Insets } from '@/types/misc'; import { useEnv } from '@/context/EnvContext'; import { useReaderStore } from '@/store/readerStore'; import { useTranslation } from '@/hooks/useTranslation'; import { PageInfo, TimeInfo } from '@/types/book'; interface PageInfoProps { bookKey: string; bookFormat: string; section?: PageInfo; pageinfo?: PageInfo; timeinfo?: TimeInfo; horizontalGap: number; contentInsets: Insets; gridInsets: Insets; } const ProgressInfoView: React.FC = ({ bookKey, bookFormat, section, pageinfo, timeinfo, horizontalGap, contentInsets, gridInsets, }) => { const _ = useTranslation(); const { appService } = useEnv(); const { getViewSettings } = useReaderStore(); const viewSettings = getViewSettings(bookKey)!; const showDoubleBorder = viewSettings.vertical && viewSettings.doubleBorder; const isScrolled = viewSettings.scrolled; const isVertical = viewSettings.vertical; const pageInfo = ['PDF', 'CBZ'].includes(bookFormat) ? section ? isVertical ? `${section.current + 1} · ${section.total}` : `${section.current + 1} / ${section.total}` : '' : pageinfo ? _(isVertical ? '{{currentPage}} · {{totalPage}}' : 'Loc. {{currentPage}} / {{totalPage}}', { currentPage: pageinfo.current + 1, totalPage: pageinfo.total, }) : ''; const timeInfo = timeinfo ? _('{{time}} min left in chapter', { time: Math.round(timeinfo.section) }) : ''; return (
{viewSettings.showRemainingTime && {timeInfo}} {viewSettings.showPageNumber && {pageInfo}}
); }; export default ProgressInfoView;