From f6333b49d35106f17fa7b7fc0311470e6a8250d8 Mon Sep 17 00:00:00 2001 From: Gauvain Date: Thu, 4 Jun 2026 00:15:50 +0200 Subject: [PATCH] fix(settings): use gorhom bottom sheet for QuickConnect (expo-ui needs a native rebuild) --- components/settings/QuickConnect.tsx | 30 ++++++++++++++++++++-------- utils/expoUiBottomSheet.ts | 24 ---------------------- 2 files changed, 22 insertions(+), 32 deletions(-) delete mode 100644 utils/expoUiBottomSheet.ts diff --git a/components/settings/QuickConnect.tsx b/components/settings/QuickConnect.tsx index dbb1c32de..d6a60ae50 100644 --- a/components/settings/QuickConnect.tsx +++ b/components/settings/QuickConnect.tsx @@ -1,3 +1,9 @@ +import { + BottomSheetBackdrop, + type BottomSheetBackdropProps, + BottomSheetModal, + BottomSheetView, +} from "@gorhom/bottom-sheet"; import { getQuickConnectApi } from "@jellyfin/sdk/lib/utils/api"; import { useAtom } from "jotai"; import { @@ -12,11 +18,6 @@ import { useTranslation } from "react-i18next"; import { Alert, Platform, View } from "react-native"; import { useHaptic } from "@/hooks/useHaptic"; import { apiAtom, userAtom } from "@/providers/JellyfinProvider"; -import { - type BottomSheetMethods, - BottomSheetModal, - BottomSheetView, -} from "@/utils/expoUiBottomSheet"; import { Button } from "../Button"; import { Text } from "../common/Text"; import { PinInput } from "../inputs/PinInput"; @@ -29,7 +30,7 @@ export const QuickConnectSheet = forwardRef( const [api] = useAtom(apiAtom); const [user] = useAtom(userAtom); const [quickConnectCode, setQuickConnectCode] = useState(); - const modalRef = useRef(null); + const modalRef = useRef(null); const successHapticFeedback = useHaptic("success"); const errorHapticFeedback = useHaptic("error"); const snapPoints = useMemo( @@ -50,6 +51,17 @@ export const QuickConnectSheet = forwardRef( [], ); + const renderBackdrop = useCallback( + (props: BottomSheetBackdropProps) => ( + + ), + [], + ); + const authorizeQuickConnect = useCallback(async () => { if (!quickConnectCode) return; try { @@ -64,7 +76,7 @@ export const QuickConnectSheet = forwardRef( t("home.settings.quick_connect.quick_connect_autorized"), ); setQuickConnectCode(undefined); - modalRef.current?.close(); + modalRef.current?.dismiss(); } else { errorHapticFeedback(); Alert.alert( @@ -93,12 +105,14 @@ export const QuickConnectSheet = forwardRef( return ( diff --git a/utils/expoUiBottomSheet.ts b/utils/expoUiBottomSheet.ts deleted file mode 100644 index 91ef322e3..000000000 --- a/utils/expoUiBottomSheet.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Platform } from "react-native"; - -/** - * TV-safe re-exports of `@expo/ui/community/bottom-sheet`. - * - * `@expo/ui` resolves its SwiftUI bridge at module load via - * `requireNativeModule('ExpoUI')`. That native module does not exist on tvOS, - * so a static top-level import from any route file crashes the whole route - * tree (expo-router eagerly loads every route). We `require()` it lazily and - * only when not on tvOS; on TV the exports are undefined, which is fine because - * every call site early-returns (`if (Platform.isTV) return null;`). - */ -type BottomSheetMod = typeof import("@expo/ui/community/bottom-sheet"); - -const mod: BottomSheetMod = Platform.isTV - ? ({} as BottomSheetMod) - : (require("@expo/ui/community/bottom-sheet") as BottomSheetMod); - -export const BottomSheetModal = mod.BottomSheetModal; -export const BottomSheetView = mod.BottomSheetView; -export const BottomSheetScrollView = mod.BottomSheetScrollView; -export const BottomSheetTextInput = mod.BottomSheetTextInput; - -export type { BottomSheetMethods } from "@expo/ui/community/bottom-sheet";