import React from 'react'; import { Alert, Modal, StyleSheet, Text, TextInput, TouchableOpacity, View, } from 'react-native'; import { saveServerDomain } from '../services/api'; const PRESETS = [ { label: 'aa.pfgame.org', host: 'aa.pfgame.org', port: '443' }, { label: '192.168.1.117:16000', host: '192.168.1.117', port: '16000' }, ]; type Props = { visible: boolean; host: string; port: string; onHostChange: (host: string) => void; onPortChange: (port: string) => void; onClose: () => void; }; export const ServerSettingsModal: React.FC = ({ visible, host, port, onHostChange, onPortChange, onClose, }) => ( Server Settings {PRESETS.map((p) => ( { onHostChange(p.host); onPortChange(p.port); }} style={[styles.presetBtn, host === p.host && port === p.port && styles.presetBtnActive]} > {p.label} ))} Host Port Cancel { const domain = port ? `${host}:${port}` : host; await saveServerDomain(domain, port === '443'); onClose(); Alert.alert('Saved', 'Restart app to take effect'); }} style={styles.saveBtn} > Save ); const styles = StyleSheet.create({ overlay: { flex: 1, backgroundColor: 'rgba(0,0,0,0.5)', justifyContent: 'center', alignItems: 'center', }, box: { backgroundColor: '#fff', borderRadius: 10, padding: 20, width: '85%', }, title: { fontSize: 16, fontWeight: 'bold', marginBottom: 12, }, presets: { flexDirection: 'row', flexWrap: 'wrap', gap: 6, marginBottom: 14, }, presetBtn: { paddingHorizontal: 10, paddingVertical: 5, borderRadius: 6, backgroundColor: '#f0f0f0', }, presetBtnActive: { backgroundColor: '#3498db' }, inputLabel: { fontSize: 13, color: '#666', marginBottom: 4, }, textInput: { borderWidth: 1, borderColor: '#ddd', borderRadius: 6, paddingHorizontal: 10, paddingVertical: 8, marginBottom: 12, fontSize: 14, }, actions: { flexDirection: 'row', justifyContent: 'flex-end', }, cancelBtn: { paddingHorizontal: 16, paddingVertical: 8, marginRight: 10, }, saveBtn: { backgroundColor: '#3498db', paddingHorizontal: 16, paddingVertical: 8, borderRadius: 6, }, });