import { Text } from "@/components/common/Text"; import MoviePoster from "@/components/posters/MoviePoster"; import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models"; import { useQuery, type QueryFunction, type QueryKey, } from "@tanstack/react-query"; import { ScrollView, View, ViewProps } from "react-native"; import ContinueWatchingPoster from "../ContinueWatchingPoster"; import { ItemCardText } from "../ItemCardText"; import { TouchableItemRouter } from "../common/TouchableItemRouter"; import SeriesPoster from "../posters/SeriesPoster"; import { useTranslation } from "react-i18next"; interface Props extends ViewProps { title?: string | null; orientation?: "horizontal" | "vertical"; disabled?: boolean; queryKey: QueryKey; queryFn: QueryFunction; hideIfEmpty?: boolean; } export const ScrollingCollectionList: React.FC = ({ title, orientation = "vertical", disabled = false, queryFn, queryKey, hideIfEmpty = false, ...props }) => { const { data, isLoading } = useQuery({ queryKey: queryKey, queryFn, staleTime: 0, refetchOnMount: true, refetchOnWindowFocus: true, refetchOnReconnect: true, }); if (disabled || !title) return null; if (hideIfEmpty === true && data?.length === 0) return null; const { t } = useTranslation(); return ( {title} {isLoading === false && data?.length === 0 && ( {t("home.no_items")} )} {isLoading ? ( {[1, 2, 3].map((i) => ( Nisi mollit voluptate amet. Lorem ipsum ))} ) : ( {data?.map((item) => ( {item.Type === "Episode" && orientation === "horizontal" && ( )} {item.Type === "Episode" && orientation === "vertical" && ( )} {item.Type === "Movie" && orientation === "horizontal" && ( )} {item.Type === "Movie" && orientation === "vertical" && ( )} {item.Type === "Series" && orientation === "vertical" && ( )} {item.Type === "Series" && orientation === "horizontal" && ( )} {item.Type === "Program" && ( )} ))} )} ); };