import { createSignal, For } from "solid-js"; import { useKeyboard } from "@opentui/solid"; import { SourceManager } from "./SourceManager"; import { useTheme } from "@/context/ThemeContext"; import { PreferencesPanel } from "./PreferencesPanel"; import { SyncPanel } from "./SyncPanel"; import { VisualizerSettings } from "./VisualizerSettings"; type SettingsScreenProps = { accountLabel: string; accountStatus: "signed-in" | "signed-out"; onOpenAccount?: () => void; onExit?: () => void; }; type SectionId = "sync" | "sources" | "preferences" | "visualizer" | "account"; const SECTIONS: Array<{ id: SectionId; label: string }> = [ { id: "sync", label: "Sync" }, { id: "sources", label: "Sources" }, { id: "preferences", label: "Preferences" }, { id: "visualizer", label: "Visualizer" }, { id: "account", label: "Account" }, ]; export function SettingsPage(props: SettingsScreenProps) { const { theme } = useTheme(); const [activeSection, setActiveSection] = createSignal("sync"); useKeyboard((key) => { if (key.name === "escape") { props.onExit?.(); return; } if (key.name === "tab") { const idx = SECTIONS.findIndex((s) => s.id === activeSection()); const next = key.shift ? (idx - 1 + SECTIONS.length) % SECTIONS.length : (idx + 1) % SECTIONS.length; setActiveSection(SECTIONS[next].id); return; } if (key.name === "1") setActiveSection("sync"); if (key.name === "2") setActiveSection("sources"); if (key.name === "3") setActiveSection("preferences"); if (key.name === "4") setActiveSection("visualizer"); if (key.name === "5") setActiveSection("account"); }); return ( Settings [Tab] Switch section | 1-5 jump | Esc up {(section, index) => ( setActiveSection(section.id)} > [{index() + 1}] {section.label} )} {activeSection() === "sync" && } {activeSection() === "sources" && } {activeSection() === "preferences" && } {activeSection() === "visualizer" && } {activeSection() === "account" && ( Account Status: {props.accountLabel} props.onOpenAccount?.()}> [A] Manage Account )} Enter to dive | Esc up ); }