import React, { useState } from 'react'; import { View, Text, StyleSheet, SafeAreaView, KeyboardAvoidingView, ScrollView, Platform, Alert, Image, TouchableWithoutFeedback, Keyboard, } from 'react-native'; import { StatusBar } from 'expo-status-bar'; import { useAuth } from '../../contexts/AuthContext'; import Button from '../../components/Button'; import Input from '../../components/Input'; import Logo from '../../components/Logo'; import { COLORS } from '../../constants/colors'; const LoginScreen = ({ navigation }) => { const [phone, setPhone] = useState(''); const [password, setPassword] = useState(''); const [errors, setErrors] = useState({}); const { login, isLoading } = useAuth(); const validateForm = () => { const newErrors = {}; if (!phone.trim()) { newErrors.phone = 'Telefon belgisi gerek'; } else if (!/^\d{8}$/.test(phone.trim())) { newErrors.phone = 'Telefon belgisi 8 sanly bolmaly (mysal: 61909090)'; } if (!password.trim()) { newErrors.password = 'Parol gerek'; } else if (password.length < 6) { newErrors.password = 'Parol azyndan 6 harp bolmaly'; } if (!/^6[1-9]\d{6}$|^7[0-1]\d{6}$/.test(phone.trim())) { newErrors.phone = 'Telefon belgisi 61000000-71999999 aralygynda bolmaly'; } setErrors(newErrors); return Object.keys(newErrors).length === 0; }; const handleLogin = async () => { if (!validateForm()) return; const result = await login(phone.trim(), password); if (result.success) { // Navigation will be handled by AuthContext } else { Alert.alert('Ýalňyşlyk', result.error); } }; const navigateToRegister = () => { navigation.navigate('Register'); }; return ( TBBANK ONLINE Hoş geldiňiz Giriş Hasabyňyza girmek üçin maglumatyňyzy giriziň