Untitled
unknown
plain_text
2 years ago
5.3 kB
5
Indexable
import React, { useState, useEffect } from 'react'; import { Center, Box, Heading, VStack, FormControl, Input, Button, HStack, Link, Text } from 'native-base'; import { StyleSheet, View, SafeAreaView, Image, KeyboardAvoidingView, TextInput, Pressable, } from "react-native"; import { MaterialIcons } from "@expo/vector-icons"; import { AntDesign } from "@expo/vector-icons"; import { useNavigation } from "@react-navigation/native"; import AsyncStorage from "@react-native-async-storage/async-storage"; import { createTableUser, getUser, dropTableUser } from '../../db/user'; import { storeData } from '../../component/store'; export default function LoginScreen({ navigation }) { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); useEffect(() => { async function initializeDatabase() { await createTableUser(); } initializeDatabase(); }, []); const handleLogin = async () => { // try { // const user = await getUser(email, password); // storeData('@user', user); // if (user.isSale === 1) { // navigation.navigate('HomeSalesman'); // } else { // navigation.navigate('Home'); // } // } catch (error) { // alert('Sai tên đăng nhập hoặc mật khẩu.'); // } navigation.navigate('Home'); }; return ( <SafeAreaView style={{ flex: 1, backgroundColor: "white", alignItems: "center"}} > <View> <Image style={{ width: 150, height: 100 }} source={{ uri: "https://www.logolynx.com/images/logolynx/4c/4c1e9d4c49f1ee74f3bb871a181fea10.png?fbclid=IwAR1tP9XGFKwI2qT8BQPXfkOwGoK-KMagmKWmwV0Esit9IeSz67oecIbnohk", }} /> </View> <KeyboardAvoidingView> <View style={{ alignItems: "center" }}> <Text style={{ fontSize: 17, fontWeight: "bold", marginTop: 12, color: "#041E42", }} > Login In to your Account </Text> </View> <View style={{ marginTop: 70 }}> <View style={{ flexDirection: "row", alignItems: "center", gap: 5, backgroundColor: "#D0D0D0", paddingVertical: 5, borderRadius: 5, marginTop: 30, }} > <MaterialIcons style={{ marginLeft: 8 }} name="email" size={24} color="gray" /> <TextInput value={email} onChangeText={(text) => setEmail(text)} style={{ color: "gray", marginVertical: 10, width: 300, fontSize: email ? 16 : 16, }} placeholder="enter your Email" /> </View> </View> <View style={{ marginTop: 10 }}> <View style={{ flexDirection: "row", alignItems: "center", gap: 5, backgroundColor: "#D0D0D0", paddingVertical: 5, borderRadius: 5, marginTop: 30, }} > <AntDesign name="lock1" size={24} color="gray" style={{ marginLeft: 8 }} /> <TextInput value={password} onChangeText={(text) => setPassword(text)} secureTextEntry={true} style={{ color: "gray", marginVertical: 10, width: 300, fontSize: password ? 16 : 16, }} placeholder="enter your Password" /> </View> </View> <View style={{ marginTop: 12, flexDirection: "row", alignItems: "center", justifyContent: "space-between", }} > <Text>Keep me logged in</Text> <Text style={{ color: "#007FFF", fontWeight: "500" }}> Forgot Password </Text> </View> <View style={{ marginTop: 80 }} /> <Pressable onPress={handleLogin} style={{ width: 200, backgroundColor: "blue", borderRadius: 6, marginLeft: "auto", marginRight: "auto", padding: 15, }} > <Text style={{ textAlign: "center", color: "white", fontSize: 16, fontWeight: "bold", }} > Login </Text> </Pressable> <Pressable onPress={() => navigation.navigate("Register")} style={{ marginTop: 15 }} > <Text style={{ textAlign: "center", color: "gray", fontSize: 16 }}> Don't have an account? Sign Up </Text> </Pressable> </KeyboardAvoidingView> </SafeAreaView> ) }
Editor is loading...
Leave a Comment