import { t } from "i18next"; import React, { useCallback, useState } from "react"; import { ScrollView, View } from "react-native"; import { Button } from "@/components/Button"; import { Text } from "@/components/common/Text"; import { useScaledTVTypography } from "@/constants/TVTypography"; import { useTVBackPress } from "@/hooks/useTVBackPress"; import { TVInput } from "./TVInput"; interface TVAddServerFormProps { onConnect: (url: string) => Promise; onStartPairing?: () => void; onBack: () => void; loading?: boolean; disabled?: boolean; } export const TVAddServerForm: React.FC = ({ onConnect, onStartPairing, onBack, loading = false, disabled = false, }) => { const typography = useScaledTVTypography(); const [serverURL, setServerURL] = useState(""); const handleConnect = async () => { if (serverURL.trim()) { await onConnect(serverURL.trim()); } }; const isDisabled = disabled || loading; const handleBack = useCallback(() => { if (isDisabled) return false; onBack(); return true; }, [isDisabled, onBack]); useTVBackPress(() => handleBack(), [handleBack]); return ( {/* Title */} {t("server.enter_url_to_jellyfin_server")} {/* Server URL Input */} {/* Connect Button */} {/* Pair with Phone */} {onStartPairing && ( )} ); };