import { router } from "expo-router"; import { useEffect, useState } from "react"; import { Alert, KeyboardAvoidingView, Platform, Pressable, ScrollView, StyleSheet, Text, TextInput, View, } from "react-native"; import { SafeAreaView } from "react-native-safe-area-context"; import { loadRecorderSettings, saveRecorderSettings, } from "@/lib/recorder-settings"; export default function SettingsScreen() { const [backendUrl, setBackendUrl] = useState(""); const [authToken, setAuthToken] = useState(""); const [fieldName, setFieldName] = useState("file"); useEffect(() => { let isMounted = true; async function loadSettings() { try { const settings = await loadRecorderSettings(); if (!isMounted) { return; } setBackendUrl(settings.backendUrl); setAuthToken(settings.authToken); setFieldName(settings.fieldName); } catch { if (isMounted) { Alert.alert("Settings error", "Could not load backend settings."); } } } void loadSettings(); return () => { isMounted = false; }; }, []); async function handleSave() { try { await saveRecorderSettings({ authToken, backendUrl, fieldName, }); router.back(); } catch { Alert.alert("Save failed", "Could not save backend settings."); } } return ( router.back()} style={styles.navButton}> Back Settings Save Backend URL Bearer token Form field name The recording is uploaded as multipart field `{fieldName.trim() || "file"}`. ); } const styles = StyleSheet.create({ safeArea: { flex: 1, backgroundColor: "#f4efe4", }, keyboardAvoidingView: { flex: 1, }, scrollView: { flex: 1, }, content: { gap: 18, paddingHorizontal: 20, paddingBottom: 32, paddingTop: 8, }, headerRow: { alignItems: "center", flexDirection: "row", justifyContent: "space-between", }, navButton: { borderColor: "#cdbfa8", borderRadius: 999, borderWidth: 1, paddingHorizontal: 12, paddingVertical: 8, }, navButtonText: { color: "#13304a", fontSize: 14, fontWeight: "700", }, title: { color: "#13304a", fontSize: 28, fontWeight: "800", }, panel: { backgroundColor: "#fffaf1", borderColor: "#dccfb9", borderRadius: 24, borderWidth: 1, gap: 12, padding: 18, }, label: { color: "#13304a", fontSize: 13, fontWeight: "700", marginBottom: -4, textTransform: "uppercase", }, input: { backgroundColor: "#f7f0e0", borderColor: "#d9ccb5", borderRadius: 16, borderWidth: 1, color: "#1a2b39", fontSize: 16, paddingHorizontal: 14, paddingVertical: 14, }, helperText: { color: "#665f54", fontSize: 13, lineHeight: 18, }, });