import { Card, CardContent, Button, Tooltip, TooltipContent, TooltipTrigger, useIsMobile, cn, } from "@methanium/ui"; import { useEffect, useState } from "react"; import MuteButton from "./buttons/mute"; import DeafButton from "./buttons/deaf"; import MediaShareButton from "./buttons/mediaShare"; import LeaveButton from "./buttons/leave"; import { setCallIsPopout, setUsersInFocusedViewHidden, stopWatchingFocusedStream, triggerCallLayoutCalculation, useCall, } from "../store"; import InviteButton from "./buttons/invite"; import { ChevronDown, ChevronUp, Maximize, Minimize, ScreenShareOff, SquareArrowOutDownLeft, SquareArrowOutUpRight, } from "lucide-react"; import { useStorage } from "@tensamin/storage/context"; export default function Actions() { const sharedClasses = "w-14! h-10!"; const sharedIconSize = 15; const view = useCall((state) => state.view); const focusedParticipantId = useCall((state) => state.focusedParticipantId); const watchedStreamParticipantIds = useCall( (state) => state.watchedStreamParticipantIds, ); const isWatchingFocusedStream = view === "focused" && focusedParticipantId != null && watchedStreamParticipantIds.includes(focusedParticipantId); const { load } = useStorage(); const [ownId, setOwnId] = useState(0); useEffect(() => { load("user_id").then(setOwnId); }, [load]); // Fullscreen stuff const callIsPopout = useCall((state) => state.callIsPopout); const callIsFullscreen = useCall((state) => state.callIsFullscreen); const screenRef = useCall((state) => state.screenRef); const [portalContainer, setPortalContainer] = useState(); useEffect(() => { setPortalContainer(screenRef?.current ?? undefined); }, [screenRef]); const toggleFullscreen = async () => { const screen = screenRef?.current; const fullscreenDocument = screen?.ownerDocument ?? document; if (callIsFullscreen) { await fullscreenDocument.exitFullscreen().catch(() => undefined); } else { await screen?.requestFullscreen().catch(() => undefined); } triggerCallLayoutCalculation(); }; // Hide users in focused view const usersInFocusedViewHidden = useCall( (state) => state.usersInFocusedViewHidden, ); const isMobile = useIsMobile(); return (
{!isMobile && (
{view === "focused" && ( ( )} /> Hide users )}
)} {isWatchingFocusedStream && focusedParticipantId !== ownId ? ( ( )} /> Stop watching ) : ( )} {!isMobile && (
( )} /> Popout ( )} /> Fullscreen
)}
); }