|
@@ -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
|
|