Browse Source

Improved amicale home button and post login behavior

Arnaud Vergnet 3 years ago
parent
commit
f2acb59ea7
2 changed files with 24 additions and 5 deletions
  1. 2
    4
      src/components/Home/ActionsDashboardItem.js
  2. 22
    1
      src/screens/Amicale/LoginScreen.js

+ 2
- 4
src/components/Home/ActionsDashboardItem.js View File

@@ -44,10 +44,8 @@ class ActionsDashBoardItem extends React.Component<Props> {
44 44
                             ? "chevron-right"
45 45
                             : "login"}/>}
46 46
                         onPress={isLoggedIn
47
-                            ? () => this.props.navigation.navigate("services", {
48
-                                screen: 'index'
49
-                            })
50
-                            : () => this.props.navigation.navigate("login")}
47
+                            ? () => this.props.navigation.navigate("profile")
48
+                            : () => this.props.navigation.navigate("login", {nextScreen: "profile"})}
51 49
                         style={styles.list}
52 50
                     />
53 51
                 </Card>

+ 22
- 1
src/screens/Amicale/LoginScreen.js View File

@@ -50,11 +50,27 @@ class LoginScreen extends React.Component<Props, State> {
50 50
     onPasswordChange: Function;
51 51
     passwordInputRef: Object;
52 52
 
53
+    nextScreen: string | null;
53 54
 
54 55
     constructor(props) {
55 56
         super(props);
56 57
         this.onEmailChange = this.onInputChange.bind(this, true);
57 58
         this.onPasswordChange = this.onInputChange.bind(this, false);
59
+        this.props.navigation.addListener('focus', this.onScreenFocus);
60
+    }
61
+
62
+    onScreenFocus = () => {
63
+        this.handleNavigationParams();
64
+    };
65
+
66
+    handleNavigationParams () {
67
+        if (this.props.route.params != null) {
68
+            if (this.props.route.params.nextScreen != null)
69
+                this.nextScreen = this.props.route.params.nextScreen;
70
+            else
71
+                this.nextScreen = null;
72
+        }
73
+        console.log(this.nextScreen);
58 74
     }
59 75
 
60 76
     showErrorDialog = (error: number) =>
@@ -65,7 +81,12 @@ class LoginScreen extends React.Component<Props, State> {
65 81
 
66 82
     hideErrorDialog = () => this.setState({dialogVisible: false});
67 83
 
68
-    handleSuccess = () => this.props.navigation.goBack();
84
+    handleSuccess = () => {
85
+        if (this.nextScreen == null)
86
+            this.props.navigation.goBack();
87
+        else
88
+            this.props.navigation.replace(this.nextScreen);
89
+    };
69 90
 
70 91
     onResetPasswordClick = () => Linking.openURL(RESET_PASSWORD_PATH);
71 92
 

Loading…
Cancel
Save