import type { Api } from "@jellyfin/sdk"; import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client"; import React from "react"; import { Animated, Image, Pressable, StyleSheet, View } from "react-native"; import { Text } from "@/components/common/Text"; import { useTVFocusAnimation } from "@/components/tv/hooks/useTVFocusAnimation"; import { useScaledTVTypography } from "@/constants/TVTypography"; import { getPrimaryImageUrl } from "@/utils/jellyfin/image/getPrimaryImageUrl"; interface TVChannelCardProps { channel: BaseItemDto; api: Api | null; onPress: () => void; hasTVPreferredFocus?: boolean; disabled?: boolean; } const CARD_WIDTH = 200; const CARD_HEIGHT = 160; export const TVChannelCard: React.FC = ({ channel, api, onPress, hasTVPreferredFocus = false, disabled = false, }) => { const typography = useScaledTVTypography(); const { focused, handleFocus, handleBlur, animatedStyle } = useTVFocusAnimation({ scaleAmount: 1.05, duration: 120, }); const imageUrl = getPrimaryImageUrl({ api, item: channel, quality: 80, width: 200, }); return ( {/* Channel logo or number */} {imageUrl ? ( ) : ( {channel.ChannelNumber || "?"} )} {/* Channel name */} {channel.Name} {/* Channel number (if name is shown) */} {channel.ChannelNumber && ( Ch. {channel.ChannelNumber} )} ); }; const styles = StyleSheet.create({ pressable: { width: CARD_WIDTH, height: CARD_HEIGHT, }, container: { flex: 1, borderRadius: 12, borderWidth: 1, padding: 12, alignItems: "center", justifyContent: "center", }, focusedShadow: { shadowColor: "#FFFFFF", shadowOffset: { width: 0, height: 0 }, shadowOpacity: 0.4, shadowRadius: 12, }, logoContainer: { width: 80, height: 60, marginBottom: 8, justifyContent: "center", alignItems: "center", }, logo: { width: "100%", height: "100%", }, numberFallback: { width: 60, height: 60, borderRadius: 30, justifyContent: "center", alignItems: "center", }, numberText: { fontWeight: "bold", }, channelName: { fontWeight: "600", textAlign: "center", marginBottom: 4, }, channelNumber: { fontWeight: "400", }, }); export { CARD_WIDTH, CARD_HEIGHT };