import { useState } from 'react'; import { Pressable, TextInput, View } from 'react-native'; import { validateServerUrl } from '@/utils/urlValidator'; import { apiService } from '@/services/api.service'; import { ThemedText } from '@/components/ThemedText'; import { colors } from '@/theme/colors'; import { spacing } from '@/theme/spacing'; type ServerUrlInputProps = { value: string; onChange: (value: string) => void; onSave: () => void; }; export const ServerUrlInput = ({ value, onChange, onSave }: ServerUrlInputProps) => { const [testResult, setTestResult] = useState(''); const validation = validateServerUrl(value); const handleTest = async () => { if (!validation.valid) { setTestResult('✗ Invalid URL'); return; } const start = Date.now(); try { await apiService.getStatus(); setTestResult(`✓ ${Date.now() - start}ms`); } catch { setTestResult('✗ Failed'); } }; return ( Server URL {!validation.valid && ( {validation.error} )} {testResult || 'Ready to test connection'} Test Connection Save ); };