import { useEffect, useState } from "react"; import { useDeckContext } from "../core/deckContext"; import { useLocalization } from "../core/localization"; import type { SlideDefinition } from "../core/Slide"; import { ControlButton } from "./ControlButton"; import { ControlIcon } from "./ControlIcon"; import { PresentationInteractionSurface } from "./PresentationInteractionLayer"; import type { PresentationInteractionController } from "./presentationInteraction"; import { SlideStage } from "./SlideStage"; export function AudiencePresentation({ controller, fullscreen, slides, onClose, onToggleFullscreen, }: { controller: PresentationInteractionController; fullscreen: boolean; slides: SlideDefinition[]; onClose: () => void; onToggleFullscreen: () => void; }) { const deck = useDeckContext(); const messages = useLocalization(); const controlsVisible = useAutoHidingControls(); const previousDisabled = deck.slideIndex === 0 && deck.revealedCount === 0; const nextDisabled = deck.slideIndex === deck.slideCount - 1 && deck.revealedCount >= (deck.stepCounts[deck.slideIndex] ?? 0); return (
); } function useAutoHidingControls(): boolean { const [visible, setVisible] = useState(true); useEffect(() => { let timeout: number | undefined; const showControls = () => { setVisible(true); window.clearTimeout(timeout); timeout = window.setTimeout(() => setVisible(false), 2_000); }; showControls(); window.addEventListener("pointermove", showControls); window.addEventListener("touchstart", showControls); return () => { window.clearTimeout(timeout); window.removeEventListener("pointermove", showControls); window.removeEventListener("touchstart", showControls); }; }, []); return visible; }