import { Ionicons } from "@expo/vector-icons"; import type React from "react"; import { useMemo } from "react"; import { useTranslation } from "react-i18next"; import { View } from "react-native"; import { Stepper } from "@/components/inputs/Stepper"; import { PlatformDropdown } from "@/components/PlatformDropdown"; import { type MpvCacheMode, useSettings } from "@/utils/atoms/settings"; import { Text } from "../common/Text"; import { ListGroup } from "../list/ListGroup"; import { ListItem } from "../list/ListItem"; const CACHE_MODE_OPTIONS: { key: string; value: MpvCacheMode }[] = [ { key: "home.settings.buffer.cache_auto", value: "auto" }, { key: "home.settings.buffer.cache_yes", value: "yes" }, { key: "home.settings.buffer.cache_no", value: "no" }, ]; export const MpvBufferSettings: React.FC = () => { const { settings, updateSettings } = useSettings(); const { t } = useTranslation(); const cacheModeOptions = useMemo( () => [ { options: CACHE_MODE_OPTIONS.map((option) => ({ type: "radio" as const, label: t(option.key), value: option.value, selected: option.value === (settings?.mpvCacheEnabled ?? "auto"), onPress: () => updateSettings({ mpvCacheEnabled: option.value }), })), }, ], [settings?.mpvCacheEnabled, t, updateSettings], ); const currentCacheModeLabel = useMemo(() => { const option = CACHE_MODE_OPTIONS.find( (o) => o.value === (settings?.mpvCacheEnabled ?? "auto"), ); return option ? t(option.key) : t("home.settings.buffer.cache_auto"); }, [settings?.mpvCacheEnabled, t]); if (!settings) return null; return ( {currentCacheModeLabel} } title={t("home.settings.buffer.cache_mode")} /> updateSettings({ mpvCacheSeconds: value })} appendValue='s' /> updateSettings({ mpvDemuxerMaxBytes: value })} appendValue=' MB' /> updateSettings({ mpvDemuxerMaxBackBytes: value }) } appendValue=' MB' /> ); };