import { useRef, useState, useCallback } from 'react'; import * as React from 'react'; import usePdfDocument from './hooks/usePdfDocument'; import VerticalPages from './VerticalPages'; import MessageService from './messageService'; import { DownloadButton, PrintButton, OpenLinkButton, CloseButton } from './ui/IconButtons'; import ZoomControls from './ui/ZoomControls'; import styled from 'styled-components'; import GotoInput from './ui/GotoPage'; require('./fullScreen.css'); const TitleWrapper = styled.div` font-size: 0.7rem; font-weight: 400; display: flex; align-items: start; flex-direction: column; min-width: 10rem; max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--secondary); padding: 0.2rem 0.6rem; height: 100%; width: 100%; justify-content: center; `; const Title = styled.div` font-size: 0.9rem; font-weight: bold; margin-bottom: 0.2rem; color: var(--primary); overflow: hidden; `; export interface FullViewerProps { pdfPath: string; isDarkTheme: boolean; messageService: MessageService; startPage: number; title: string; } export default function FullViewer(props: FullViewerProps) { const pdfDocument = usePdfDocument(props.pdfPath); const [zoom, setZoom] = useState(1); const [startPage, setStartPage] = useState(props.startPage || 1); const [selectedPage, setSelectedPage] = useState(startPage); const mainViewerRef = useRef(null); const thubmnailRef = useRef(null); const onActivePageChange = useCallback((pageNo: number) => { setSelectedPage(pageNo); }, []); const goToPage = useCallback((pageNo: number) => { if (pageNo < 1 || pageNo > pdfDocument.pageCount || pageNo === selectedPage) return; setSelectedPage(pageNo); setStartPage(pageNo); }, [pdfDocument, selectedPage]); if (!pdfDocument) { return (
); } return (
{props.title}
{selectedPage} of {pdfDocument.pageCount} pages
); }