import { Ionicons } from "@expo/vector-icons"; import React from "react"; import { useTranslation } from "react-i18next"; import { Animated, Pressable, View } from "react-native"; import { Text } from "@/components/common/Text"; import { useScaledTVTypography } from "@/constants/TVTypography"; import type { AccountSecurityType } from "@/utils/secureCredentials"; import { useTVFocusAnimation } from "./hooks/useTVFocusAnimation"; export interface TVUserCardProps { username: string; securityType: AccountSecurityType; hasTVPreferredFocus?: boolean; isCurrent?: boolean; onPress: () => void; } export const TVUserCard = React.forwardRef( ( { username, securityType, hasTVPreferredFocus = false, isCurrent = false, onPress, }, ref, ) => { const { t } = useTranslation(); const typography = useScaledTVTypography(); const { focused, handleFocus, handleBlur, animatedStyle } = useTVFocusAnimation({ scaleAmount: isCurrent ? 1.02 : 1.05 }); const getSecurityIcon = (): keyof typeof Ionicons.glyphMap => { switch (securityType) { case "pin": return "keypad"; case "password": return "lock-closed"; default: return "key"; } }; const getSecurityText = (): string => { switch (securityType) { case "pin": return t("save_account.pin_code"); case "password": return t("save_account.password"); default: return t("save_account.no_protection"); } }; const getBackgroundColor = () => { if (isCurrent) { return focused ? "rgba(255,255,255,0.15)" : "rgba(255,255,255,0.04)"; } return focused ? "#fff" : "rgba(255,255,255,0.08)"; }; const getTextColor = () => { if (isCurrent) { return "rgba(255,255,255,0.4)"; } return focused ? "#000" : "#fff"; }; const getSecondaryColor = () => { if (isCurrent) { return "rgba(255,255,255,0.25)"; } return focused ? "rgba(0,0,0,0.5)" : "rgba(255,255,255,0.5)"; }; return ( {/* User Avatar */} {/* Text column */} {/* Username */} {username} {isCurrent && ( ({t("home.settings.switch_user.current")}) )} {/* Security indicator */} {getSecurityText()} ); }, );