import { useState } from "react"; import BrainActivity from "./BrainActivity"; import FlyChipStrip from "./FlyChipStrip"; import FlyControls from "./FlyControls"; import FlyList from "./FlyList"; import type { FlyInstanceData } from "./useFlyLayout"; import type { LiveFlyPositions } from "./useLiveFlyState"; import { useStatusSnapshot } from "./useStatusSnapshot"; // Exported so App.tsx can size the collapsed canvas as calc(100% - handle). export const MOBILE_SHEET_HANDLE_HEIGHT = 48; const TAB_BAR_HEIGHT = 40; type SheetTab = "controls" | "flies" | "brain"; const TABS: { id: SheetTab; label: string }[] = [ { id: "controls", label: "Controls" }, { id: "flies", label: "Flies" }, { id: "brain", label: "Brain" }, ]; interface MobileControlSheetProps { flies: FlyInstanceData[]; selectedFlyId: string | null; onSelectFly: (id: string | null) => void; joystickRef: React.RefObject<{ x: number; y: number }>; wingSlidersRef: React.RefObject<{ left: number; right: number }>; livePositionsRef: React.RefObject; expanded: boolean; onToggleExpanded: () => void; flying: boolean; onToggleFlying: () => void; altitudeLevelIndex: number; onAltitudeChange: (index: number) => void; } export default function MobileControlSheet({ flies, selectedFlyId, onSelectFly, joystickRef, wingSlidersRef, livePositionsRef, expanded, onToggleExpanded, flying, onToggleFlying, altitudeLevelIndex, onAltitudeChange, }: MobileControlSheetProps) { const statusSnapshot = useStatusSnapshot(flies, livePositionsRef); const [activeTab, setActiveTab] = useState("controls"); return (
{expanded && (
{TABS.map((tab) => ( ))}
{/* Each tab gets the FULL remaining height to itself -- avoids the previous single-column layout, where stacking FlyControls + FlyList + BrainActivity all at once needed flex-shrink to work perfectly across every nested level to fit a compact sheet, and in practice didn't: BrainActivity (last in the stack) ended up laid out far below the visible, clipped area -- present in the DOM, but never actually seen. */}
{activeTab === "controls" && ( <> )} {activeTab === "flies" && ( )} {activeTab === "brain" && }
)}
); }