import React, { useRef, useState, useCallback } from 'react'; import useIsFocused from './hooks/useIsFocused'; import usePdfDocument from './hooks/usePdfDocument'; import VerticalPages from './VerticalPages'; import ZoomControls from './ui/ZoomControls'; import MessageService from './messageService'; import { DownloadButton, PrintButton } from './ui/IconButtons'; require('./miniViewer.css'); export interface MiniViewerAppProps { pdfPath: string; isDarkTheme: boolean; anchorPage: number; pdfId: string; resourceId?: string; messageService: MessageService; } export default function MiniViewerApp(props: MiniViewerAppProps) { const pdfDocument = usePdfDocument(props.pdfPath); const isFocused = useIsFocused(); const [zoom, setZoom] = useState(1); const containerEl = useRef(null); const [activePage, setActivePage] = useState(1); const onActivePageChange = useCallback((page: number) => { setActivePage(page); }, []); const onDoubleClick = useCallback((pageNo: number) => { props.messageService.openFullScreenViewer(props.resourceId, pageNo); }, [props.messageService, props.resourceId]); if (!pdfDocument) { return (
); } return (
{activePage}/{pdfDocument.pageCount} pages
{isFocused ? '' : 'Click to enable scroll'}
); }