Browse Source

Improved dashboard amicale item

Arnaud Vergnet 3 years ago
parent
commit
9207d02c2a
2 changed files with 13 additions and 6 deletions
  1. 12
    5
      src/components/Home/ActionsDashboardItem.js
  2. 1
    1
      src/screens/Home/HomeScreen.js

+ 12
- 5
src/components/Home/ActionsDashboardItem.js View File

@@ -11,15 +11,18 @@ const ICON_AMICALE = require("../../../assets/amicale.png");
11 11
 type Props = {
12 12
     navigation: DrawerNavigationProp,
13 13
     theme: CustomTheme,
14
+    isLoggedIn: boolean,
14 15
 }
15 16
 
16 17
 class ActionsDashBoardItem extends React.Component<Props> {
17 18
 
18 19
     shouldComponentUpdate(nextProps: Props): boolean {
19 20
         return (nextProps.theme.dark !== this.props.theme.dark)
21
+        || (nextProps.isLoggedIn !== this.props.isLoggedIn);
20 22
     }
21 23
 
22 24
     render() {
25
+        const isLoggedIn = this.props.isLoggedIn;
23 26
         return (
24 27
             <Card style={{
25 28
                 ...styles.card,
@@ -27,14 +30,18 @@ class ActionsDashBoardItem extends React.Component<Props> {
27 30
             }}>
28 31
                 <List.Item
29 32
                     title={"AMICALE"}
30
-                    description={"VOTRE COMPTE"}
33
+                    description={isLoggedIn ? "VOTRE ESPACE" : "SE CONNECTER"}
31 34
                     left={props => <Avatar.Image
32 35
                         {...props}
33 36
                         size={40}
34 37
                         source={ICON_AMICALE}
35 38
                         style={styles.avatar}/>}
36
-                    right={props => <List.Icon {...props} icon="chevron-right"/>}
37
-                    onPress={() => this.props.navigation.navigate("amicale-home")}
39
+                    right={props => <List.Icon {...props} icon={isLoggedIn
40
+                        ? "chevron-right"
41
+                        : "login"}/>}
42
+                    onPress={isLoggedIn
43
+                        ? () => this.props.navigation.navigate("services")
44
+                        : () => this.props.navigation.navigate("login")}
38 45
                     style={styles.list}
39 46
                 />
40 47
             </Card>
@@ -55,8 +62,8 @@ const styles = StyleSheet.create({
55 62
     },
56 63
     list: {
57 64
         // height: 50,
58
-        paddingTop:0,
59
-        paddingBottom:0,
65
+        paddingTop: 0,
66
+        paddingBottom: 0,
60 67
     }
61 68
 });
62 69
 

+ 1
- 1
src/screens/Home/HomeScreen.js View File

@@ -312,7 +312,7 @@ class HomeScreen extends React.Component<Props, State> {
312 312
     }
313 313
 
314 314
     getDashboardActions() {
315
-        return <ActionsDashBoardItem {...this.props}/>;
315
+        return <ActionsDashBoardItem {...this.props} isLoggedIn={this.isLoggedIn}/>;
316 316
     }
317 317
 
318 318
     /**

Loading…
Cancel
Save