File size: 1,508 Bytes
4e1096a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 'use client';
import React from 'react';
import { FoliateView } from '@/types/view';
import { Insets } from '@/types/misc';
import { useReaderStore } from '@/store/readerStore';
import { useParagraphMode } from '../../hooks/useParagraphMode';
import ParagraphBar from './ParagraphBar';
import ParagraphOverlay from './ParagraphOverlay';
const DIM_OPACITY = 0.3;
interface ParagraphControlProps {
bookKey: string;
viewRef: React.RefObject<FoliateView | null>;
gridInsets: Insets;
}
const ParagraphControl: React.FC<ParagraphControlProps> = ({ bookKey, viewRef, gridInsets }) => {
const { getViewSettings } = useReaderStore();
const viewSettings = getViewSettings(bookKey);
const {
paragraphState,
paragraphConfig,
toggleParagraphMode,
goToNextParagraph,
goToPrevParagraph,
} = useParagraphMode({ bookKey, viewRef });
if (!paragraphConfig?.enabled) {
return null;
}
return (
<>
<ParagraphOverlay
bookKey={bookKey}
dimOpacity={DIM_OPACITY}
viewSettings={viewSettings ?? undefined}
onClose={toggleParagraphMode}
/>
<ParagraphBar
bookKey={bookKey}
currentIndex={paragraphState.currentIndex}
totalParagraphs={paragraphState.totalParagraphs}
isLoading={paragraphState.isLoading}
onPrev={goToPrevParagraph}
onNext={goToNextParagraph}
onClose={toggleParagraphMode}
gridInsets={gridInsets}
/>
</>
);
};
export default ParagraphControl;
|