import { apiAtom, userAtom } from "@/providers/JellyfinProvider"; import { DownloadOptions, useSettings } from "@/utils/atoms/settings"; import { getItemsApi } from "@jellyfin/sdk/lib/utils/api"; import { useQuery, useQueryClient } from "@tanstack/react-query"; import { useAtom } from "jotai"; import { Linking, Switch, TouchableOpacity, View } from "react-native"; import * as DropdownMenu from "zeego/dropdown-menu"; import { Text } from "../common/Text"; import { Loader } from "../Loader"; import { Input } from "../common/Input"; import { useState } from "react"; import { Button } from "../Button"; export const SettingToggles: React.FC = () => { const [settings, updateSettings] = useSettings(); const [api] = useAtom(apiAtom); const [user] = useAtom(userAtom); const [marlinUrl, setMarlinUrl] = useState(""); const queryClient = useQueryClient(); const { data: mediaListCollections, isLoading: isLoadingMediaListCollections, } = useQuery({ queryKey: ["sf_promoted", user?.Id, settings?.usePopularPlugin], queryFn: async () => { if (!api || !user?.Id) return []; const response = await getItemsApi(api).getItems({ userId: user.Id, tags: ["sf_promoted"], recursive: true, fields: ["Tags"], includeItemTypes: ["BoxSet"], }); return response.data.Items ?? []; }, enabled: !!api && !!user?.Id && settings?.usePopularPlugin === true, staleTime: 0, }); return ( Auto rotate Important on android since the video player orientation is locked to the app orientation. updateSettings({ autoRotate: value })} /> Download quality Choose the search engine you want to use. {settings?.downloadQuality?.label} Quality {DownloadOptions.map((option) => ( { updateSettings({ downloadQuality: option }); }} > {option.label} ))} Start videos in fullscreen Clicking a video will start it in fullscreen mode, instead of inline. updateSettings({ openFullScreenVideoPlayerByDefault: value }) } /> Use external player (VLC) Open all videos in VLC instead of the default player. This requries VLC to be installed on the phone. { updateSettings({ openInVLC: value, forceDirectPlay: value }); }} /> Use popular lists plugin Made by: lostb1t { Linking.openURL( "https://github.com/lostb1t/jellyfin-plugin-media-lists" ); }} > More info updateSettings({ usePopularPlugin: value }) } /> {settings?.usePopularPlugin && ( {mediaListCollections?.map((mlc) => ( {mlc.Name} { if (!settings.mediaListCollectionIds) { updateSettings({ mediaListCollectionIds: [mlc.Id!], }); return; } updateSettings({ mediaListCollectionIds: settings?.mediaListCollectionIds.includes(mlc.Id!) ? settings?.mediaListCollectionIds.filter( (id) => id !== mlc.Id ) : [...settings?.mediaListCollectionIds, mlc.Id!], }); }} /> ))} {isLoadingMediaListCollections && ( )} {mediaListCollections?.length === 0 && ( No collections found. Add some in Jellyfin. )} )} Force direct play This will always request direct play. This is good if you want to try to stream movies you think the device supports. updateSettings({ forceDirectPlay: value })} /> Device profile A profile used for deciding what audio and video codecs the device supports. {settings?.deviceProfile} Profiles { updateSettings({ deviceProfile: "Expo" }); }} > Expo { updateSettings({ deviceProfile: "Native" }); }} > Native { updateSettings({ deviceProfile: "Old" }); }} > Old Search engine Choose the search engine you want to use. {settings?.searchEngine} Profiles { updateSettings({ searchEngine: "Jellyfin" }); queryClient.invalidateQueries({ queryKey: ["search"] }); }} > Jellyfin { updateSettings({ searchEngine: "Marlin" }); queryClient.invalidateQueries({ queryKey: ["search"] }); }} > Marlin {settings?.searchEngine === "Marlin" && ( <> setMarlinUrl(text)} /> {settings?.marlinServerUrl} )} ); };