import { Ionicons } from "@expo/vector-icons"; import { Image } from "expo-image"; import React, { useState } from "react"; import { Animated, Pressable, View } from "react-native"; import { Text } from "@/components/common/Text"; import { useTVFocusAnimation } from "@/components/tv/hooks/useTVFocusAnimation"; import { useScaledTVTypography } from "@/constants/TVTypography"; import { getUserImageUrl } from "@/utils/jellyfin/image/getUserImageUrl"; import { scaleSize } from "@/utils/scaleSize"; import type { AccountSecurityType } from "@/utils/secureCredentials"; export interface TVUserIconProps { username: string; securityType: AccountSecurityType; onPress: () => void; hasTVPreferredFocus?: boolean; disabled?: boolean; serverAddress?: string; userId?: string; primaryImageTag?: string; } export const TVUserIcon = React.forwardRef( ( { username, securityType, onPress, hasTVPreferredFocus, disabled = false, serverAddress, userId, primaryImageTag, }, ref, ) => { const typography = useScaledTVTypography(); const { focused, handleFocus, handleBlur, animatedStyle } = useTVFocusAnimation(); const [imageError, setImageError] = useState(false); const getSecurityIcon = (): keyof typeof Ionicons.glyphMap => { switch (securityType) { case "pin": return "keypad"; case "password": return "lock-closed"; default: return "key"; } }; const hasSecurityProtection = securityType !== "none"; const imageUrl = serverAddress && userId && primaryImageTag && !imageError ? getUserImageUrl({ serverAddress, userId, primaryImageTag, width: 280, }) : null; return ( {imageUrl ? ( setImageError(true)} /> ) : ( )} {/* Security badge */} {hasSecurityProtection && ( )} {username} ); }, );