import { Ionicons } from "@expo/vector-icons"; import { BottomSheetBackdrop, type BottomSheetBackdropProps, BottomSheetModal, BottomSheetView, } from "@gorhom/bottom-sheet"; import type React from "react"; import { useCallback, useEffect, useRef } from "react"; import { useTranslation } from "react-i18next"; import { StyleSheet, TouchableOpacity, View, type ViewProps, } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { Text } from "@/components/common/Text"; interface LibraryOptions { display: "row" | "list"; imageStyle: "poster" | "cover"; showTitles: boolean; showStats: boolean; } interface Props extends ViewProps { open: boolean; setOpen: (open: boolean) => void; settings: LibraryOptions; updateSettings: (options: Partial) => void; disabled?: boolean; } const OptionGroup: React.FC<{ title: string; children: React.ReactNode }> = ({ title, children, }) => ( {title} {children} ); const OptionItem: React.FC<{ label: string; selected: boolean; onPress: () => void; disabled?: boolean; isLast?: boolean; }> = ({ label, selected, onPress, disabled: itemDisabled, isLast }) => ( <> {label} {selected ? ( ) : ( )} {!isLast && ( )} ); const ToggleItem: React.FC<{ label: string; value: boolean; onToggle: () => void; disabled?: boolean; isLast?: boolean; }> = ({ label, value, onToggle, disabled: itemDisabled, isLast }) => ( <> {label} {!isLast && ( )} ); /** * LibraryOptionsSheet Component * * This component creates a bottom sheet modal for managing library display options. */ export const LibraryOptionsSheet: React.FC = ({ open, setOpen, settings, updateSettings, disabled = false, }) => { const bottomSheetModalRef = useRef(null); const { t } = useTranslation(); const insets = useSafeAreaInsets(); const handlePresentModal = useCallback(() => { bottomSheetModalRef.current?.present(); }, []); const handleDismissModal = useCallback(() => { bottomSheetModalRef.current?.dismiss(); }, []); useEffect(() => { if (open) { handlePresentModal(); } else { handleDismissModal(); } }, [open, handlePresentModal, handleDismissModal]); const handleSheetChanges = useCallback( (index: number) => { if (index === -1) { setOpen(false); } }, [setOpen], ); const renderBackdrop = useCallback( (props: BottomSheetBackdropProps) => ( ), [], ); if (disabled) return null; return ( {t("library.options.display")} updateSettings({ display: "row" })} /> updateSettings({ display: "list" })} isLast /> updateSettings({ imageStyle: "poster" })} /> updateSettings({ imageStyle: "cover" })} isLast /> updateSettings({ showTitles: !settings.showTitles }) } disabled={settings.imageStyle === "poster"} /> updateSettings({ showStats: !settings.showStats }) } isLast /> ); };