import { Ionicons } from "@expo/vector-icons"; import { useMemo } from "react"; import { useTranslation } from "react-i18next"; import { Platform, View, type ViewProps } from "react-native"; import { Switch } from "react-native-gesture-handler"; import { OUTLINE_THICKNESS_OPTIONS, VLC_COLOR_OPTIONS, } from "@/constants/SubtitleConstants"; import { useSettings, VideoPlayerIOS } from "@/utils/atoms/settings"; import { Text } from "../common/Text"; import { Stepper } from "../inputs/Stepper"; import { ListGroup } from "../list/ListGroup"; import { ListItem } from "../list/ListItem"; import { PlatformDropdown } from "../PlatformDropdown"; interface Props extends ViewProps {} /** * VLC Subtitle Settings component * Only shown when VLC is the active player (Android always, iOS when VLC selected) * Note: These settings are applied via VLC init options and take effect on next playback */ export const VlcSubtitleSettings: React.FC = ({ ...props }) => { const { t } = useTranslation(); const { settings, updateSettings } = useSettings(); // Only show for VLC users const isVlcPlayer = Platform.OS === "android" || (Platform.OS === "ios" && settings.videoPlayerIOS === VideoPlayerIOS.VLC); const textColorOptions = useMemo( () => [ { options: VLC_COLOR_OPTIONS.map((color) => ({ type: "radio" as const, label: color, value: color, selected: settings.vlcTextColor === color, onPress: () => updateSettings({ vlcTextColor: color }), })), }, ], [settings.vlcTextColor, updateSettings], ); const backgroundColorOptions = useMemo( () => [ { options: VLC_COLOR_OPTIONS.map((color) => ({ type: "radio" as const, label: color, value: color, selected: settings.vlcBackgroundColor === color, onPress: () => updateSettings({ vlcBackgroundColor: color }), })), }, ], [settings.vlcBackgroundColor, updateSettings], ); const outlineColorOptions = useMemo( () => [ { options: VLC_COLOR_OPTIONS.map((color) => ({ type: "radio" as const, label: color, value: color, selected: settings.vlcOutlineColor === color, onPress: () => updateSettings({ vlcOutlineColor: color }), })), }, ], [settings.vlcOutlineColor, updateSettings], ); const outlineThicknessOptions = useMemo( () => [ { options: OUTLINE_THICKNESS_OPTIONS.map((thickness) => ({ type: "radio" as const, label: thickness, value: thickness, selected: settings.vlcOutlineThickness === thickness, onPress: () => updateSettings({ vlcOutlineThickness: thickness }), })), }, ], [settings.vlcOutlineThickness, updateSettings], ); if (!isVlcPlayer) return null; if (Platform.isTV) return null; return ( {t("home.settings.vlc_subtitles.hint")} } > {/* Text Color */} {settings.vlcTextColor || "White"} } title={t("home.settings.vlc_subtitles.text_color")} /> {/* Background Color */} {settings.vlcBackgroundColor || "Black"} } title={t("home.settings.vlc_subtitles.background_color")} /> {/* Background Opacity */} updateSettings({ vlcBackgroundOpacity: Math.round((value / 100) * 255), }) } /> {/* Outline Color */} {settings.vlcOutlineColor || "Black"} } title={t("home.settings.vlc_subtitles.outline_color")} /> {/* Outline Opacity */} updateSettings({ vlcOutlineOpacity: Math.round((value / 100) * 255), }) } /> {/* Outline Thickness */} {settings.vlcOutlineThickness || "Normal"} } title={t("home.settings.vlc_subtitles.outline_thickness")} /> {/* Bold Text */} updateSettings({ vlcIsBold: value })} /> {/* Subtitle Margin */} updateSettings({ vlcSubtitleMargin: Math.round(value) }) } /> ); };