import { router } from 'expo-router'; import { useState } from 'react'; import { ScrollView, StyleSheet, Text, View } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { LabeledField } from '../../src/components/LabeledField'; import { PrimaryButton } from '../../src/components/PrimaryButton'; import { useApp } from '../../src/context/AppContext'; import { colors } from '../../src/theme/colors'; export default function ReglagesScreen() { const insets = useSafeAreaInsets(); const app = useApp(); const [url, setUrl] = useState(''); const [key, setKey] = useState(''); const [msg, setMsg] = useState(null); const [loading, setLoading] = useState(false); return ( Mode actuel {app.runtimeMode === 'local' && 'Hors-ligne — données stockées sur l’appareil.'} {app.runtimeMode === 'cloud' && 'Supabase — synchronisation cloud.'} {app.runtimeMode === 'none' && 'Non initialisé.'} {app.user ? ( Compte : {app.user.email ?? app.user.id} ) : null} Projet Supabase URL et clé « anon » (Settings → API). Exécutez aussi la migration SQL du dépôt sur votre projet. {msg ? {msg} : null} { setMsg(null); if (!url.trim() || !key.trim()) { setMsg('Renseignez URL et clé.'); return; } setLoading(true); try { await app.saveCloudConfig({ supabaseUrl: url.trim(), supabaseAnonKey: key.trim(), }); setMsg('Configuration enregistrée. Connectez-vous ou créez un compte.'); router.push('/auth/login'); } catch { setMsg('Erreur lors de l’enregistrement.'); } finally { setLoading(false); } }} /> { await app.enterLocalMode(); setMsg('Mode hors-ligne activé.'); router.replace('/(tabs)'); }} /> { await app.signOut(); router.replace('/'); }} /> ); } const styles = StyleSheet.create({ h2: { color: colors.text, fontSize: 18, fontWeight: '700', marginBottom: 8 }, p: { color: colors.textMuted, lineHeight: 20, marginBottom: 8 }, msg: { color: colors.flash, marginBottom: 12, lineHeight: 20 }, });