import React, { useState } from 'react'; import { View, Text, KeyboardAvoidingView, Platform, ScrollView, TouchableOpacity, Alert, } from 'react-native'; import { getStyles } from './LoginScreen.styles'; import { CustomInput, PrimaryButton, SocialButton } from '@components'; import CheckBox from '@react-native-community/checkbox'; import { useAppTheme } from '@theme'; export const LoginScreen: React.FC = () => { const { colors } = useAppTheme(); const styles = getStyles(colors); const [mobileNumber, setMobileNumber] = useState(''); const [password, setPassword] = useState(''); const [rememberMe, setRememberMe] = useState(false); const [isLoading, setIsLoading] = useState(false); const [errors, setErrors] = useState<{ mobile?: string; password?: string }>({}); const validate = () => { const newErrors: { mobile?: string; password?: string } = {}; if (!mobileNumber) { newErrors.mobile = 'Mobile number is required'; } else if (mobileNumber.length < 9) { newErrors.mobile = 'Please enter a valid mobile number'; } if (!password) { newErrors.password = 'Password is required'; } else if (password.length < 6) { newErrors.password = 'Password must be at least 6 characters'; } setErrors(newErrors); return Object.keys(newErrors).length === 0; }; const handleLogin = () => { if (!validate()) return; setIsLoading(true); // Simulate API request setTimeout(() => { setIsLoading(false); Alert.alert('Success', 'Logged in successfully!'); }, 1500); }; const handleSocialLogin = (provider: 'google' | 'apple') => { Alert.alert('Social Login', `Initiating ${provider} login...`); }; const handleForgotPassword = () => { Alert.alert('Forgot Password', 'Redirecting to reset password...'); }; const handleSignUp = () => { Alert.alert('Sign Up', 'Redirecting to registration...'); }; return ( Welcome back 👋 Login to continue { setMobileNumber(text); if (errors.mobile) setErrors({ ...errors, mobile: undefined }); }} error={errors.mobile} /> { setPassword(text); if (errors.password) setErrors({ ...errors, password: undefined }); }} error={errors.password} /> setRememberMe(!rememberMe)} activeOpacity={0.8} > Remember me or continue with handleSocialLogin('google')} /> handleSocialLogin('apple')} /> Don’t have an account? Sign up ); };