import { DownloadSize } from "@/components/downloads/DownloadSize"; import { useDownload } from "@/providers/DownloadProvider"; import { storage } from "@/utils/mmkv"; import { useActionSheet } from "@expo/react-native-action-sheet"; import { Ionicons } from "@expo/vector-icons"; import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models"; import { Image } from "expo-image"; import { router } from "expo-router"; import type React from "react"; import { useCallback, useMemo } from "react"; import { TouchableOpacity, View } from "react-native"; import { Text } from "../common/Text"; export const SeriesCard: React.FC<{ items: BaseItemDto[] }> = ({ items }) => { const { deleteItems } = useDownload(); const { showActionSheetWithOptions } = useActionSheet(); const base64Image = useMemo(() => { return storage.getString(items[0].SeriesId!); }, []); const deleteSeries = useCallback(async () => deleteItems(items), [items]); const showActionSheet = useCallback(() => { const options = ["Delete", "Cancel"]; const destructiveButtonIndex = 0; showActionSheetWithOptions( { options, destructiveButtonIndex, }, (selectedIndex) => { if (selectedIndex == destructiveButtonIndex) { deleteSeries(); } }, ); }, [showActionSheetWithOptions, deleteSeries]); return ( router.push(`/downloads/${items[0].SeriesId}`)} onLongPress={showActionSheet} > {base64Image ? ( {items.length} ) : ( )} {items[0].SeriesName} {items[0].ProductionYear} ); };