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 { ClearFlowsButton } from "./ClearFlowsButton"; import { FlowDetail } from "./FlowDetail"; import { FlowList } from "./FlowList"; import { ProxyStatus } from "./ProxyStatus"; import { filteredCountAtom, selectedSidebarLabelAtom, Sidebar } from "./Sidebar"; export function ProxyLayout() { const os = getOsType(); 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}
setFlowLayout((prev) => (prev === "horizontal" ? "vertical" : "horizontal")) } />
) : ( ) } > ( )} secondSlot={({ style, orientation }) => ( )} /> ); } /** Its own component, so new traffic re-renders the count rather than the whole layout */ function FlowCount() { const count = useAtomValue(filteredCountAtom); return ( {count === 1 ? "1 flow" : `${count} flows`} ); }