import { router } from 'expo-router'; import { useState } from 'react'; import { KeyboardAvoidingView, Platform, 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 LoginScreen() { const insets = useSafeAreaInsets(); const app = useApp(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [err, setErr] = useState(null); const [loading, setLoading] = useState(false); if (app.runtimeMode !== 'cloud' || !app.supabase) { return ( Configurez d’abord Supabase dans Réglages, puis revenez ici. router.replace('/(tabs)/reglages')} /> ); } return ( {err ? {err} : null} { setErr(null); setLoading(true); const r = await app.signIn(email.trim(), password); setLoading(false); if (r.error) { setErr(r.error); return; } router.replace('/(tabs)'); }} /> router.push('/auth/register')} containerStyle={{ marginTop: 12 }} /> ); } const styles = StyleSheet.create({ box: { flex: 1, padding: 20, backgroundColor: colors.bg, gap: 12 }, err: { color: colors.danger, marginBottom: 12 }, });