diff --git a/src/app/room/page.tsx b/src/app/room/page.tsx index 253ef5f..fb08f0d 100644 --- a/src/app/room/page.tsx +++ b/src/app/room/page.tsx @@ -3,7 +3,7 @@ import { useEffect, useRef, useState, useCallback, Suspense } from "react"; import { useSearchParams, useRouter } from "next/navigation"; import { io, type Socket } from "socket.io-client"; -import { Download, PanelRightClose, Square, X } from "lucide-react"; +import { Download, Maximize, PanelRightClose, Square, X } from "lucide-react"; import type { ImperativePanelHandle } from "react-resizable-panels"; import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/components/ui/resizable"; @@ -169,6 +169,7 @@ function RoomInner() { const [endingSession, setEndingSession] = useState(false); const chatHistoryRef = useRef([]); const chatPanelRef = useRef(null); + const [isPresenting, setIsPresenting] = useState(false); const slideContextRef = useRef({ slidePageIndex: null, slideSetId: null, @@ -403,6 +404,8 @@ function RoomInner() { onEndLecture={isProfessor ? () => setShowEndModal(true) : undefined} onSlideContextChange={handleSlideContextChange} slideNavTarget={slideNavTarget} + isPresenting={isPresenting} + onExitPresenting={() => setIsPresenting(false)} /> @@ -425,14 +428,24 @@ function RoomInner() { {!isChatVisible && ( - +
+ + +
)} diff --git a/src/app/room/slideViewer.tsx b/src/app/room/slideViewer.tsx index 42caa01..247dbff 100644 --- a/src/app/room/slideViewer.tsx +++ b/src/app/room/slideViewer.tsx @@ -10,6 +10,7 @@ import { SquareMousePointer, Upload, LogOut, + Minimize, Unlink, Undo2, } from "lucide-react"; @@ -38,6 +39,8 @@ interface SlideViewerProps { onEndLecture?: () => void; onSlideContextChange?: (ctx: SlideContextSnapshot) => void; slideNavTarget?: SlideContextSnapshot | null; + isPresenting?: boolean; + onExitPresenting?: () => void; } // --------------------------------------------------------------------------- @@ -64,6 +67,8 @@ interface SlideUIProps { onSlideContextChange?: (ctx: SlideContextSnapshot) => void; onReplaceSlides?: (file: File) => void; onEndLecture?: () => void; + isPresenting?: boolean; + onExitPresenting?: () => void; } function SlideUI({ @@ -74,6 +79,8 @@ function SlideUI({ onSlideContextChange, onReplaceSlides, onEndLecture, + isPresenting, + onExitPresenting, }: SlideUIProps) { const { socket, sessionId, userId, role, slideReturnTarget, goBackToPreviousSlide } = useRoom(); const router = useRouter(); @@ -239,6 +246,26 @@ function SlideUI({ [pageCount, navigateToLocal, isControlling, socket, sessionId] ); + // ------------------------------------------------------------------------- + // Presenter view — slides fill the tab + // ------------------------------------------------------------------------- + + // The controls bar is hidden while presenting, so a follower has no "Back to + // Live" — leave them following rather than silently detaching them. + const canStep = isPresenting && (isControlling || mode === "browsing"); + + useEffect(() => { + if (!isPresenting) return; + const onKey = (e: KeyboardEvent) => { + if (e.key === "Escape") onExitPresenting?.(); + else if (!canStep) return; + else if (e.key === "ArrowRight") navigateTo(pageIndex + 1); + else if (e.key === "ArrowLeft") navigateTo(pageIndex - 1); + }; + document.addEventListener("keydown", onKey); + return () => document.removeEventListener("keydown", onKey); + }, [isPresenting, canStep, onExitPresenting, navigateTo, pageIndex]); + // Question-badge jump: the person driving takes the room with them; everyone // else detaches and looks on their own. useEffect(() => { @@ -337,7 +364,23 @@ function SlideUI({ // ------------------------------------------------------------------------- return ( -
+
navigateTo(pageIndex + 1) : undefined} + className={`flex flex-col w-full min-h-0 ${isPresenting ? "fixed inset-0 z-50 bg-black" : "flex-1"}`} + > + {isPresenting && ( + + )} {/* Slide canvas */} {activeDocumentId ? ( @@ -364,8 +407,10 @@ function SlideUI({
)} - {/* Controls bar — always rendered */} -
+ {/* Controls bar — always rendered, hidden while presenting */} +
{slideReturnTarget?.slidePageIndex != null && ( <> @@ -651,6 +696,8 @@ export default function SlideViewer({ onEndLecture, onSlideContextChange, slideNavTarget, + isPresenting, + onExitPresenting, }: SlideViewerProps) { const { engine, isLoading: engineLoading } = usePdfiumEngine(); const { sessionId, socket } = useRoom(); @@ -850,6 +897,8 @@ export default function SlideViewer({ onSlideContextChange={onSlideContextChange} onReplaceSlides={isProfessor ? handleUpload : undefined} onEndLecture={isProfessor ? onEndLecture : undefined} + isPresenting={isPresenting} + onExitPresenting={onExitPresenting} /> )}