From dc498d62d8ec95e5758862d243ef226c6f32f1b1 Mon Sep 17 00:00:00 2001 From: herrrta <73949927+herrrta@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:44:37 -0500 Subject: [PATCH] feat: [StreamyfinPlugin] Other settings --- .../(home)/settings/hide-libraries/page.tsx | 10 +- components/settings/OtherSettings.tsx | 245 ++++++++---------- 2 files changed, 113 insertions(+), 142 deletions(-) diff --git a/app/(auth)/(tabs)/(home)/settings/hide-libraries/page.tsx b/app/(auth)/(tabs)/(home)/settings/hide-libraries/page.tsx index 6919441e..35200bc1 100644 --- a/app/(auth)/(tabs)/(home)/settings/hide-libraries/page.tsx +++ b/app/(auth)/(tabs)/(home)/settings/hide-libraries/page.tsx @@ -8,9 +8,10 @@ import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api"; import { useQuery } from "@tanstack/react-query"; import { useAtomValue } from "jotai"; import { Switch, View } from "react-native"; +import DisabledSetting from "@/components/settings/DisabledSetting"; export default function page() { - const [settings, updateSettings] = useSettings(); + const [settings, updateSettings, pluginSettings] = useSettings(); const user = useAtomValue(userAtom); const api = useAtomValue(apiAtom); @@ -35,7 +36,10 @@ export default function page() { ); return ( - + {data?.map((view) => ( {}}> @@ -56,6 +60,6 @@ export default function page() { Select the libraries you want to hide from the Library tab and home page sections. - + ); } diff --git a/components/settings/OtherSettings.tsx b/components/settings/OtherSettings.tsx index cbd8fc18..dcea3f26 100644 --- a/components/settings/OtherSettings.tsx +++ b/components/settings/OtherSettings.tsx @@ -9,19 +9,18 @@ import * as BackgroundFetch from "expo-background-fetch"; import { useRouter } from "expo-router"; import * as ScreenOrientation from "expo-screen-orientation"; import * as TaskManager from "expo-task-manager"; -import React, { useEffect } from "react"; -import { Linking, Switch, TouchableOpacity, ViewProps } from "react-native"; +import React, {useEffect, useMemo} from "react"; +import { Linking, Switch, TouchableOpacity } from "react-native"; import { toast } from "sonner-native"; -import * as DropdownMenu from "zeego/dropdown-menu"; import { Text } from "../common/Text"; import { ListGroup } from "../list/ListGroup"; import { ListItem } from "../list/ListItem"; - -interface Props extends ViewProps {} +import DisabledSetting from "@/components/settings/DisabledSetting"; +import Dropdown from "@/components/common/Dropdown"; export const OtherSettings: React.FC = () => { const router = useRouter(); - const [settings, updateSettings] = useSettings(); + const [settings, updateSettings, pluginSettings] = useSettings(); /******************** * Background task @@ -53,146 +52,114 @@ export const OtherSettings: React.FC = () => { /********************** *********************/ + const disabled = useMemo(() => ( + pluginSettings?.autoRotate?.locked === true && + 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 + ] + if (!settings) return null; return ( - - - updateSettings({ autoRotate: value })} - /> - + + + + updateSettings({autoRotate: value})} + /> + - - - - - - {ScreenOrientationEnum[settings.defaultVideoOrientation]} - - - - - - Orientation - { - updateSettings({ - defaultVideoOrientation: - ScreenOrientation.OrientationLock.DEFAULT, - }); - }} - > - - { - ScreenOrientationEnum[ - ScreenOrientation.OrientationLock.DEFAULT - ] - } - - - { - updateSettings({ - defaultVideoOrientation: - ScreenOrientation.OrientationLock.PORTRAIT_UP, - }); - }} - > - - { - ScreenOrientationEnum[ - ScreenOrientation.OrientationLock.PORTRAIT_UP - ] - } - - - { - updateSettings({ - defaultVideoOrientation: - ScreenOrientation.OrientationLock.LANDSCAPE_LEFT, - }); - }} - > - - { - ScreenOrientationEnum[ - ScreenOrientation.OrientationLock.LANDSCAPE_LEFT - ] - } - - - { - updateSettings({ - defaultVideoOrientation: - ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT, - }); - }} - > - - { - ScreenOrientationEnum[ - ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT - ] - } - - - - - + + + ScreenOrientationEnum[item] + } + title={ + + + {ScreenOrientationEnum[settings.defaultVideoOrientation]} + + + + } + label="Orientation" + onSelected={(defaultVideoOrientation) => + updateSettings({defaultVideoOrientation}) + } + /> + - - - updateSettings({ safeAreaInControlsEnabled: value }) - } - /> - + + + updateSettings({safeAreaInControlsEnabled: value}) + } + /> + - - Linking.openURL( - "https://jellyfin.org/docs/general/clients/web-config/#custom-menu-links" - ) - } - > - - updateSettings({ showCustomMenuLinks: value }) + + Linking.openURL( + "https://jellyfin.org/docs/general/clients/web-config/#custom-menu-links" + ) } + > + + updateSettings({showCustomMenuLinks: value}) + } + /> + + router.push("/settings/hide-libraries/page")} + title="Hide Libraries" + showArrow /> - - router.push("/settings/hide-libraries/page")} - title="Hide Libraries" - showArrow - /> - - - updateSettings({ disableHapticFeedback: value }) - } - /> - - + + + updateSettings({disableHapticFeedback}) + } + /> + + + ); };