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
                             ? "chevron-right"
44
                             ? "chevron-right"
45
                             : "login"}/>}
45
                             : "login"}/>}
46
                         onPress={isLoggedIn
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
                         style={styles.list}
49
                         style={styles.list}
52
                     />
50
                     />
53
                 </Card>
51
                 </Card>

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

50
     onPasswordChange: Function;
50
     onPasswordChange: Function;
51
     passwordInputRef: Object;
51
     passwordInputRef: Object;
52
 
52
 
53
+    nextScreen: string | null;
53
 
54
 
54
     constructor(props) {
55
     constructor(props) {
55
         super(props);
56
         super(props);
56
         this.onEmailChange = this.onInputChange.bind(this, true);
57
         this.onEmailChange = this.onInputChange.bind(this, true);
57
         this.onPasswordChange = this.onInputChange.bind(this, false);
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
     showErrorDialog = (error: number) =>
76
     showErrorDialog = (error: number) =>
65
 
81
 
66
     hideErrorDialog = () => this.setState({dialogVisible: false});
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
     onResetPasswordClick = () => Linking.openURL(RESET_PASSWORD_PATH);
91
     onResetPasswordClick = () => Linking.openURL(RESET_PASSWORD_PATH);
71
 
92
 

Loading…
Cancel
Save