import { View, Text, StyleSheet, Pressable, ScrollView, Alert } from 'react-native'; import NormalButton from '../../../global/normal_button'; import Logo from '../../../global/logo'; import PhoneInput from '../../../global/phone_input'; import NormalInput from '../../../global/normal_input'; import { useState } from 'react'; import { SafeAreaView } from 'react-native-safe-area-context'; import { useAuth } from '../../../../context/AuthProvider'; type LoginPageProps = { goToNextPage: () => void; goToForgetPassWordPage: () => void; }; const LoginPage: React.FC = ({ goToNextPage, goToForgetPassWordPage }) => { // const [loginPhone, setLoginPhone] = useState(''); //This loginPhone useState is only a placeholder, will be updated in the future const [loginEmail, setLoginEmail] = useState(''); const [loginPassword, setLoginPassword] = useState(''); const [isLoading, setIsLoading] = useState(false); const { login } = useAuth(); const _login = async (username: string, password: string) => { setIsLoading(true); if (username === '' || password === '') { Alert.alert('Error', 'Please enter a username and password'); } else { const success = await login(username, password); if (!success) { Alert.alert('Error', 'Invalid username or password'); } } setIsLoading(false); }; return ( setLoginEmail(email)} extendedStyle={{ borderRadius: 12, padding: 20 }} /> setLoginPassword(password)} secureTextEntry={true} extendedStyle={{ borderRadius: 12, padding: 20 }} /> goToForgetPassWordPage()}> 忘記密碼 _login(loginEmail, loginPassword)} title={ isLoading ? ( Loading ...{' '} ) : ( 登入 ) } /> 註冊會員 ); }; const styles = StyleSheet.create({ container: { flex: 1, gap: 50, marginHorizontal: 20 }, topContainerForLogo: { flex: 1 / 2 }, bottomContainer: { flex: 1, gap: 10 }, text: { color: '#02677D', fontSize: 16, paddingVertical: 5 } }); export default LoginPage;