/* ============================================================ IO PAGE — Input / Output Selection Design: Reference luxsin_x8_输入输出.jpg - Circular icon buttons in a grid (3 cols) - Active = cyan fill + glow - Inactive = dark gray circle ============================================================ */ import { useDevice } from "@/contexts/DeviceContext"; import { cn } from "@/lib/utils"; import BottomNav from "@/components/BottomNav"; import { ChevronLeft } from "lucide-react"; import { useLocation } from "wouter"; import { useMemo } from "react"; import localeZh from "@/locales/data-zh.json"; import localeEn from "@/locales/data-en.json"; import { resolveLocalePack } from "@/locales/resolveLocale"; import { usePageTitleWithConnection } from "@/hooks/usePageTitleWithConnection"; type SourceLocale = NonNullable<(typeof localeZh)["source"]>; interface IOOption { index: number; label: string; icon: React.ReactNode; } interface IOOptionDef { index: number; icon: React.ReactNode; } const INPUT_OPTION_DEFS: IOOptionDef[] = [ { index: 0, icon: ( ), }, { index: 1, icon: ( ), }, { index: 2, icon: ( ), }, { index: 3, icon: ( ), }, { index: 4, icon: ( ), }, { index: 5, icon: ( ), }, ]; const OUTPUT_OPTION_DEFS: IOOptionDef[] = [ { index: 0, icon: ( ), }, { index: 1, icon: ( ), }, { index: 2, icon: ( ), }, { index: 3, icon: ( ), }, ]; const FALLBACK_INPUT_LABELS = ["USB-B", "USB-C", "同轴", "光纤", "蓝牙", "IIS"]; const FALLBACK_OUTPUT_LABELS = ["XLR", "RCA", "耳机", "XLR/RCA"]; function withLabels(defs: IOOptionDef[], labels: string[] | undefined, fallback: string[]): IOOption[] { return defs.map((def, i) => ({ ...def, label: labels?.[i] ?? fallback[i] ?? String(def.index), })); } function IOCircleButton({ option, active, onSelect, }: { option: IOOption; active: boolean; onSelect: () => void; }) { return ( ); } export default function IOPage() { const [, setLocation] = useLocation(); const { deviceState, setInput, setOutput } = useDevice(); const sourceText = useMemo((): SourceLocale => { const pack = resolveLocalePack(deviceState?.language); return (pack.source ?? {}) as SourceLocale; }, [deviceState?.language]); const inputOptions = useMemo( () => withLabels(INPUT_OPTION_DEFS, sourceText.inputOptions, FALLBACK_INPUT_LABELS), [sourceText.inputOptions], ); const outputOptions = useMemo( () => withLabels(OUTPUT_OPTION_DEFS, sourceText.outputOptions, FALLBACK_OUTPUT_LABELS), [sourceText.outputOptions], ); const ioPageTitle = usePageTitleWithConnection( sourceText.pageTitle ?? sourceText.label ?? "I/O", ); const inputSectionTitle = sourceText.inputSection ?? "输入"; const outputSectionTitle = sourceText.outputSection ?? "输出"; const currentInput = deviceState?.input ?? 1; const currentOutput = deviceState?.output ?? 2; return (
{inputSectionTitle}
{outputSectionTitle}