import { HeaderSize, IconButton, SidebarLayout, SplitLayout } from "@yaakapp-internal/ui"; import classNames from "classnames"; import { useAtom, useAtomValue } from "jotai"; import { useState } from "react"; import { useLocalStorage } from "react-use"; import { flowLayoutAtom } from "../lib/atoms"; import { getOsType } from "../lib/tauri"; import { FlowDetail } from "./FlowDetail"; import { FlowList } from "./FlowList"; import { ProxyStatus } from "./ProxyStatus"; import { filteredExchangesAtom, selectedSidebarLabelAtom, Sidebar } from "./Sidebar"; export function ProxyLayout() { const os = getOsType(); const exchanges = useAtomValue(filteredExchangesAtom); const title = useAtomValue(selectedSidebarLabelAtom); const [flowLayout, setFlowLayout] = useAtom(flowLayoutAtom); const [sidebarWidth, setSidebarWidth] = useLocalStorage("sidebar_width", 250); const [sidebarHidden, setSidebarHidden] = useLocalStorage("sidebar_hidden", false); const [floatingSidebarHidden, setFloatingSidebarHidden] = useLocalStorage( "floating_sidebar_hidden", true, ); const [floating, setFloating] = useState(false); const isHidden = floating ? (floatingSidebarHidden ?? true) : (sidebarHidden ?? false); return (
{ if (floating) { setFloatingSidebarHidden(!floatingSidebarHidden); } else { setSidebarHidden(!sidebarHidden); } }} />
{title} {exchanges.length === 1 ? "1 flow" : `${exchanges.length} flows`}
setFlowLayout((prev) => (prev === "horizontal" ? "vertical" : "horizontal")) } />
) : ( ) } > ( )} secondSlot={({ style, orientation }) => ( )} /> ); }