Files
streamyfin_mirror/components/ParentPoster.tsx
Fredrik Burmester 382e70cf8e chore
2024-08-06 08:18:17 +02:00

50 lines
1.0 KiB
TypeScript

import { apiAtom } from "@/providers/JellyfinProvider";
import { useQuery } from "@tanstack/react-query";
import { Image } from "expo-image";
import { useAtom } from "jotai";
import { useMemo } from "react";
import { View } from "react-native";
type PosterProps = {
id?: string;
showProgress?: boolean;
};
const ParentPoster: React.FC<PosterProps> = ({ id }) => {
const [api] = useAtom(apiAtom);
const url = useMemo(
() => `${api?.basePath}/Items/${id}/Images/Primary`,
[id]
);
if (!url || !id)
return (
<View
className="border border-neutral-900"
style={{
aspectRatio: "10/15",
}}
></View>
);
return (
<View className="rounded-md overflow-hidden border border-neutral-900">
<Image
key={id}
id={id}
source={{
uri: url,
}}
cachePolicy={"memory-disk"}
contentFit="cover"
style={{
aspectRatio: "10/15",
}}
/>
</View>
);
};
export default ParentPoster;