import { Ionicons } from "@expo/vector-icons"; import { useRouter } from "expo-router"; import { TFunction } from "i18next"; import type React from "react"; import { useMemo } from "react"; import { useTranslation } from "react-i18next"; import { Linking, Switch, View } from "react-native"; import { BITRATES } from "@/components/BitrateSelector"; import { PlatformDropdown } from "@/components/PlatformDropdown"; import DisabledSetting from "@/components/settings/DisabledSetting"; import * as ScreenOrientation from "@/packages/expo-screen-orientation"; import { ScreenOrientationEnum, useSettings } from "@/utils/atoms/settings"; import { Text } from "../common/Text"; import { ListGroup } from "../list/ListGroup"; import { ListItem } from "../list/ListItem"; export const OtherSettings: React.FC = () => { const router = useRouter(); const { settings, updateSettings, pluginSettings } = useSettings(); const { t } = useTranslation(); const disabled = useMemo( () => pluginSettings?.defaultVideoOrientation?.locked === true && pluginSettings?.safeAreaInControlsEnabled?.locked === true && pluginSettings?.showCustomMenuLinks?.locked === true && pluginSettings?.hiddenLibraries?.locked === true && pluginSettings?.disableHapticFeedback?.locked === true, [pluginSettings], ); const orientations = [ ScreenOrientation.OrientationLock.DEFAULT, ScreenOrientation.OrientationLock.PORTRAIT_UP, ScreenOrientation.OrientationLock.LANDSCAPE_LEFT, ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT, ]; const orientationTranslations = useMemo( () => ({ [ScreenOrientation.OrientationLock.DEFAULT]: "home.settings.other.orientations.DEFAULT", [ScreenOrientation.OrientationLock.PORTRAIT_UP]: "home.settings.other.orientations.PORTRAIT_UP", [ScreenOrientation.OrientationLock.LANDSCAPE_LEFT]: "home.settings.other.orientations.LANDSCAPE_LEFT", [ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT]: "home.settings.other.orientations.LANDSCAPE_RIGHT", }), [], ); const orientationOptions = useMemo( () => [ { options: orientations.map((orientation) => ({ type: "radio" as const, label: t(ScreenOrientationEnum[orientation]), value: String(orientation), selected: orientation === settings?.defaultVideoOrientation, onPress: () => updateSettings({ defaultVideoOrientation: orientation }), })), }, ], [orientations, settings?.defaultVideoOrientation, t, updateSettings], ); const bitrateOptions = useMemo( () => [ { options: BITRATES.map((bitrate) => ({ type: "radio" as const, label: bitrate.key, value: bitrate.key, selected: bitrate.key === settings?.defaultBitrate?.key, onPress: () => updateSettings({ defaultBitrate: bitrate }), })), }, ], [settings?.defaultBitrate?.key, t, updateSettings], ); const autoPlayEpisodeOptions = useMemo( () => [ { options: AUTOPLAY_EPISODES_COUNT(t).map((item) => ({ type: "radio" as const, label: item.key, value: item.key, selected: item.key === settings?.maxAutoPlayEpisodeCount?.key, onPress: () => updateSettings({ maxAutoPlayEpisodeCount: item }), })), }, ], [settings?.maxAutoPlayEpisodeCount?.key, t, updateSettings], ); if (!settings) return null; return ( {t( orientationTranslations[ settings.defaultVideoOrientation as keyof typeof orientationTranslations ], ) || "Unknown Orientation"} } title={t("home.settings.other.orientation")} /> updateSettings({ safeAreaInControlsEnabled: value }) } /> Linking.openURL( "https://jellyfin.org/docs/general/clients/web-config/#custom-menu-links", ) } > updateSettings({ showCustomMenuLinks: value }) } /> updateSettings({ showLargeHomeCarousel: value }) } /> router.push("/settings/hide-libraries/page")} title={t("home.settings.other.hide_libraries")} showArrow /> {settings.defaultBitrate?.key} } title={t("home.settings.other.default_quality")} /> updateSettings({ disableHapticFeedback }) } /> {t(settings?.maxAutoPlayEpisodeCount.key)} } title={t("home.settings.other.max_auto_play_episode_count")} /> ); }; const AUTOPLAY_EPISODES_COUNT = ( t: TFunction<"translation", undefined>, ): { key: string; value: number; }[] => [ { key: t("home.settings.other.disabled"), value: -1 }, { key: "1", value: 1 }, { key: "2", value: 2 }, { key: "3", value: 3 }, { key: "4", value: 4 }, { key: "5", value: 5 }, { key: "6", value: 6 }, { key: "7", value: 7 }, ];