import { useState, useEffect } from 'react'; import { TextInput, TouchableOpacity, Image, StyleSheet, Alert, StatusBar, } from 'react-native'; import { Checkbox, Input, Grid, Icon, View, Text, Toast, Button, } from '@ant-design/react-native'; import AsyncStorage from '@/storage/index'; import { useNavigation, useIsFocused } from '@react-navigation/native'; import { useContextHook } from '@/components/AuthContext'; import { useTranslation } from 'react-i18next'; import { useRouter } from '@/hooks/useRouter'; import { statusBarHeight, paddingTopStatusBarHeight, flexRow, flexColumn, flexSub, flexShrink, flexWrap, flexnoWrap, justifyStart, justifyEnd, justifyCenter, justifyBetween, justifyAround, justifyEvenly, alignItemsStart, alignItemsEnd, alignItemsCenter, alignItemsStretch, positionRelative, positionAbsolute, useStyles, } from '@/assets/styles/css'; const inputItem = useStyles({ height: 56, width: '100%', borderRadius: 10, paddingHorizontal: 16, paddingVertical: 8, }); const LoginScreen = () => { const { themeColor } = useContextHook(); const { t, i18n } = useTranslation(); console.log('🚀 ~ LoginScreen ~ i18n:', i18n) const { linkTo } = useRouter(); const [language, setLanguage] = useState('en'); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [showPassword, setShowPassword] = useState(false); const handleLogin = () => { if (!email) { Toast.show({ content: t('Please enter email'), position: 'center', mask: true, }); return; } if (!password) { Toast.show({ content: t('Please enter password'), position: 'center', mask: true, }); return; } const key = Toast.show({ icon: 'loading', content: t('loading'), position: 'center', mask: true, duration: 0, }); console.log(123, 123); // login({ username, password }) // .then(res => { // Toast.remove(key); // setTimeout(() => { // Toast.show({ // content: t('login success'), //i18n.t('login_success'), // position: 'center', // mask: true, // onClose: () => { // // 设置全局的用户信息 // setUser(res.user) // AsyncStorage.setItem('appToken', { // appToken: res.token, // user: res.user, // }).then(() => { // linkTo('Home'); // }); // }, // }); // }, 200); // }) // .catch(err => { // Toast.remove(key); // setTimeout(() => { // Toast.show({ // content: t('login_failed'), // i18n.t('login_failed'), // position: 'center', // mask: true, // }); // }, 200); // // i18n.t('login_error_message') // }); }; return ( {t('Welcome_Back')} {t('Sign_in_to_your_account')} setShowPassword(!showPassword)}> } /> {t('Remember_me')} linkTo('ForgotPassword')}> {t('Forgot_password')} {/* {t('Or_sign_in_with')} */} {t('Do_not_have_an_account')} linkTo('Signup')}> {t('Sign_up')} ); }; export default LoginScreen;