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 { 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 [fullName, setFullName] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [showPassword, setShowPassword] = useState(false); const [checked, setChecked] = useState(false); const onChangeCheckbox = (e) => { console.log('checked = ', e.target.checked) setChecked(e.target.checked) } 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('Create_your_account')} {t('Let_us_get_started_with_a_free_Financy_account')} setShowPassword(!showPassword)}> } /> {setChecked(!checked)}}> {t('I_certify_that_I_am_18_years_of_age_or_older')} {t('agree_to_the')} linkTo('UserAgreement')}> {t('User_Agreement')} {t('and')} linkTo('UserAgreement')}> {t('Privacy_Policy')} {t('Do_not_have_an_account')} linkTo('Login')}> {t('Sign_In')} ); }; export default LoginScreen;