У меня есть экран регистрации с текстовыми полями имени пользователя, полного имени, адреса электронной почты, пароля и кнопки Зарегистрироваться . И внизу экрана регистрации у меня есть
Уже есть аккаунт? Вход
Теперь, если я заполнил свои регистрационные данные и нажал кнопку «Регистрация», он вернется ко мне на экране «Вход». Кнопка регистрации должна перейти ко мне на домашний экран.
Но если я удалю - Уже есть аккаунт? Войдите в систему с моего экрана регистрации, затем кнопка регистрации успешно перейдет на главный экран.
Я не знаю, почему это произойдет, хотя мой код, если он в полном порядке.
Кроме того, случайно ли это может быть проблемой перекрытия SoftKeyboard?
// Below is my Signup Screen
export default class Signup extends Component {
constructor(props) {
super(props);
this.state = {
fullname: '',
username: '',
email: '',
password: '',
confirm_password: '',
};
}
signupCall = () => {
fetch(strings.baseUri+"registration", {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify( {
"fullname": this.state.fullname,
"username": this.state.username,
"email": this.state.email,
"password": this.state.password,
"confirm_password": this.state.confirm_password,
"latitude" : "0",
"longitude": "0",
"country": "0",
} )
})
.then((response) => response.json())
.then((responseJson) => {
let jsonObj = JSON.parse(JSON.stringify(responseJson));
if (jsonObj.status=="true") {
this.props.navigation.navigate('Tabs');
}
else {
alert(jsonObj.message);
}
})
.catch((error) => {
console.error(error);
});
}
navigateSIGNIN = () => {
this.props.navigation.navigate('Signin');
}
render() {
const { navigate } = this.props.navigation;
return (
<View >
<MyStatusBar backgroundColor={colors.transColor} barStyle="light-content" />
<View>
<ImageBackground style={styles.top_img} source={require('../../assets/imgs/bg2.png')}>
<View style={styles.logoimg_signup}>
<Image style={styles.logo_text_img} source={require('../../assets/imgs/logo_text.png')}></Image>
</View>
<View style={styles.signView}>
<TextInput style={styles.inputBox}
placeholder="USERNAME"
placeholderTextColor= {colors.dividerColor}
onChangeText={ username => this.setState({username}) }
/>
<TextInput style={styles.inputBox}
placeholder="FULL NAME"
placeholderTextColor= {colors.dividerColor}
onChangeText={ fullname => this.setState({fullname}) }
/>
<TextInput style={styles.inputBox}
placeholder="EMAIL ADDRESS"
placeholderTextColor= {colors.dividerColor}
onChangeText={ email => this.setState({email}) }
/>
<TextInput style={styles.inputBox}
placeholder="PASSWORD"
placeholderTextColor= {colors.dividerColor}
secureTextEntry password={true}
onChangeText={ password => this.setState({password}) }
/>
<TextInput style={styles.inputBox}
placeholder="CONFIRM PASSWORD"
placeholderTextColor= {colors.dividerColor}
secureTextEntry password={true}
onChangeText={ confirm_password => this.setState({confirm_password}) }
/>
<Text style={styles.dating_nearby}>I AGREE WITH TERMS & CONDITIONS</Text>
<TouchableOpacity style={styles.buttonSignin} onPress={ this.signupCall }>
<Text style={styles.sign_btns_txt} >SIGN UP</Text>
</TouchableOpacity>
</View>
<TouchableOpacity style={styles.facebookButton} onPress={() => navigate('Tabs')}>
<Text style={styles.social_sign_btns_txt}>SIGN UP WITH FACEBOOK</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.googleButton} onPress={() => navigate('Tabs')}>
<Text style={styles.social_sign_btns_txt}>SIGN UP WITH GOOGLE</Text>
</TouchableOpacity>
<Text style={styles.bottomTextLoginSignFor}
onPress={ this.navigateSIGNIN }
>
ALREADY HAVE ACCOUNT?
<Text style={{color: colors.primaryColor}}> SIGNIN NOW
</Text>
</Text>
</ImageBackground>
</View>
</View>
);
}
}
Styles
signView: {
justifyContent: 'center',
alignItems: 'center',
width: '80%',
borderRadius: 5,
padding:10,
backgroundColor: colors.whiteColor,
shadowColor: colors.blackColor,
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.8,
shadowRadius: 5,
elevation: 5,
},
inputBox:{
textAlign: 'center',
width: '80%',
padding: 5,
fontFamily: Fonts.MontserratR,
marginTop: 10,
fontSize: 16,
color: colors.blackColor,
},
dating_nearby: {
height:16,
textAlign: 'center',
marginTop:20,
marginBottom:10,
color: colors.subTextColor,
fontSize: 12,
fontFamily: Fonts.MontserratR,
},
buttonSignin:{
alignItems: 'center',
justifyContent: 'center',
height: 45,
width: '65%',
borderRadius: 35,
fontSize: 16,
fontFamily: Fonts.MontserratR,
color: colors.whiteColor,
backgroundColor: colors.leftColor,
shadowColor: colors.blackColor,
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.8,
shadowRadius: 5,
elevation: 3,
},
sign_btns_txt: {
color: colors.whiteColor,
fontSize: 16,
fontFamily: Fonts.MontserratR,
},
facebookButton:{
alignItems: 'center',
justifyContent: 'center',
height: 45,
width: '50%',
marginTop: 20,
borderRadius: 35,
fontSize: 16,
fontFamily: Fonts.MontserratR,
color: colors.whiteColor,
backgroundColor: colors.facebookColor,
shadowColor: colors.blackColor,
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.8,
shadowRadius: 5,
elevation: 3,
},
googleButton:{
alignItems: 'center',
justifyContent: 'center',
height: 45,
width: '50%',
marginTop: 10,
borderRadius: 35,
fontSize: 16,
fontFamily: Fonts.MontserratR,
color: colors.whiteColor,
backgroundColor: colors.googleColor,
shadowColor: colors.blackColor,
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.8,
shadowRadius: 5,
elevation: 3,
},
social_sign_btns_txt: {
color: colors.whiteColor,
fontSize: 12,
fontFamily: Fonts.MontserratR,
},
bottomTextLoginSignFor: {
height:16,
textAlign: 'center',
marginTop:20,
marginBottom:20,
justifyContent: 'center',
alignItems: 'center',
position: 'absolute',
bottom: 0,
fontFamily: Fonts.MontserratR,
color: colors.subTextColor,
fontSize: 12,
},