import { t } from "i18next"; import React, { useCallback } from "react"; import { ScrollView, View } from "react-native"; import { Text } from "@/components/common/Text"; import { useScaledTVTypography } from "@/constants/TVTypography"; import { useTVBackPress } from "@/hooks/useTVBackPress"; import type { SavedServer, SavedServerAccount, } from "@/utils/secureCredentials"; import { TVAddIcon } from "./TVAddIcon"; import { TVBackIcon } from "./TVBackIcon"; import { TVUserIcon } from "./TVUserIcon"; interface TVUserSelectionScreenProps { server: SavedServer; onUserSelect: (account: SavedServerAccount) => void; onAddUser: () => void; onChangeServer: () => void; disabled?: boolean; } export const TVUserSelectionScreen: React.FC = ({ server, onUserSelect, onAddUser, onChangeServer, disabled = false, }) => { const typography = useScaledTVTypography(); const accounts = server.accounts || []; const hasAccounts = accounts.length > 0; const handleBackPress = useCallback(() => { if (disabled) return false; onChangeServer(); return true; }, [disabled, onChangeServer]); useTVBackPress(handleBackPress, [handleBackPress]); return ( {/* Server Info Header */} {server.name || server.address} {server.name && ( {server.address.replace(/^https?:\/\//, "")} )} {hasAccounts ? t("login.select_user") : t("login.add_user_to_login")} {/* User Icons Grid with Back and Add buttons */} {/* Back/Change Server Button (left) */} {/* User Icons */} {accounts.map((account, index) => ( onUserSelect(account)} hasTVPreferredFocus={index === 0} disabled={disabled} serverAddress={server.address} userId={account.userId} primaryImageTag={account.primaryImageTag} /> ))} {/* Add User Button (right) */} ); };