diff --git a/src/components/Home/ActionsDashboardItem.js b/src/components/Home/ActionsDashboardItem.js index ad501d6..a4a920e 100644 --- a/src/components/Home/ActionsDashboardItem.js +++ b/src/components/Home/ActionsDashboardItem.js @@ -44,10 +44,8 @@ class ActionsDashBoardItem extends React.Component { ? "chevron-right" : "login"}/>} onPress={isLoggedIn - ? () => this.props.navigation.navigate("services", { - screen: 'index' - }) - : () => this.props.navigation.navigate("login")} + ? () => this.props.navigation.navigate("profile") + : () => this.props.navigation.navigate("login", {nextScreen: "profile"})} style={styles.list} /> diff --git a/src/screens/Amicale/LoginScreen.js b/src/screens/Amicale/LoginScreen.js index fcc2404..f3d8169 100644 --- a/src/screens/Amicale/LoginScreen.js +++ b/src/screens/Amicale/LoginScreen.js @@ -50,11 +50,27 @@ class LoginScreen extends React.Component { onPasswordChange: Function; passwordInputRef: Object; + nextScreen: string | null; constructor(props) { super(props); this.onEmailChange = this.onInputChange.bind(this, true); this.onPasswordChange = this.onInputChange.bind(this, false); + this.props.navigation.addListener('focus', this.onScreenFocus); + } + + onScreenFocus = () => { + this.handleNavigationParams(); + }; + + handleNavigationParams () { + if (this.props.route.params != null) { + if (this.props.route.params.nextScreen != null) + this.nextScreen = this.props.route.params.nextScreen; + else + this.nextScreen = null; + } + console.log(this.nextScreen); } showErrorDialog = (error: number) => @@ -65,7 +81,12 @@ class LoginScreen extends React.Component { hideErrorDialog = () => this.setState({dialogVisible: false}); - handleSuccess = () => this.props.navigation.goBack(); + handleSuccess = () => { + if (this.nextScreen == null) + this.props.navigation.goBack(); + else + this.props.navigation.replace(this.nextScreen); + }; onResetPasswordClick = () => Linking.openURL(RESET_PASSWORD_PATH);