/* ============================================================ 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 localeZhHK from "@/locales/data-zh-HK.json"; import localeEn from "@/locales/data-en.json"; 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: ( ), }, { index: 6, icon: ( ), }, { index: 7, icon: ( ), }, ]; const OUTPUT_OPTION_DEFS: IOOptionDef[] = [ { index: 0, icon: ( ), }, { index: 1, icon: ( ), }, { index: 3, icon: ( ), }, { index: 2, icon: ( ), }, ]; const FALLBACK_INPUT_LABELS = ["USB-B", "USB-C", "同轴", "光纤", "蓝牙", "HDMI-EARC", "RCA", "USB Driver"]; 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 lang = deviceState?.language; const pack = lang === 0 ? localeEn : lang === 1 ? localeZhHK : localeZh; 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 = sourceText.pageTitle ?? sourceText.label ?? "输入输出"; const inputSectionTitle = sourceText.inputSection ?? "输入"; const outputSectionTitle = sourceText.outputSection ?? "输出"; const currentInput = deviceState?.input ?? 1; const currentOutput = deviceState?.output ?? 2; return (

{ioPageTitle}

{inputSectionTitle}

{inputOptions.map((opt) => ( setInput(opt.index)} /> ))}

{outputSectionTitle}

{outputOptions.map((opt) => ( setOutput(opt.index)} /> ))}
); }