import clsx from 'clsx'; import React, { useCallback, useEffect } from 'react'; import { RiArrowLeftSLine, RiArrowRightSLine } from 'react-icons/ri'; import { RiArrowGoBackLine, RiArrowGoForwardLine } from 'react-icons/ri'; import { RiArrowLeftDoubleLine, RiArrowRightDoubleLine } from 'react-icons/ri'; import { useEnv } from '@/context/EnvContext'; import { useReaderStore } from '@/store/readerStore'; import { useTranslation } from '@/hooks/useTranslation'; import { NavigationHandlers } from './types'; import { getNavigationIcon } from './utils'; import Button from '@/components/Button'; import Slider from '@/components/Slider'; interface NavigationPanelProps { bookKey: string; actionTab: string; progressFraction: number; progressValid: boolean; navigationHandlers: NavigationHandlers; bottomOffset: string; sliderHeight: number; forceMobileLayout: boolean; } export const NavigationPanel: React.FC = ({ bookKey, actionTab, progressFraction, progressValid, navigationHandlers, bottomOffset, sliderHeight, forceMobileLayout, }) => { const _ = useTranslation(); const { appService } = useEnv(); const { getView, getViewSettings } = useReaderStore(); const view = getView(bookKey); const viewSettings = getViewSettings(bookKey); const [progressValue, setProgressValue] = React.useState( progressValid ? progressFraction * 100 : 0, ); useEffect(() => { if (progressValid) { // eslint-disable-next-line react-hooks/set-state-in-effect setProgressValue(progressFraction * 100); } }, [progressValid, progressFraction]); const handleProgressChange = useCallback( (value: number) => { setProgressValue(value); navigationHandlers.onProgressChange(value); }, [navigationHandlers], ); const classes = clsx( 'footerbar-progress-mobile bg-base-200 absolute flex w-full flex-col items-center gap-y-8 px-4 transition-all', !forceMobileLayout && 'sm:hidden', actionTab === 'progress' ? 'pointer-events-auto translate-y-0 pb-4 pt-8 ease-out' : 'pointer-events-none invisible translate-y-full overflow-hidden pb-0 pt-0 ease-in', ); return (
); };