import { useState } from 'react'; import { View, Text, TextInput, TouchableOpacity, StyleSheet, KeyboardAvoidingView, Platform, ScrollView, Alert, ActivityIndicator, } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import { useAuthContext } from '../lib/AuthContext'; export default function LoginScreen() { const { login, register } = useAuthContext(); const [mode, setMode] = useState<'login' | 'register'>('login'); const [email, setEmail] = useState(''); const [name, setName] = useState(''); const [password, setPassword] = useState(''); const [showPassword, setShowPassword] = useState(false); const [loading, setLoading] = useState(false); const handleSubmit = async () => { if (!email.trim() || !password.trim()) { Alert.alert('Chyba', 'Vyplnte vsechna pole'); return; } if (mode === 'register' && !name.trim()) { Alert.alert('Chyba', 'Vyplnte jmeno'); return; } setLoading(true); try { if (mode === 'login') { await login(email.trim(), password); } else { await register(email.trim(), name.trim(), password); } } catch (err: any) { Alert.alert('Chyba', err.message || 'Nepodarilo se prihlasit'); } finally { setLoading(false); } }; return ( {/* Logo */} Task Team Spravujte ukoly, cile a tymovou spolupraci {/* Form */} {/* Mode toggle */} setMode('login')} > Prihlaseni setMode('register')} > Registrace {mode === 'register' && ( )} setShowPassword(!showPassword)} style={styles.eyeBtn} > {loading ? ( ) : ( {mode === 'login' ? 'Prihlasit se' : 'Zaregistrovat se'} )} ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#F8FAFC' }, scrollContent: { flexGrow: 1, justifyContent: 'center', padding: 24, }, logoSection: { alignItems: 'center', marginBottom: 40 }, logoCircle: { width: 80, height: 80, borderRadius: 20, backgroundColor: '#3B82F6', alignItems: 'center', justifyContent: 'center', marginBottom: 16, }, appName: { fontSize: 28, fontWeight: '800', color: '#1E293B' }, appDesc: { fontSize: 15, color: '#64748B', textAlign: 'center', marginTop: 8, }, form: {}, modeToggle: { flexDirection: 'row', backgroundColor: '#E2E8F0', borderRadius: 12, padding: 4, marginBottom: 24, }, modeBtn: { flex: 1, paddingVertical: 10, borderRadius: 10, alignItems: 'center', }, modeBtnActive: { backgroundColor: '#fff' }, modeBtnText: { fontSize: 15, color: '#64748B', fontWeight: '500' }, modeBtnTextActive: { color: '#3B82F6', fontWeight: '700' }, inputGroup: { flexDirection: 'row', alignItems: 'center', backgroundColor: '#fff', borderRadius: 12, borderWidth: 1, borderColor: '#E2E8F0', marginBottom: 12, paddingHorizontal: 14, }, inputIcon: { marginRight: 10 }, input: { flex: 1, paddingVertical: 14, fontSize: 16, color: '#1E293B', }, eyeBtn: { padding: 4 }, submitBtn: { backgroundColor: '#3B82F6', borderRadius: 12, paddingVertical: 16, alignItems: 'center', marginTop: 8, shadowColor: '#3B82F6', shadowOffset: { width: 0, height: 4 }, shadowOpacity: 0.2, shadowRadius: 8, elevation: 4, }, submitBtnDisabled: { backgroundColor: '#94A3B8' }, submitBtnText: { color: '#fff', fontSize: 17, fontWeight: '700' }, });