import { useState } from "react"; import { useTranslation } from "react-i18next"; import { ChevronDown, Hand } from "lucide-react"; import { Button } from "@/components/button"; import { Input } from "@/components/input"; import { SettingRow } from "@/components/section-card"; import type { TouchInputNumericKey, TouchInputSettings, } from "@/types/touch-input-settings"; import { TOUCH_INPUT_NUMERIC_BOUNDS } from "@/types/touch-input-settings"; import { AccordionSection, AdminToggle } from "./AdminSettingsShared"; const fields: Array<{ key: TouchInputNumericKey; label: string; unit: string; }> = [ { key: "dragThresholdPx", label: "touchDragThreshold", unit: "px" }, { key: "maxWheelDeltaPx", label: "touchMaxWheelDelta", unit: "px" }, { key: "momentumSampleWindowMs", label: "touchMomentumSampleWindow", unit: "ms", }, { key: "releaseGracePeriodMs", label: "touchReleaseGracePeriod", unit: "ms", }, { key: "minimumVelocityPxPerMs", label: "touchMinimumVelocity", unit: "px/ms", }, { key: "maximumVelocityPxPerMs", label: "touchMaximumVelocity", unit: "px/ms", }, { key: "maximumDurationMs", label: "touchMaximumDuration", unit: "ms" }, { key: "maximumTravelPx", label: "touchMaximumTravel", unit: "px" }, { key: "decayTimeMs", label: "touchDecayTime", unit: "ms" }, { key: "pixelsPerTick", label: "touchPixelsPerTick", unit: "px" }, { key: "maximumFrameIntervalMs", label: "touchMaximumFrameInterval", unit: "ms", }, { key: "maximumTicksPerFrame", label: "touchMaximumTicksPerFrame", unit: "", }, ]; export function AdminTouchInputSection({ open, onToggle, settings, setSettings, onSave, onReset, }: { open: boolean; onToggle: () => void; settings: TouchInputSettings; setSettings: (settings: TouchInputSettings) => void; onSave: () => void; onReset: () => void; }) { const { t } = useTranslation(); const [advancedOpen, setAdvancedOpen] = useState(false); return ( } open={open} onToggle={onToggle} >
setSettings({ ...settings, enabled: !settings.enabled }) } /> setSettings({ ...settings, momentumEnabled: !settings.momentumEnabled, }) } disabled={!settings.enabled} /> {advancedOpen && (
{fields.map(({ key, label, unit }) => { const bounds = TOUCH_INPUT_NUMERIC_BOUNDS[key]; return ( ); })}
)}
); }