|
|
@ -8,7 +8,7 @@ import { |
|
|
|
TouchableOpacity, |
|
|
|
TouchableOpacity, |
|
|
|
ActivityIndicator, |
|
|
|
ActivityIndicator, |
|
|
|
Appearance, |
|
|
|
Appearance, |
|
|
|
Platform |
|
|
|
Platform, |
|
|
|
} from "react-native"; |
|
|
|
} from "react-native"; |
|
|
|
import tw from "tailwind-rn"; |
|
|
|
import tw from "tailwind-rn"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { connect } from "react-redux"; |
|
|
@ -20,8 +20,7 @@ import { user } from "../../redux/actions"; |
|
|
|
import fontSize from "../../constants/fontSize"; |
|
|
|
import fontSize from "../../constants/fontSize"; |
|
|
|
import Colors from "../../constants/Colors"; |
|
|
|
import Colors from "../../constants/Colors"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ios = Platform.OS === "ios"; |
|
|
|
const ios = Platform.OS === 'ios'; |
|
|
|
|
|
|
|
const { width } = Dimensions.get("window"); |
|
|
|
const { width } = Dimensions.get("window"); |
|
|
|
let ref1; |
|
|
|
let ref1; |
|
|
|
let ref2; |
|
|
|
let ref2; |
|
|
@ -38,8 +37,10 @@ function Otp(props) { |
|
|
|
const [fourthCode, setFourthCode] = useState(""); |
|
|
|
const [fourthCode, setFourthCode] = useState(""); |
|
|
|
const [time, setTime] = useState(60); |
|
|
|
const [time, setTime] = useState(60); |
|
|
|
const [loading, setLoading] = useState(false); |
|
|
|
const [loading, setLoading] = useState(false); |
|
|
|
|
|
|
|
const [timeEnd, setTimeEnd] = useState(false); |
|
|
|
|
|
|
|
|
|
|
|
const onChangeCode = (value, key) => { |
|
|
|
const onChangeCode = (value, key) => { |
|
|
|
|
|
|
|
if (onInput.numberOnly(value) || value === "") { |
|
|
|
switch (key) { |
|
|
|
switch (key) { |
|
|
|
case "1": |
|
|
|
case "1": |
|
|
|
setFirstCode(value); |
|
|
|
setFirstCode(value); |
|
|
@ -73,6 +74,9 @@ function Otp(props) { |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const getEnCode = () => { |
|
|
|
const getEnCode = () => { |
|
|
@ -105,6 +109,7 @@ function Otp(props) { |
|
|
|
}, 1000); |
|
|
|
}, 1000); |
|
|
|
let timeout = setTimeout(() => { |
|
|
|
let timeout = setTimeout(() => { |
|
|
|
clearInterval(interval); |
|
|
|
clearInterval(interval); |
|
|
|
|
|
|
|
setTimeEnd(true); |
|
|
|
}, 60000); |
|
|
|
}, 60000); |
|
|
|
return () => { |
|
|
|
return () => { |
|
|
|
clearInterval(interval); |
|
|
|
clearInterval(interval); |
|
|
@ -132,7 +137,11 @@ function Otp(props) { |
|
|
|
/> |
|
|
|
/> |
|
|
|
<Text |
|
|
|
<Text |
|
|
|
style={[ |
|
|
|
style={[ |
|
|
|
tw(`w-full mt-2.5 ${ios ? 'text-right' : ""} ${props.mobile ? "" : "w-3/4"}`), |
|
|
|
tw( |
|
|
|
|
|
|
|
`w-full mt-2.5 ${ios ? "text-right" : ""} ${ |
|
|
|
|
|
|
|
props.mobile ? "" : "w-3/4" |
|
|
|
|
|
|
|
}` |
|
|
|
|
|
|
|
), |
|
|
|
{ |
|
|
|
{ |
|
|
|
fontSize: props.mobile ? fontSize.sm : fontSize.base, |
|
|
|
fontSize: props.mobile ? fontSize.sm : fontSize.base, |
|
|
|
fontFamily: "regular", |
|
|
|
fontFamily: "regular", |
|
|
@ -152,12 +161,12 @@ function Otp(props) { |
|
|
|
fontSize: fontSize.xl3, |
|
|
|
fontSize: fontSize.xl3, |
|
|
|
fontFamily: "bold", |
|
|
|
fontFamily: "bold", |
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
width : ios ? fontSize.xl3 + 40 : "" |
|
|
|
width: fontSize.xl3 + 40, |
|
|
|
}, |
|
|
|
}, |
|
|
|
]} |
|
|
|
]} |
|
|
|
underlineColorAndroid={"transparent"} |
|
|
|
underlineColorAndroid={"transparent"} |
|
|
|
value={firstCode} |
|
|
|
value={firstCode} |
|
|
|
maxLength={1} |
|
|
|
maxLength={2} |
|
|
|
ref={(ref) => (ref1 = ref)} |
|
|
|
ref={(ref) => (ref1 = ref)} |
|
|
|
onChangeText={(text) => onChangeCode(text, "1")} |
|
|
|
onChangeText={(text) => onChangeCode(text, "1")} |
|
|
|
regex={onInput.numberOnly} |
|
|
|
regex={onInput.numberOnly} |
|
|
@ -170,12 +179,12 @@ function Otp(props) { |
|
|
|
fontSize: fontSize.xl3, |
|
|
|
fontSize: fontSize.xl3, |
|
|
|
fontFamily: "bold", |
|
|
|
fontFamily: "bold", |
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
width : ios ? fontSize.xl3 + 40 : "" |
|
|
|
width: fontSize.xl3 + 40, |
|
|
|
}, |
|
|
|
}, |
|
|
|
]} |
|
|
|
]} |
|
|
|
underlineColorAndroid={"transparent"} |
|
|
|
underlineColorAndroid={"transparent"} |
|
|
|
value={secondCode} |
|
|
|
value={secondCode} |
|
|
|
maxLength={1} |
|
|
|
maxLength={2} |
|
|
|
ref={(ref) => (ref2 = ref)} |
|
|
|
ref={(ref) => (ref2 = ref)} |
|
|
|
onChangeText={(text) => onChangeCode(text, "2")} |
|
|
|
onChangeText={(text) => onChangeCode(text, "2")} |
|
|
|
regex={onInput.numberOnly} |
|
|
|
regex={onInput.numberOnly} |
|
|
@ -188,12 +197,12 @@ function Otp(props) { |
|
|
|
fontSize: fontSize.xl3, |
|
|
|
fontSize: fontSize.xl3, |
|
|
|
fontFamily: "bold", |
|
|
|
fontFamily: "bold", |
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
width : ios ? fontSize.xl3 + 40 : "" |
|
|
|
width: fontSize.xl3 + 40, |
|
|
|
}, |
|
|
|
}, |
|
|
|
]} |
|
|
|
]} |
|
|
|
underlineColorAndroid={"transparent"} |
|
|
|
underlineColorAndroid={"transparent"} |
|
|
|
value={thirdCode} |
|
|
|
value={thirdCode} |
|
|
|
maxLength={1} |
|
|
|
maxLength={2} |
|
|
|
ref={(ref) => (ref3 = ref)} |
|
|
|
ref={(ref) => (ref3 = ref)} |
|
|
|
onChangeText={(text) => onChangeCode(text, "3")} |
|
|
|
onChangeText={(text) => onChangeCode(text, "3")} |
|
|
|
regex={onInput.numberOnly} |
|
|
|
regex={onInput.numberOnly} |
|
|
@ -206,12 +215,12 @@ function Otp(props) { |
|
|
|
fontSize: fontSize.xl3, |
|
|
|
fontSize: fontSize.xl3, |
|
|
|
fontFamily: "bold", |
|
|
|
fontFamily: "bold", |
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
width : ios ? fontSize.xl3 + 40 : "" |
|
|
|
width: fontSize.xl3 + 40, |
|
|
|
}, |
|
|
|
}, |
|
|
|
]} |
|
|
|
]} |
|
|
|
underlineColorAndroid={"transparent"} |
|
|
|
underlineColorAndroid={"transparent"} |
|
|
|
value={fourthCode} |
|
|
|
value={fourthCode} |
|
|
|
maxLength={1} |
|
|
|
maxLength={2} |
|
|
|
ref={(ref) => (ref4 = ref)} |
|
|
|
ref={(ref) => (ref4 = ref)} |
|
|
|
onChangeText={(text) => onChangeCode(text, "4")} |
|
|
|
onChangeText={(text) => onChangeCode(text, "4")} |
|
|
|
regex={onInput.numberOnly} |
|
|
|
regex={onInput.numberOnly} |
|
|
@ -221,7 +230,11 @@ function Otp(props) { |
|
|
|
<TouchableOpacity |
|
|
|
<TouchableOpacity |
|
|
|
disabled={loading} |
|
|
|
disabled={loading} |
|
|
|
style={[ |
|
|
|
style={[ |
|
|
|
tw(`w-full rounded-md py-2 mt-6 items-center justify-center ${props.mobile ? "" : "w-3/4"}`), |
|
|
|
tw( |
|
|
|
|
|
|
|
`w-full rounded-md py-2 mt-6 items-center justify-center ${ |
|
|
|
|
|
|
|
props.mobile ? "" : "w-3/4" |
|
|
|
|
|
|
|
}` |
|
|
|
|
|
|
|
), |
|
|
|
{ |
|
|
|
{ |
|
|
|
backgroundColor: Colors.theme1[colorScheme].greenCF, |
|
|
|
backgroundColor: Colors.theme1[colorScheme].greenCF, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -243,14 +256,20 @@ function Otp(props) { |
|
|
|
)} |
|
|
|
)} |
|
|
|
</TouchableOpacity> |
|
|
|
</TouchableOpacity> |
|
|
|
<View> |
|
|
|
<View> |
|
|
|
|
|
|
|
{!timeEnd ? ( |
|
|
|
<Text |
|
|
|
<Text |
|
|
|
style={[ |
|
|
|
style={[ |
|
|
|
tw("mt-7 text-center"), |
|
|
|
tw("mt-7 text-center"), |
|
|
|
{ fontFamily: "light", fontSize: fontSize.base, color : Colors.theme1[colorScheme].gray20 }, |
|
|
|
{ |
|
|
|
|
|
|
|
fontFamily: "light", |
|
|
|
|
|
|
|
fontSize: fontSize.base, |
|
|
|
|
|
|
|
color: Colors.theme1[colorScheme].gray20, |
|
|
|
|
|
|
|
}, |
|
|
|
]} |
|
|
|
]} |
|
|
|
> |
|
|
|
> |
|
|
|
{"زمان باقی مانده تا انقضای کد: " + time} |
|
|
|
{"زمان باقی مانده تا ارسال مجدد: " + time} |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
|
|
|
|
) : ( |
|
|
|
<TouchableOpacity |
|
|
|
<TouchableOpacity |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
marginTop: 20, |
|
|
|
marginTop: 20, |
|
|
@ -268,6 +287,7 @@ function Otp(props) { |
|
|
|
{"بازگشت به مرحله قبل و اصلاح شماره"} |
|
|
|
{"بازگشت به مرحله قبل و اصلاح شماره"} |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
</TouchableOpacity> |
|
|
|
</TouchableOpacity> |
|
|
|
|
|
|
|
)} |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
); |
|
|
|
); |
|
|
@ -275,7 +295,7 @@ function Otp(props) { |
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
isLogin: state.user.status, |
|
|
|
isLogin: state.user.status, |
|
|
|
mobile : state.publicApi.mobile |
|
|
|
mobile: state.publicApi.mobile, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
const mapDispatchToProps = { |
|
|
|