import { HeaderSize, IconButton, SidebarLayout, SplitLayout, type SplitLayoutLayout, Toasts, } 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 { searchWindowAtom, showFirstRunAtom, shownTotalAtom } from "../lib/store"; import { getOsType } from "../lib/tauri"; import { ClearFlowsButton } from "./ClearFlowsButton"; import { FirstRun } from "./FirstRun"; import { FlowDetail } from "./FlowDetail"; import { FlowList } from "./FlowList"; import { ProxyStatus } from "./ProxyStatus"; import { HelperDialog } from "./HelperDialog"; import { SaveDialog } from "./SaveDialog"; import { selectedSidebarLabelAtom, Sidebar } from "./Sidebar"; import { TakeOverBanner } from "./TakeOverBanner"; 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")) } />
) : ( ) } >
); } /** Its own component, so new traffic re-renders the count rather than the whole layout */ function FlowCount() { const count = useAtomValue(shownTotalAtom); const searching = useAtomValue(searchWindowAtom) != null; const noun = searching ? (count === 1 ? "match" : "matches") : count === 1 ? "flow" : "flows"; return {`${count} ${noun}`}; } /** * The flow list above the detail pane, or, while the database has no flows at all, the first-run * card across the whole area: it is the empty state until traffic replaces it. */ function FlowsOrFirstRun({ flowLayout }: { flowLayout: SplitLayoutLayout }) { if (useAtomValue(showFirstRunAtom)) return ; return ( ( )} secondSlot={({ style, orientation }) => ( )} /> ); }