Browse Source

Added ability to set a custom dashboard via settings

Arnaud Vergnet 1 year ago
parent
commit
b405f2aa6b

+ 13
- 3
locales/en.json View File

@@ -6,7 +6,8 @@
6 6
       "categories": {
7 7
         "amicale": "The Amicale",
8 8
         "students": "Student services",
9
-        "insa": "INSA services"
9
+        "insa": "INSA services",
10
+        "special": "Proxiwash"
10 11
       },
11 12
       "descriptions": {
12 13
         "clubs": "See info about your favorite club and discover new ones",
@@ -23,7 +24,9 @@
23 24
         "mails": "Check your INSA mails",
24 25
         "ent": "See your grades",
25 26
         "insaAccount": "See your information and change your password",
26
-        "equipment": "Book a BBQ or other equipment"
27
+        "equipment": "Book a BBQ or other equipment",
28
+        "washers": "Number of available washers",
29
+        "dryers": "Number of available dryers"
27 30
       },
28 31
       "mascotDialog": {
29 32
         "title": "So handy!",
@@ -320,9 +323,16 @@
320 323
       "nightModeAutoSub": "Follows the mode chosen by your system",
321 324
       "startScreen": "Start Screen",
322 325
       "startScreenSub": "Select which screen to start the app on",
326
+      "dashboard": "Dashboard",
327
+      "dashboardSub": "Edit what services to display on the dashboard",
323 328
       "proxiwashNotifReminder": "Machine running reminder",
324 329
       "proxiwashNotifReminderSub": "How many minutes before",
325
-      "information": "Information"
330
+      "information": "Information",
331
+      "dashboardEdit": {
332
+        "title": "Edit dashboard",
333
+        "message": "The five items above represent your dashboard.\nYou can replace one of its services by selecting it, and then by clicking on the desired new service in the list bellow.",
334
+        "undo": "Undo changes"
335
+      }
326 336
     },
327 337
     "about": {
328 338
       "title": "About",

+ 13
- 3
locales/fr.json View File

@@ -6,7 +6,8 @@
6 6
       "categories": {
7 7
         "amicale": "L' Amicale",
8 8
         "students": "Services étudiants",
9
-        "insa": "Services de l'INSA"
9
+        "insa": "Services de l'INSA",
10
+        "special": "Proxiwash"
10 11
       },
11 12
       "descriptions": {
12 13
         "clubs": "Tous les clubs et leurs infos",
@@ -23,7 +24,9 @@
23 24
         "mails": "Vérifie tes mails INSA",
24 25
         "ent": "Retrouve tes notes",
25 26
         "insaAccount": "Accède à tes infos INSA et modifie ton mot de passe",
26
-        "equipment": "Réserve un BBQ ou autre matériel"
27
+        "equipment": "Réserve un BBQ ou autre matériel",
28
+        "washers": "Nombre de lave-Linges disponibles",
29
+        "dryers": "Nombre de sèche-Linges disponibles"
27 30
       },
28 31
       "mascotDialog": {
29 32
         "title": "Un peu perdu ?",
@@ -319,9 +322,16 @@
319 322
       "nightModeAutoSub": "Suit le mode sélectionné par le système",
320 323
       "startScreen": "Écran de démarrage",
321 324
       "startScreenSub": "Choisis l'écran sur lequel démarre Campus",
325
+      "dashboard": "Dashboard",
326
+      "dashboardSub": "Choisis les services à afficher sur la dashboard",
322 327
       "proxiwashNotifReminder": "Rappel de machine en cours",
323 328
       "proxiwashNotifReminderSub": "Combien de minutes avant",
324
-      "information": "Informations"
329
+      "information": "Informations",
330
+      "dashboardEdit": {
331
+        "title": "Modifier la dashboard",
332
+        "message": "Les 5 icones ci-dessus représentent ta dashboard.\nTu peux remplacer un de ses services en cliquant dessus, puis en sélectionnant le nouveau service de ton choix dans la liste ci-dessous.",
333
+        "undo": "Annuler les changements"
334
+      }
325 335
     },
326 336
     "about": {
327 337
       "title": "À Propos",

+ 72
- 0
src/components/Lists/DashboardEdit/DashboardEditAccordion.js View File

@@ -0,0 +1,72 @@
1
+// @flow
2
+
3
+import * as React from 'react';
4
+import {withTheme} from 'react-native-paper';
5
+import {FlatList, Image, View} from "react-native";
6
+import DashboardEditItem from "./DashboardEditItem";
7
+import AnimatedAccordion from "../../Animations/AnimatedAccordion";
8
+import type {ServiceCategory, ServiceItem} from "../../../managers/ServicesManager";
9
+import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";
10
+import type {CustomTheme} from "../../../managers/ThemeManager";
11
+
12
+type Props = {
13
+    item: ServiceCategory,
14
+    activeDashboard: Array<string>,
15
+    onPress: (service: ServiceItem) => void,
16
+    theme: CustomTheme,
17
+}
18
+
19
+const LIST_ITEM_HEIGHT = 64;
20
+
21
+class DashboardEditAccordion extends React.Component<Props> {
22
+
23
+    renderItem = ({item}: { item: ServiceItem }) => {
24
+        return (
25
+            <DashboardEditItem
26
+                height={LIST_ITEM_HEIGHT}
27
+                item={item}
28
+                isActive={this.props.activeDashboard.includes(item.key)}
29
+                onPress={() => this.props.onPress(item)}/>
30
+        );
31
+    }
32
+
33
+    itemLayout = (data, index) => ({length: LIST_ITEM_HEIGHT, offset: LIST_ITEM_HEIGHT * index, index});
34
+
35
+    render() {
36
+        const item = this.props.item;
37
+        return (
38
+            <View>
39
+                <AnimatedAccordion
40
+                    title={item.title}
41
+                    left={props => typeof item.image === "number"
42
+                        ? <Image
43
+                            {...props}
44
+                            source={item.image}
45
+                            style={{
46
+                                width: 40,
47
+                                height: 40
48
+                            }}
49
+                        />
50
+                        : <MaterialCommunityIcons
51
+                            //$FlowFixMe
52
+                            name={item.image}
53
+                            color={this.props.theme.colors.primary}
54
+                            size={40}/>}
55
+                >
56
+                    {/*$FlowFixMe*/}
57
+                    <FlatList
58
+                        data={item.content}
59
+                        extraData={this.props.activeDashboard.toString()}
60
+                        renderItem={this.renderItem}
61
+                        listKey={item.key}
62
+                        // Performance props, see https://reactnative.dev/docs/optimizing-flatlist-configuration
63
+                        getItemLayout={this.itemLayout}
64
+                        removeClippedSubviews={true}
65
+                    />
66
+                </AnimatedAccordion>
67
+            </View>
68
+        );
69
+    }
70
+}
71
+
72
+export default withTheme(DashboardEditAccordion)

+ 55
- 0
src/components/Lists/DashboardEdit/DashboardEditItem.js View File

@@ -0,0 +1,55 @@
1
+// @flow
2
+
3
+import * as React from 'react';
4
+import {Image} from "react-native";
5
+import {List, withTheme} from 'react-native-paper';
6
+import type {CustomTheme} from "../../../managers/ThemeManager";
7
+import type {ServiceItem} from "../../../managers/ServicesManager";
8
+
9
+type Props = {
10
+    item: ServiceItem,
11
+    isActive: boolean,
12
+    height: number,
13
+    onPress: () => void,
14
+    theme: CustomTheme,
15
+}
16
+
17
+class DashboardEditItem extends React.Component<Props> {
18
+
19
+    shouldComponentUpdate(nextProps: Props) {
20
+        return (nextProps.isActive !== this.props.isActive);
21
+    }
22
+
23
+    render() {
24
+        return (
25
+            <List.Item
26
+                title={this.props.item.title}
27
+                description={this.props.item.subtitle}
28
+                onPress={this.props.isActive ? null : this.props.onPress}
29
+                left={props =>
30
+                    <Image
31
+                        {...props}
32
+                        source={{uri: this.props.item.image}}
33
+                        style={{
34
+                            width: 40,
35
+                            height: 40
36
+                        }}
37
+                    />}
38
+                right={props => this.props.isActive
39
+                    ? <List.Icon
40
+                        {...props}
41
+                        icon={"check"}
42
+                        color={this.props.theme.colors.success}
43
+                    /> : null}
44
+                style={{
45
+                    height: this.props.height,
46
+                    justifyContent: 'center',
47
+                    paddingLeft: 30,
48
+                    backgroundColor: this.props.isActive ? this.props.theme.colors.proxiwashFinishedColor : "transparent"
49
+                }}
50
+            />
51
+        );
52
+    }
53
+}
54
+
55
+export default withTheme(DashboardEditItem);

+ 58
- 0
src/components/Lists/DashboardEdit/DashboardEditPreviewItem.js View File

@@ -0,0 +1,58 @@
1
+// @flow
2
+
3
+import * as React from 'react';
4
+import {TouchableRipple, withTheme} from 'react-native-paper';
5
+import {Dimensions, Image, View} from "react-native";
6
+import type {CustomTheme} from "../../../managers/ThemeManager";
7
+
8
+type Props = {
9
+    image: string,
10
+    isActive: boolean,
11
+    onPress: () => void,
12
+    theme: CustomTheme,
13
+};
14
+
15
+/**
16
+ * Component used to render a small dashboard item
17
+ */
18
+class DashboardEditPreviewItem extends React.Component<Props> {
19
+
20
+    itemSize: number;
21
+
22
+    constructor(props: Props) {
23
+        super(props);
24
+        this.itemSize = Dimensions.get('window').width / 8;
25
+    }
26
+
27
+    render() {
28
+        const props = this.props;
29
+        return (
30
+            <TouchableRipple
31
+                onPress={this.props.onPress}
32
+                borderless={true}
33
+                style={{
34
+                    marginLeft: 5,
35
+                    marginRight: 5,
36
+                    backgroundColor: this.props.isActive ? this.props.theme.colors.textDisabled : "transparent",
37
+                    borderRadius: 5
38
+                }}
39
+            >
40
+                <View style={{
41
+                    width: this.itemSize,
42
+                    height: this.itemSize,
43
+                }}>
44
+                    <Image
45
+                        source={{uri: props.image}}
46
+                        style={{
47
+                            width: "100%",
48
+                            height: "100%",
49
+                        }}
50
+                    />
51
+                </View>
52
+            </TouchableRipple>
53
+        );
54
+    }
55
+
56
+}
57
+
58
+export default withTheme(DashboardEditPreviewItem)

+ 68
- 4
src/managers/ServicesManager.js View File

@@ -31,6 +31,8 @@ const ACCOUNT_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Account
31 31
 const WASHER_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/ProxiwashLaveLinge.png";
32 32
 const DRYER_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/ProxiwashSecheLinge.png";
33 33
 
34
+const AMICALE_LOGO = require("../../assets/amicale.png");
35
+
34 36
 export const SERVICES_KEY = {
35 37
     CLUBS: "clubs",
36 38
     PROFILE: "profile",
@@ -51,6 +53,14 @@ export const SERVICES_KEY = {
51 53
     DRYERS: "dryers",
52 54
 }
53 55
 
56
+export const SERVICES_CATEGORIES_KEY = {
57
+    AMICALE: "amicale",
58
+    STUDENTS: "students",
59
+    INSA: "insa",
60
+    SPECIAL: "special",
61
+}
62
+
63
+
54 64
 export type ServiceItem = {
55 65
     key: string,
56 66
     title: string,
@@ -60,6 +70,15 @@ export type ServiceItem = {
60 70
     badgeFunction?: (dashboard: fullDashboard) => number,
61 71
 }
62 72
 
73
+export type ServiceCategory = {
74
+    key: string,
75
+    title: string,
76
+    subtitle: string,
77
+    image: string | number,
78
+    content: Array<ServiceItem>
79
+}
80
+
81
+
63 82
 export default class ServicesManager {
64 83
 
65 84
     navigation: StackNavigationProp;
@@ -69,6 +88,8 @@ export default class ServicesManager {
69 88
     insaDataset: Array<ServiceItem>;
70 89
     specialDataset: Array<ServiceItem>;
71 90
 
91
+    categoriesDataset: Array<ServiceCategory>;
92
+
72 93
     constructor(nav: StackNavigationProp) {
73 94
         this.navigation = nav;
74 95
         this.amicaleDataset = [
@@ -213,7 +234,7 @@ export default class ServicesManager {
213 234
             {
214 235
                 key: SERVICES_KEY.WASHERS,
215 236
                 title: i18n.t('screens.proxiwash.washers'),
216
-                subtitle: i18n.t('screens.proxiwash.title'), // TODO add description
237
+                subtitle: i18n.t('screens.services.descriptions.washers'),
217 238
                 image: WASHER_IMAGE,
218 239
                 onPress: () => nav.navigate("proxiwash"),
219 240
                 badgeFunction: (dashboard: fullDashboard) => dashboard.available_washers
@@ -221,12 +242,42 @@ export default class ServicesManager {
221 242
             {
222 243
                 key: SERVICES_KEY.DRYERS,
223 244
                 title: i18n.t('screens.proxiwash.dryers'),
224
-                subtitle: i18n.t('screens.proxiwash.title'), // TODO add description
245
+                subtitle: i18n.t('screens.services.descriptions.washers'),
225 246
                 image: DRYER_IMAGE,
226 247
                 onPress: () => nav.navigate("proxiwash"),
227 248
                 badgeFunction: (dashboard: fullDashboard) => dashboard.available_dryers
228 249
             }
229
-        ]
250
+        ];
251
+        this.categoriesDataset = [
252
+            {
253
+                key: SERVICES_CATEGORIES_KEY.AMICALE,
254
+                title: i18n.t("screens.services.categories.amicale"),
255
+                subtitle: i18n.t("screens.services.more"),
256
+                image: AMICALE_LOGO,
257
+                content: this.amicaleDataset
258
+            },
259
+            {
260
+                key: SERVICES_CATEGORIES_KEY.STUDENTS,
261
+                title: i18n.t("screens.services.categories.students"),
262
+                subtitle: i18n.t("screens.services.more"),
263
+                image: 'account-group',
264
+                content: this.studentsDataset
265
+            },
266
+            {
267
+                key: SERVICES_CATEGORIES_KEY.INSA,
268
+                title: i18n.t("screens.services.categories.insa"),
269
+                subtitle: i18n.t("screens.services.more"),
270
+                image: 'school',
271
+                content: this.insaDataset
272
+            },
273
+            {
274
+                key: SERVICES_CATEGORIES_KEY.SPECIAL,
275
+                title: i18n.t("screens.services.categories.special"),
276
+                subtitle: i18n.t("screens.services.categories.special"),
277
+                image: 'star',
278
+                content: this.specialDataset
279
+            },
280
+        ];
230 281
     }
231 282
 
232 283
     /**
@@ -249,7 +300,7 @@ export default class ServicesManager {
249 300
      * @param sourceList The item list to use as source
250 301
      * @returns {[]}
251 302
      */
252
-    getStrippedList(idList: Array<string>, sourceList: Array<ServiceItem>) {
303
+    getStrippedList(idList: Array<string>, sourceList: Array<{key: string, [key: string]: any}>) {
253 304
         let newArray = [];
254 305
         for (let i = 0; i < sourceList.length; i++) {
255 306
             const item = sourceList[i];
@@ -311,4 +362,17 @@ export default class ServicesManager {
311 362
             return this.specialDataset;
312 363
     }
313 364
 
365
+    /**
366
+     * Gets all services sorted by category
367
+     *
368
+     * @param excludedItems Ids of categories to exclude from the returned list
369
+     * @returns {Array<ServiceCategory>}
370
+     */
371
+    getCategories(excludedItems?: Array<string>) {
372
+        if (excludedItems != null)
373
+            return this.getStrippedList(excludedItems, this.categoriesDataset)
374
+        else
375
+            return this.categoriesDataset;
376
+    }
377
+
314 378
 }

+ 9
- 1
src/navigation/MainNavigator.js View File

@@ -1,7 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import SettingsScreen from '../screens/Other/SettingsScreen';
4
+import SettingsScreen from '../screens/Other/Settings/SettingsScreen';
5 5
 import AboutScreen from '../screens/About/AboutScreen';
6 6
 import AboutDependenciesScreen from '../screens/About/AboutDependenciesScreen';
7 7
 import DebugScreen from '../screens/About/DebugScreen';
@@ -26,6 +26,7 @@ import WebsiteScreen from "../screens/Services/WebsiteScreen";
26 26
 import EquipmentScreen from "../screens/Amicale/Equipment/EquipmentListScreen";
27 27
 import EquipmentLendScreen from "../screens/Amicale/Equipment/EquipmentRentScreen";
28 28
 import EquipmentConfirmScreen from "../screens/Amicale/Equipment/EquipmentConfirmScreen";
29
+import DashboardEditScreen from "../screens/Other/Settings/DashboardEditScreen";
29 30
 
30 31
 const modalTransition = Platform.OS === 'ios' ? TransitionPresets.ModalPresentationIOS : TransitionPresets.ModalSlideFromBottomIOS;
31 32
 
@@ -63,6 +64,13 @@ function MainStackComponent(props: { createTabNavigator: () => React.Node }) {
63 64
                 }}
64 65
             />
65 66
             <MainStack.Screen
67
+                name="dashboard-edit"
68
+                component={DashboardEditScreen}
69
+                options={{
70
+                    title: i18n.t('screens.settings.dashboardEdit.title'),
71
+                }}
72
+            />
73
+            <MainStack.Screen
66 74
                 name="about"
67 75
                 component={AboutScreen}
68 76
                 options={{

+ 148
- 0
src/screens/Other/Settings/DashboardEditScreen.js View File

@@ -0,0 +1,148 @@
1
+// @flow
2
+
3
+import * as React from 'react';
4
+import {StackNavigationProp} from "@react-navigation/stack";
5
+import type {CustomTheme} from "../../../managers/ThemeManager";
6
+import {Button, Paragraph, withTheme} from "react-native-paper";
7
+import type {ServiceCategory, ServiceItem} from "../../../managers/ServicesManager";
8
+import DashboardManager from "../../../managers/DashboardManager";
9
+import DashboardItem from "../../../components/Home/EventDashboardItem";
10
+import {FlatList} from "react-native";
11
+import {View} from "react-native-animatable";
12
+import DashboardEditAccordion from "../../../components/Lists/DashboardEdit/DashboardEditAccordion";
13
+import DashboardEditPreviewItem from "../../../components/Lists/DashboardEdit/DashboardEditPreviewItem";
14
+import AsyncStorageManager from "../../../managers/AsyncStorageManager";
15
+import i18n from "i18n-js";
16
+
17
+type Props = {
18
+    navigation: StackNavigationProp,
19
+    theme: CustomTheme,
20
+};
21
+
22
+type State = {
23
+    currentDashboard: Array<ServiceItem>,
24
+    currentDashboardIdList: Array<string>,
25
+    activeItem: number,
26
+};
27
+
28
+/**
29
+ * Class defining the Settings screen. This screen shows controls to modify app preferences.
30
+ */
31
+class DashboardEditScreen extends React.Component<Props, State> {
32
+
33
+    content: Array<ServiceCategory>;
34
+    initialDashboard: Array<ServiceItem>;
35
+    initialDashboardIdList: Array<string>;
36
+
37
+    constructor(props: Props) {
38
+        super(props);
39
+        let dashboardManager = new DashboardManager(this.props.navigation);
40
+        this.initialDashboardIdList = JSON.parse(AsyncStorageManager.getInstance().preferences.dashboardItems.current);
41
+        this.initialDashboard = dashboardManager.getCurrentDashboard();
42
+        this.state = {
43
+            currentDashboard: [...this.initialDashboard],
44
+            currentDashboardIdList: [...this.initialDashboardIdList],
45
+            activeItem: 0,
46
+        }
47
+        this.content = dashboardManager.getCategories();
48
+    }
49
+
50
+    dashboardRowRenderItem = ({item, index}: { item: DashboardItem, index: number }) => {
51
+        return (
52
+            <DashboardEditPreviewItem
53
+                image={item.image}
54
+                onPress={() => this.setState({activeItem: index})}
55
+                isActive={this.state.activeItem === index}
56
+            />
57
+        );
58
+    };
59
+
60
+    getDashboard(content: Array<DashboardItem>) {
61
+        return (
62
+            <FlatList
63
+                data={content}
64
+                extraData={this.state}
65
+                renderItem={this.dashboardRowRenderItem}
66
+                horizontal={true}
67
+                contentContainerStyle={{
68
+                    marginLeft: 'auto',
69
+                    marginRight: 'auto',
70
+                    marginTop: 5,
71
+                }}
72
+            />);
73
+    }
74
+
75
+    renderItem = ({item}: { item: ServiceCategory }) => {
76
+        return (
77
+            <DashboardEditAccordion
78
+                item={item}
79
+                onPress={this.updateDashboard}
80
+                activeDashboard={this.state.currentDashboardIdList}
81
+            />
82
+        );
83
+    };
84
+
85
+    updateDashboard = (service: ServiceItem) => {
86
+        let currentDashboard = this.state.currentDashboard;
87
+        let currentDashboardIdList = this.state.currentDashboardIdList;
88
+        currentDashboard[this.state.activeItem] = service;
89
+        currentDashboardIdList[this.state.activeItem] = service.key;
90
+        this.setState({
91
+            currentDashboard: currentDashboard,
92
+            currentDashboardIdList: currentDashboardIdList,
93
+        });
94
+        AsyncStorageManager.getInstance().savePref(
95
+            AsyncStorageManager.getInstance().preferences.dashboardItems.key,
96
+            JSON.stringify(currentDashboardIdList)
97
+        );
98
+    }
99
+
100
+    undoDashboard= () => {
101
+        this.setState({
102
+            currentDashboard: [...this.initialDashboard],
103
+            currentDashboardIdList: [...this.initialDashboardIdList]
104
+        });
105
+        AsyncStorageManager.getInstance().savePref(
106
+            AsyncStorageManager.getInstance().preferences.dashboardItems.key,
107
+            JSON.stringify(this.initialDashboardIdList)
108
+        );
109
+    }
110
+
111
+
112
+    render() {
113
+        return (
114
+            <View style={{flex: 1}}>
115
+                <View style={{
116
+                    padding: 5
117
+                }}>
118
+                    <Button
119
+                        mode={"contained"}
120
+                        onPress={this.undoDashboard}
121
+                        style={{
122
+                            marginLeft: "auto",
123
+                            marginRight: "auto",
124
+                        }}
125
+                    >
126
+                        {i18n.t("screens.settings.dashboardEdit.undo")}
127
+                    </Button>
128
+                    <View style={{
129
+                        height: 50
130
+                    }}>
131
+                        {this.getDashboard(this.state.currentDashboard)}
132
+                    </View>
133
+
134
+                </View>
135
+                    <FlatList
136
+                        data={this.content}
137
+                        renderItem={this.renderItem}
138
+                        ListHeaderComponent={<Paragraph>{i18n.t("screens.settings.dashboardEdit.message")}</Paragraph>}
139
+                        style={{
140
+                        }}
141
+                    />
142
+            </View>
143
+        );
144
+    }
145
+
146
+}
147
+
148
+export default withTheme(DashboardEditScreen);

src/screens/Other/SettingsScreen.js → src/screens/Other/Settings/SettingsScreen.js View File

@@ -2,13 +2,13 @@
2 2
 
3 3
 import * as React from 'react';
4 4
 import {ScrollView, View} from "react-native";
5
-import type {CustomTheme} from "../../managers/ThemeManager";
6
-import ThemeManager from '../../managers/ThemeManager';
5
+import type {CustomTheme} from "../../../managers/ThemeManager";
6
+import ThemeManager from '../../../managers/ThemeManager';
7 7
 import i18n from "i18n-js";
8
-import AsyncStorageManager from "../../managers/AsyncStorageManager";
8
+import AsyncStorageManager from "../../../managers/AsyncStorageManager";
9 9
 import {Card, List, Switch, ToggleButton, withTheme} from 'react-native-paper';
10 10
 import {Appearance} from "react-native-appearance";
11
-import CustomSlider from "../../components/Overrides/CustomSlider";
11
+import CustomSlider from "../../../components/Overrides/CustomSlider";
12 12
 import {StackNavigationProp} from "@react-navigation/stack";
13 13
 
14 14
 type Props = {
@@ -203,6 +203,12 @@ class SettingsScreen extends React.Component<Props, State> {
203 203
                             left={props => <List.Icon {...props} icon="power"/>}
204 204
                         />
205 205
                         {this.getStartScreenPicker()}
206
+                        <List.Item
207
+                            title={i18n.t('screens.settings.dashboard')}
208
+                            description={i18n.t('screens.settings.dashboardSub')}
209
+                            onPress={() => this.props.navigation.navigate("dashboard-edit")}
210
+                            left={props => <List.Icon {...props} icon="view-dashboard"/>}
211
+                        />
206 212
                     </List.Section>
207 213
                 </Card>
208 214
                 <Card style={{margin: 5}}>

+ 2
- 29
src/screens/Services/ServicesScreen.js View File

@@ -16,7 +16,7 @@ import {StackNavigationProp} from "@react-navigation/stack";
16 16
 import {MASCOT_STYLE} from "../../components/Mascot/Mascot";
17 17
 import MascotPopup from "../../components/Mascot/MascotPopup";
18 18
 import AsyncStorageManager from "../../managers/AsyncStorageManager";
19
-import ServicesManager from "../../managers/ServicesManager";
19
+import ServicesManager, {SERVICES_CATEGORIES_KEY} from "../../managers/ServicesManager";
20 20
 
21 21
 type Props = {
22 22
     navigation: StackNavigationProp,
@@ -36,14 +36,9 @@ export type listItem = {
36 36
     content: cardList,
37 37
 }
38 38
 
39
-const AMICALE_LOGO = require("../../../assets/amicale.png");
40 39
 
41 40
 class ServicesScreen extends React.Component<Props, State> {
42 41
 
43
-    amicaleDataset: cardList;
44
-    studentsDataset: cardList;
45
-    insaDataset: cardList;
46
-
47 42
     finalDataset: Array<listItem>
48 43
 
49 44
     state = {
@@ -53,29 +48,7 @@ class ServicesScreen extends React.Component<Props, State> {
53 48
     constructor(props) {
54 49
         super(props);
55 50
         const services = new ServicesManager(props.navigation);
56
-        this.amicaleDataset = services.getAmicaleServices();
57
-        this.studentsDataset = services.getStudentServices();
58
-        this.insaDataset = services.getINSAServices();
59
-        this.finalDataset = [
60
-            {
61
-                title: i18n.t("screens.services.categories.amicale"),
62
-                description: i18n.t("screens.services.more"),
63
-                image: AMICALE_LOGO,
64
-                content: this.amicaleDataset
65
-            },
66
-            {
67
-                title: i18n.t("screens.services.categories.students"),
68
-                description: i18n.t("screens.services.more"),
69
-                image: 'account-group',
70
-                content: this.studentsDataset
71
-            },
72
-            {
73
-                title: i18n.t("screens.services.categories.insa"),
74
-                description: i18n.t("screens.services.more"),
75
-                image: 'school',
76
-                content: this.insaDataset
77
-            },
78
-        ];
51
+        this.finalDataset = services.getCategories([SERVICES_CATEGORIES_KEY.SPECIAL])
79 52
     }
80 53
 
81 54
     componentDidMount() {

Loading…
Cancel
Save