Browse Source

Added tutorinsa to the dashboard + reworked item organization

keplyx 2 years ago
parent
commit
f3d1c705ae

+ 2
- 2
components/DashboardItem.js View File

@@ -140,8 +140,8 @@ export default class DashboardItem extends React.Component<Props> {
140 140
                         this.props.color :
141 141
                         ThemeManager.getCurrentThemeVariables().textDisabledColor
142 142
                 }
143
-                fontSize={this.props.isSquare ? 60 : 40}
144
-                width={this.props.isSquare ? 60 : 40}/>
143
+                fontSize={this.props.isSquare ? 50 : 40}
144
+                width={this.props.isSquare ? 50 : 40}/>
145 145
         );
146 146
     }
147 147
 

+ 1
- 0
native-base-theme/variables/platform.js View File

@@ -278,6 +278,7 @@ export default {
278 278
     proximoColor: '#ec5904',
279 279
     proxiwashColor: '#1fa5ee',
280 280
     menuColor: '#e91314',
281
+    tutorinsaColor: '#f93943',
281 282
 
282 283
 
283 284
     // Other

+ 2
- 1
native-base-theme/variables/platformDark.js View File

@@ -138,7 +138,7 @@ export default {
138 138
 
139 139
     // Footer
140 140
     footerHeight: 55,
141
-    footerDefaultBg: platform === "ios" ? "#F8F8F8" : "#be1522",
141
+    footerDefaultBg: platform === "ios" ? "#333333" : "#be1522",
142 142
     footerPaddingBottom: 0,
143 143
 
144 144
     // FooterTab
@@ -279,6 +279,7 @@ export default {
279 279
     proximoColor: '#ec5904',
280 280
     proxiwashColor: '#1fa5ee',
281 281
     menuColor: '#b81213',
282
+    tutorinsaColor: '#f93943',
282 283
 
283 284
     // Other
284 285
     borderRadiusBase: platform === "ios" ? 5 : 2,

+ 114
- 71
screens/HomeScreen.js View File

@@ -9,7 +9,7 @@ import FetchedDataSectionList from "../components/FetchedDataSectionList";
9 9
 import Autolink from 'react-native-autolink';
10 10
 import ThemeManager from "../utils/ThemeManager";
11 11
 import DashboardItem from "../components/DashboardItem";
12
-// import DATA from "../dashboard_data.json";
12
+import DATA from "../dashboard_data.json";
13 13
 
14 14
 
15 15
 const ICON_AMICALE = require('../assets/amicale.png');
@@ -39,7 +39,7 @@ function openWebLink(link) {
39 39
 export default class HomeScreen extends FetchedDataSectionList {
40 40
 
41 41
     constructor() {
42
-        super(DATA_URL, REFRESH_TIME);
42
+        super('DATA_URL', REFRESH_TIME);
43 43
     }
44 44
 
45 45
     getHeaderTranslation() {
@@ -55,7 +55,7 @@ export default class HomeScreen extends FetchedDataSectionList {
55 55
     }
56 56
 
57 57
     createDataset(fetchedData: Object) {
58
-        // fetchedData = DATA;
58
+        fetchedData = DATA;
59 59
         let newsData = [];
60 60
         let dashboardData = [];
61 61
         if (fetchedData['news_feed'] !== undefined)
@@ -83,7 +83,7 @@ export default class HomeScreen extends FetchedDataSectionList {
83 83
     generateDashboardDataset(dashboardData: Object) {
84 84
         let dataset = [
85 85
             {
86
-                id: 'top',
86
+                id: 'event',
87 87
                 content: undefined
88 88
             },
89 89
             {
@@ -92,7 +92,7 @@ export default class HomeScreen extends FetchedDataSectionList {
92 92
             },
93 93
             {
94 94
                 id: 'bottom',
95
-                content: undefined
95
+                content: [{}, {}]
96 96
             },
97 97
 
98 98
         ];
@@ -101,15 +101,19 @@ export default class HomeScreen extends FetchedDataSectionList {
101 101
                 case 'today_events':
102 102
                     dataset[0]['content'] = value;
103 103
                     break;
104
-                case 'proximo_articles':
104
+                case 'available_machines':
105 105
                     dataset[1]['content'][0] = {id: key, data: value};
106 106
                     break;
107
-                case 'today_menu':
107
+                case 'available_tutorials':
108 108
                     dataset[1]['content'][1] = {id: key, data: value};
109 109
                     break;
110
-                case 'available_machines':
111
-                    dataset[2]['content'] = value;
110
+                case 'proximo_articles':
111
+                    dataset[2]['content'][0] = {id: key, data: value};
112 112
                     break;
113
+                case 'today_menu':
114
+                    dataset[2]['content'][1] = {id: key, data: value};
115
+                    break;
116
+
113 117
             }
114 118
         }
115 119
         return dataset
@@ -147,12 +151,12 @@ export default class HomeScreen extends FetchedDataSectionList {
147 151
 
148 152
     getDashboardItem(item: Object) {
149 153
         let content = item['content'];
150
-        if (item['id'] === 'top')
154
+        if (item['id'] === 'event')
151 155
             return this.getDashboardEventItem(content);
152 156
         else if (item['id'] === 'middle')
153 157
             return this.getDashboardMiddleItem(content);
154 158
         else
155
-            return this.getDashboardProxiwashItem(content);
159
+            return this.getDashboardBottomItem(content);
156 160
     }
157 161
 
158 162
     /**
@@ -325,7 +329,7 @@ export default class HomeScreen extends FetchedDataSectionList {
325 329
     }
326 330
 
327 331
 
328
-    getDashboardMiddleItem(content: Object) {
332
+    getDashboardBottomItem(content: Array<Object>) {
329 333
         let proximoData = content[0]['data'];
330 334
         let menuData = content[1]['data'];
331 335
         let proximoIcon = 'shopping';
@@ -368,87 +372,126 @@ export default class HomeScreen extends FetchedDataSectionList {
368 372
             }}>
369 373
                 <DashboardItem
370 374
                     isSquare={true}
371
-                    subtitle={proximoSubtitle}
372
-                    color={proximoColor}
373
-                    icon={proximoIcon}
374
-                    clickAction={() => proximoClickAction()}
375
-                    title={proximoTitle}
376
-                    isAvailable={isProximoAvailable}
377
-                    isSquareLeft={true}/>
378
-                <DashboardItem
379
-                    isSquare={true}
380 375
                     subtitle={menuSubtitle}
381 376
                     color={menuColor}
382 377
                     icon={menuIcon}
383 378
                     clickAction={() => menuClickAction()}
384 379
                     title={menuTitle}
385
-                    isAvailable={isMenuAvailable}/>
386
-                {/*{this.getSquareDashboardItem(isProximoAvailable, proximoIcon, proximoColor, proximoTitle, proximoSubtitle, proximoClickAction, true)}*/}
387
-                {/*{this.getSquareDashboardItem(isMenuAvailable, menuIcon, menuColor, menuTitle, menuSubtitle, menuClickAction, false)}*/}
380
+                    isAvailable={isMenuAvailable}
381
+                    isSquareLeft={true}/>
382
+                <DashboardItem
383
+                    isSquare={true}
384
+                    subtitle={proximoSubtitle}
385
+                    color={proximoColor}
386
+                    icon={proximoIcon}
387
+                    clickAction={() => proximoClickAction()}
388
+                    title={proximoTitle}
389
+                    isAvailable={isProximoAvailable}/>
388 390
             </View>
389 391
         );
390 392
     }
391 393
 
394
+    getDashboardMiddleItem(content: Array<Object>) {
395
+        let proxiwashData = content[0]['data'];
396
+        let tutorinsaData = content[1]['data'];
392 397
 
393
-    getDashboardProxiwashItem(content: Object) {
394
-        let icon = 'washing-machine';
395
-        let color = ThemeManager.getCurrentThemeVariables().proxiwashColor;
396
-        let title = i18n.t('homeScreen.dashboard.proxiwashTitle');
397
-        let isAvailable = parseInt(content['dryers']) > 0 || parseInt(content['washers']) > 0;
398
-        let subtitle;
399
-        let dryerColor = parseInt(content['dryers']) > 0 ?
398
+        let proxiwashIcon = 'washing-machine';
399
+        let proxiwashColor = ThemeManager.getCurrentThemeVariables().proxiwashColor;
400
+        let proxiwashTitle = i18n.t('homeScreen.dashboard.proxiwashTitle');
401
+        let proxiwashIsAvailable = parseInt(proxiwashData['dryers']) > 0 || parseInt(proxiwashData['washers']) > 0;
402
+        let proxiwashSubtitle;
403
+        let dryerColor = parseInt(proxiwashData['dryers']) > 0 ?
400 404
             ThemeManager.getCurrentThemeVariables().textColor :
401 405
             ThemeManager.getCurrentThemeVariables().listNoteColor;
402
-        let washerColor = parseInt(content['washers']) > 0 ?
406
+        let washerColor = parseInt(proxiwashData['washers']) > 0 ?
403 407
             ThemeManager.getCurrentThemeVariables().textColor :
404 408
             ThemeManager.getCurrentThemeVariables().listNoteColor;
405
-        let availableDryers = content['dryers'];
406
-        let availableWashers = content['washers'];
407
-        if (isAvailable) {
408
-            subtitle =
409
-                <Text>
410
-                    <Text style={{
411
-                        fontWeight: parseInt(content['dryers']) > 0 ?
412
-                            'bold' :
413
-                            'normal',
414
-                        color: dryerColor
415
-                    }}>
416
-                        {availableDryers}
417
-                    </Text>
409
+        let availableDryers = proxiwashData['dryers'];
410
+        let availableWashers = proxiwashData['washers'];
411
+        if (proxiwashIsAvailable) {
412
+            proxiwashSubtitle =
418 413
                     <Text>
419
-                        {
420
-                            availableDryers > 1 ?
421
-                                i18n.t('homeScreen.dashboard.proxiwashSubtitle1Plural') :
422
-                                i18n.t('homeScreen.dashboard.proxiwashSubtitle1')
423
-                        }
424
-                    </Text>
425
-                    <Text style={{
426
-                        fontWeight: parseInt(content['washers']) > 0 ?
427
-                            'bold' :
428
-                            'normal',
429
-                        color: washerColor
430
-                    }}>
431
-                        {availableWashers}
432
-                    </Text>
414
+                        <Text style={{
415
+                            fontWeight: parseInt(proxiwashData['dryers']) > 0 ?
416
+                                'bold' :
417
+                                'normal',
418
+                            color: dryerColor
419
+                        }}>
420
+                            {availableDryers}
421
+                        </Text>
422
+                        <Text>
423
+                            {
424
+                                availableDryers > 1 ?
425
+                                    i18n.t('homeScreen.dashboard.proxiwashSubtitle1Plural') :
426
+                                    i18n.t('homeScreen.dashboard.proxiwashSubtitle1')
427
+                            }
428
+                        </Text>
429
+                        {"\n"}
430
+                        <Text style={{
431
+                            fontWeight: parseInt(proxiwashData['washers']) > 0 ?
432
+                                'bold' :
433
+                                'normal',
434
+                            color: washerColor
435
+                        }}>
436
+                            {availableWashers}
437
+                        </Text>
438
+                        <Text>
439
+                            {
440
+                                availableWashers > 1 ?
441
+                                    i18n.t('homeScreen.dashboard.proxiwashSubtitle2Plural') :
442
+                                    i18n.t('homeScreen.dashboard.proxiwashSubtitle2')
443
+                            }
444
+                        </Text>
445
+                    </Text>;
446
+        } else
447
+            proxiwashSubtitle = i18n.t('homeScreen.dashboard.proxiwashSubtitleNA');
448
+        let proxiwashClickAction = () => this.props.navigation.navigate('Proxiwash');
449
+
450
+        let tutorinsaIcon = 'school';
451
+        let tutorinsaColor = ThemeManager.getCurrentThemeVariables().tutorinsaColor;
452
+        let tutorinsaTitle = 'Tutor\'INSA';
453
+        let tutorinsaIsAvailable = tutorinsaData > 0;
454
+        let tutorinsaSubtitle;
455
+        if (tutorinsaIsAvailable) {
456
+            tutorinsaSubtitle =
457
+                <Text>
458
+                    <Text style={{fontWeight: "bold"}}>{tutorinsaData}</Text>
433 459
                     <Text>
434 460
                         {
435
-                            availableWashers > 1 ?
436
-                                i18n.t('homeScreen.dashboard.proxiwashSubtitle2Plural') :
437
-                                i18n.t('homeScreen.dashboard.proxiwashSubtitle2')
461
+                            tutorinsaData > 1 ?
462
+                                i18n.t('homeScreen.dashboard.tutorinsaSubtitlePlural') :
463
+                                i18n.t('homeScreen.dashboard.tutorinsaSubtitle')
438 464
                         }
439 465
                     </Text>
440 466
                 </Text>;
441 467
         } else
442
-            subtitle = i18n.t('homeScreen.dashboard.proxiwashSubtitleNA');
443
-        let clickAction = () => this.props.navigation.navigate('Proxiwash');
468
+            tutorinsaSubtitle = i18n.t('homeScreen.dashboard.tutorinsaSubtitleNA');
469
+        let tutorinsaClickAction = () => this.props.navigation.navigate('TutorInsaScreen');
470
+
444 471
         return (
445
-            <DashboardItem
446
-                subtitle={subtitle}
447
-                color={color}
448
-                icon={icon}
449
-                clickAction={() => clickAction()}
450
-                title={title}
451
-                isAvailable={isAvailable}/>
472
+            <View style={{
473
+                flexDirection: 'row',
474
+                marginLeft: 10,
475
+                marginRight: 10,
476
+            }}>
477
+                <DashboardItem
478
+                    isSquare={true}
479
+                    subtitle={proxiwashSubtitle}
480
+                    color={proxiwashColor}
481
+                    icon={proxiwashIcon}
482
+                    clickAction={() => proxiwashClickAction()}
483
+                    title={proxiwashTitle}
484
+                    isAvailable={proxiwashIsAvailable}
485
+                    isSquareLeft={true}/>
486
+                <DashboardItem
487
+                    isSquare={true}
488
+                    subtitle={tutorinsaSubtitle}
489
+                    color={tutorinsaColor}
490
+                    icon={tutorinsaIcon}
491
+                    clickAction={() => tutorinsaClickAction()}
492
+                    title={tutorinsaTitle}
493
+                    isAvailable={tutorinsaIsAvailable}/>
494
+            </View>
452 495
         );
453 496
     }
454 497
 

+ 5
- 2
translations/en.json View File

@@ -80,10 +80,13 @@
80 80
       "proximoSubtitleNA": "No articles available",
81 81
       "proximoSubtitle": " article available",
82 82
       "proximoSubtitlePlural": " articles available",
83
+      "tutorinsaSubtitleNA": "No tutorial available",
84
+      "tutorinsaSubtitle": " tutorial available",
85
+      "tutorinsaSubtitlePlural": " tutorials available",
83 86
       "proxiwashTitle": "Available machines",
84 87
       "proxiwashSubtitleNA": "No machines available",
85
-      "proxiwashSubtitle1": " dryer and ",
86
-      "proxiwashSubtitle1Plural": " dryers and ",
88
+      "proxiwashSubtitle1": " dryer",
89
+      "proxiwashSubtitle1Plural": " dryers",
87 90
       "proxiwashSubtitle2": " washer",
88 91
       "proxiwashSubtitle2Plural": " washers",
89 92
       "menuTitle": "Today's menu",

+ 11
- 8
translations/fr.json View File

@@ -80,12 +80,15 @@
80 80
       "proximoSubtitleNA": "pas d'article en vente",
81 81
       "proximoSubtitle": " article disponible",
82 82
       "proximoSubtitlePlural": " articles disponibles",
83
+      "tutorinsaSubtitleNA": "Aucun tutorat disponible",
84
+      "tutorinsaSubtitle": " tutorat disponible",
85
+      "tutorinsaSubtitlePlural": " tutorats disponibles",
83 86
       "proxiwashTitle": "Machines disponibles",
84 87
       "proxiwashSubtitleNA": "Pas de machine disponible",
85
-      "proxiwashSubtitle1": " sèches linges et ",
86
-      "proxiwashSubtitle1Plural": " sèche linge et ",
87
-      "proxiwashSubtitle2": " laves linges",
88
-      "proxiwashSubtitle2Plural": " lave linge",
88
+      "proxiwashSubtitle1": " sèche-linge",
89
+      "proxiwashSubtitle1Plural": " sèche-linges",
90
+      "proxiwashSubtitle2": " lave-linge",
91
+      "proxiwashSubtitle2Plural": " lave-linges",
89 92
       "menuTitle": "Menu d'aujourd'hui",
90 93
       "menuSubtitleNA": "Pas de menu disponible",
91 94
       "menuSubtitle": "Cliquez ici pour voir le menu"
@@ -127,10 +130,10 @@
127 130
     "paymentMethodsDescription" : "Espèce ou Lydia"
128 131
   },
129 132
   "proxiwashScreen": {
130
-    "dryer": "Sèche Linge",
131
-    "dryers": "Sèche Linges",
132
-    "washer": "Lave Linge",
133
-    "washers": "Lave Linges",
133
+    "dryer": "Sèche-Linge",
134
+    "dryers": "Sèche-Linges",
135
+    "washer": "Lave-Linge",
136
+    "washers": "Lave-Linges",
134 137
     "min": "min",
135 138
     "listUpdated": "Etat des machines mis à jour",
136 139
     "listUpdateFail": "Erreur lors de la mise à jour del'état des machines",

Loading…
Cancel
Save