You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
3.3 KiB
135 lines
3.3 KiB
import React, { useState } from "react"; |
|
import { |
|
View, |
|
Text, |
|
Image, |
|
ActivityIndicator, |
|
Dimensions, |
|
TextInput, |
|
TouchableHighlight, |
|
} from "react-native"; |
|
import Logo from "./assets/logo.png"; |
|
import CustomTextInput from "../../components/CustomTextInput"; |
|
import { digitToEn, digitToPersian } from "../../utils"; |
|
import services from "./services"; |
|
import { asyncAwesomeAlert } from "../../utils/AsyncWrappers"; |
|
import tw from "tailwind-rn"; |
|
|
|
const { width, height } = Dimensions.get("window"); |
|
let faNums = ["۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "۰"]; |
|
|
|
function Login(props) { |
|
const [phone, setPhone] = useState(""); |
|
const [loading, setLoading] = useState(false); |
|
|
|
const onChangePhone = (name, value) => { |
|
let items = digitToPersian(value).split(""); |
|
for (let item of items) { |
|
if (!faNums.includes(item)) { |
|
return; |
|
} |
|
} |
|
setPhone(digitToPersian(value)); |
|
}; |
|
|
|
const checkPhoneNumber = () => { |
|
return phone.split("").length === 11; |
|
}; |
|
|
|
const submit = async () => { |
|
setLoading(true); |
|
// if (!checkPhoneNumber()) { |
|
// setLoading(false); |
|
// return asyncAwesomeAlert("خطا", "شماره وارد شده اشتباه است", { |
|
// showCancelButton: false, |
|
// }); |
|
// } |
|
// let res = await services.getSmsCode({ |
|
// cellphone: digitToEn(phone), |
|
// }); |
|
// if (res.ok) { |
|
// setLoading(false); |
|
props.navigation.navigate("Otp", { phone: digitToEn(phone) }); |
|
// } |
|
setLoading(false); |
|
}; |
|
|
|
return ( |
|
<View |
|
style={[ |
|
tw("flex flex-col flex-1 justify-center items-center bg-white px-4"), |
|
]} |
|
> |
|
<Image |
|
source={Logo} |
|
style={{ |
|
width: 55, |
|
height: 80, |
|
}} |
|
/> |
|
<Text |
|
style={[ |
|
tw("w-full my-5"), |
|
{ |
|
fontSize: width / 20, |
|
fontFamily: "bold", |
|
color: "#132F52", |
|
}, |
|
]} |
|
> |
|
{"سلام"} |
|
</Text> |
|
{/* <Text |
|
style={[tw('w-full mt-2'),{ |
|
fontSize: width / 34, |
|
color: "#6f7074", |
|
fontFamily: "regular" |
|
}]} |
|
> |
|
{ |
|
"به دانوین خوش اومدی برای عضویت و ادامه شماره موبایلت رو وارد کن و روی گزینه ثبت بزن" |
|
} |
|
</Text> */} |
|
<View style={[tw("w-full rounded-md overflow-hidden relative"), {}]}> |
|
<CustomTextInput |
|
label="شماره موبایل" |
|
textAlign="left" |
|
name="phone" |
|
maxlength="11" |
|
value={phone} |
|
onChange={onChangePhone} |
|
autoFocus={true} |
|
/> |
|
</View> |
|
<TouchableHighlight |
|
disabled={loading} |
|
style={[ |
|
tw("w-full py-2 rounded-md"), |
|
{ |
|
backgroundColor: "#196EC0", |
|
alignItems: "center", |
|
justifyContent: "center", |
|
marginTop: 15, |
|
fontFamily: "light", |
|
}, |
|
]} |
|
onPress={() => submit()} |
|
> |
|
{loading ? ( |
|
<ActivityIndicator size={"small"} color={"white"} /> |
|
) : ( |
|
<Text |
|
style={{ |
|
color: "white", |
|
fontSize: 18, |
|
}} |
|
> |
|
{"ادامه"} |
|
</Text> |
|
)} |
|
</TouchableHighlight> |
|
</View> |
|
); |
|
} |
|
|
|
export default Login;
|
|
|