import { USE_CUSTOM_WINDOW_CONTROLS } from "@/lib/platform"; import { cn } from "@/lib/utils"; import { Cancel01Icon, Copy01Icon, MinusSignIcon, SquareIcon, } from "@hugeicons/core-free-icons"; import { HugeiconsIcon } from "@hugeicons/react"; import { getCurrentWindow } from "@tauri-apps/api/window"; import { useEffect, useState } from "react"; type Props = { /** Render only the close button (used by the settings window). */ closeOnly?: boolean; }; export function WindowControls({ closeOnly = false }: Props) { const [maximized, setMaximized] = useState(false); useEffect(() => { if (!USE_CUSTOM_WINDOW_CONTROLS || closeOnly) return; const w = getCurrentWindow(); let unlisten: (() => void) | undefined; void w.isMaximized().then(setMaximized); void w .onResized(() => { void w.isMaximized().then(setMaximized); }) .then((un) => { unlisten = un; }); return () => unlisten?.(); }, [closeOnly]); if (!USE_CUSTOM_WINDOW_CONTROLS) return null; const w = getCurrentWindow(); return (
{!closeOnly && ( <> void w.minimize()}> void w.toggleMaximize()} > )} void w.close()} danger>
); } function CtlButton({ ariaLabel, onClick, children, danger, }: { ariaLabel: string; onClick: () => void; children: React.ReactNode; danger?: boolean; }) { return ( ); }