import { useRef, useState, useCallback } from 'react'; import Search from '/src/pages/Search'; import { Maximize2, SquareArrowOutUpRight, ZoomIn, ZoomOut, Cloud, HardDrive, Bug, } from 'lucide-react'; import { useLocalGmLoader } from '/src/utils/hooks/player/useLocalGmLoader'; import { useNavigate } from 'react-router-dom'; import Control from './Controls'; import InfoCard from './InfoCard'; import theming from '/src/styles/theming.module.css'; import clsx from 'clsx'; import Tooltip from '@mui/material/Tooltip'; import loaderStore from '/src/utils/hooks/loader/useLoaderStore'; const Loader = ({ theme, app }) => { const nav = useNavigate(); const gmRef = useRef(null); const [zoom, setZoom] = useState(1); const { gmUrl, loading, downloading } = useLocalGmLoader(app); const isLocal = app?.local; const activeFrameRef = loaderStore((state) => state.activeFrameRef); const fs = useCallback(() => { if (gmRef.current) { gmRef.current?.requestFullscreen?.(); } else if (activeFrameRef?.current) { //browser restricts fullscreen w/o some sort of user interaction //using boolean to decide fs wont work so we directly use frame reference activeFrameRef.current?.requestFullscreen?.(); } }, [activeFrameRef]); const external = useCallback(() => { nav('/search', { state: { url: app?.url, }, }); }, [app?.url]); const handleZoom = useCallback((direction) => { setZoom((prev) => { const newZoom = direction === 'in' ? Math.min(prev + 0.1, 2) : Math.max(prev - 0.1, 0.5); if (gmRef.current) gmRef.current.style.zoom = newZoom; return newZoom; }); }, []); return (
{isLocal ? ( ) : ( )}
{loading ? (
{downloading ? 'Downloading...' : 'Loading...'}
) : isLocal ? (