import { View, Text, Image, StyleSheet, Pressable, Alert, Dimensions, ActivityIndicator } from 'react-native'; import Logo from '../../../global/logo'; import NormalButton from '../../../global/normal_button'; import NormalInput from '../../../global/normal_input'; import { useState } from 'react'; import { useAuth } from '../../../../context/AuthProvider'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; type LoginPageProps = { goToNextPage: () => void; goToForgetPassWordPage: () => void; }; const screenHeight = Dimensions.get('window').height; console.log(screenHeight); const LoginPage: React.FC = ({ goToNextPage, goToForgetPassWordPage }) => { 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 lowerCaseUsername = username.toLowerCase(); const success = await login(lowerCaseUsername, password); if (!success) { Alert.alert('Error', 'Invalid username or password'); } } setIsLoading(false); }; const insets = useSafeAreaInsets(); return ( // // // // // // setLoginEmail(email)} // extendedStyle={{ borderRadius: 12, padding: 20 }} // textContentType="username" // autoComplete="username" // /> // setLoginPassword(password)} // secureTextEntry={true} // extendedStyle={{ borderRadius: 12, padding: 20 }} // textContentType="password" // autoComplete="password" // /> // goToForgetPassWordPage()}> // 忘記密碼 // // _login(loginEmail, loginPassword)} // title={ // isLoading ? ( // // // // ) : ( // // 登入 // // ) // } // /> // // 註冊會員 // // // // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // // // // // setLoginEmail(email)} // extendedStyle={{ borderRadius: 12, padding: 20 }} // textContentType="username" // autoComplete="username" // /> // setLoginPassword(password)} // secureTextEntry={true} // extendedStyle={{ borderRadius: 12, padding: 20 }} // textContentType="password" // autoComplete="password" // /> // goToForgetPassWordPage()}> // 忘記密碼 // // _login(loginEmail, loginPassword)} // title={ // isLoading ? ( // // // // ) : ( // // 登入 // // ) // } // /> // // 註冊會員 // // // // ); // }; // const styles = StyleSheet.create({ // container: { // flex: 1, // height: Dimensions.get('window').height, // justifyContent: 'center', // marginHorizontal: 20 // }, // topContainerForLogo: {}, // text: { // color: '#02677D', // fontSize: 16, // paddingVertical: 5 // } // }); // export default LoginPage; // 750 ? 250 : 200, height: screenHeight > 750 ? 250 : 200 }} /> 750 ? 40 : 0 }} className="mx-[5%] flex-2 " > setLoginEmail(email)} extendedStyle={{ borderRadius: 12, padding: 20 }} textContentType="username" autoComplete="username" /> setLoginPassword(password)} secureTextEntry={true} extendedStyle={{ borderRadius: 12, padding: 20 }} textContentType="password" autoComplete="password" /> goToForgetPassWordPage()}> 忘記密碼 _login(loginEmail, loginPassword)} title={ isLoading ? ( ) : ( 登入 ) } /> 註冊會員 ); }; const styles = StyleSheet.create({ container: { flex: 1, height: Dimensions.get('window').height, justifyContent: 'center', marginHorizontal: 20 }, topContainerForLogo: {}, text: { color: '#02677D', fontSize: 16, paddingVertical: 5 } }); export default LoginPage;