|
@@ -1,14 +1,13 @@
|
1
|
1
|
// @flow
|
2
|
2
|
|
3
|
3
|
import * as React from 'react';
|
4
|
|
-import {TouchableOpacity, View} from 'react-native';
|
|
4
|
+import {View} from 'react-native';
|
5
|
5
|
import i18n from "i18n-js";
|
6
|
|
-import Autolink from 'react-native-autolink';
|
7
|
6
|
import ThemeManager from "../utils/ThemeManager";
|
8
|
7
|
import DashboardItem from "../components/EventDashboardItem";
|
9
|
8
|
import * as WebBrowser from 'expo-web-browser';
|
10
|
9
|
import WebSectionList from "../components/WebSectionList";
|
11
|
|
-import {Avatar, Button, Card, Text} from 'react-native-paper';
|
|
10
|
+import {Text} from 'react-native-paper';
|
12
|
11
|
import FeedItem from "../components/FeedItem";
|
13
|
12
|
import SquareDashboardItem from "../components/SquareDashboardItem";
|
14
|
13
|
import PreviewEventDashboardItem from "../components/PreviewEventDashboardItem";
|
|
@@ -109,36 +108,32 @@ export default class HomeScreen extends React.Component<Props> {
|
109
|
108
|
|
110
|
109
|
generateDashboardDataset(dashboardData: Object) {
|
111
|
110
|
let dataset = [
|
112
|
|
- {
|
113
|
|
- id: 'event',
|
114
|
|
- content: undefined
|
115
|
|
- },
|
|
111
|
+
|
116
|
112
|
{
|
117
|
113
|
id: 'middle',
|
118
|
|
- content: [{}, {}]
|
|
114
|
+ content: []
|
119
|
115
|
},
|
120
|
116
|
{
|
121
|
|
- id: 'bottom',
|
122
|
|
- content: [{}, {}]
|
|
117
|
+ id: 'event',
|
|
118
|
+ content: undefined
|
123
|
119
|
},
|
124
|
|
-
|
125
|
120
|
];
|
126
|
121
|
for (let [key, value] of Object.entries(dashboardData)) {
|
127
|
122
|
switch (key) {
|
128
|
123
|
case 'today_events':
|
129
|
|
- dataset[0]['content'] = value;
|
|
124
|
+ dataset[1]['content'] = value;
|
130
|
125
|
break;
|
131
|
126
|
case 'available_machines':
|
132
|
|
- dataset[1]['content'][0] = {id: key, data: value};
|
|
127
|
+ dataset[0]['content'][0] = {id: key, data: value};
|
133
|
128
|
break;
|
134
|
129
|
case 'available_tutorials':
|
135
|
|
- dataset[1]['content'][1] = {id: key, data: value};
|
|
130
|
+ dataset[0]['content'][1] = {id: key, data: value};
|
136
|
131
|
break;
|
137
|
132
|
case 'proximo_articles':
|
138
|
|
- dataset[2]['content'][0] = {id: key, data: value};
|
|
133
|
+ dataset[0]['content'][2] = {id: key, data: value};
|
139
|
134
|
break;
|
140
|
135
|
case 'today_menu':
|
141
|
|
- dataset[2]['content'][1] = {id: key, data: value};
|
|
136
|
+ dataset[0]['content'][3] = {id: key, data: value};
|
142
|
137
|
break;
|
143
|
138
|
|
144
|
139
|
}
|
|
@@ -152,8 +147,6 @@ export default class HomeScreen extends React.Component<Props> {
|
152
|
147
|
return this.getDashboardEventItem(content);
|
153
|
148
|
else if (item['id'] === 'middle')
|
154
|
149
|
return this.getDashboardMiddleItem(content);
|
155
|
|
- else
|
156
|
|
- return this.getDashboardBottomItem(content);
|
157
|
150
|
}
|
158
|
151
|
|
159
|
152
|
/**
|
|
@@ -310,7 +303,8 @@ export default class HomeScreen extends React.Component<Props> {
|
310
|
303
|
|
311
|
304
|
let displayEvent = this.getDisplayEvent(futureEvents);
|
312
|
305
|
const clickContainerAction = () => this.props.navigation.navigate('Planning');
|
313
|
|
- const clickPreviewAction = () => this.props.navigation.navigate('PlanningDisplayScreen', {data: displayEvent});;
|
|
306
|
+ const clickPreviewAction = () => this.props.navigation.navigate('PlanningDisplayScreen', {data: displayEvent});
|
|
307
|
+
|
314
|
308
|
return (
|
315
|
309
|
<DashboardItem
|
316
|
310
|
{...this.props}
|
|
@@ -330,164 +324,54 @@ export default class HomeScreen extends React.Component<Props> {
|
330
|
324
|
}
|
331
|
325
|
|
332
|
326
|
|
333
|
|
- getDashboardBottomItem(content: Array<Object>) {
|
334
|
|
- let proximoData = content[0]['data'];
|
335
|
|
- let menuData = content[1]['data'];
|
336
|
|
- let proximoIcon = 'shopping';
|
337
|
|
- let proximoColor = ThemeManager.getCurrentThemeVariables().proximoColor;
|
338
|
|
- let proximoTitle = i18n.t('homeScreen.dashboard.proximoTitle');
|
339
|
|
- let isProximoAvailable = parseInt(proximoData) > 0;
|
340
|
|
- let proximoSubtitle;
|
341
|
|
- if (isProximoAvailable) {
|
342
|
|
- proximoSubtitle =
|
343
|
|
- <Text>
|
344
|
|
- <Text style={{fontWeight: "bold"}}>{proximoData}</Text>
|
345
|
|
- <Text>
|
346
|
|
- {
|
347
|
|
- proximoData > 1 ?
|
348
|
|
- i18n.t('homeScreen.dashboard.proximoSubtitlePlural') :
|
349
|
|
- i18n.t('homeScreen.dashboard.proximoSubtitle')
|
350
|
|
- }
|
351
|
|
- </Text>
|
352
|
|
- </Text>;
|
353
|
|
- } else
|
354
|
|
- proximoSubtitle = i18n.t('homeScreen.dashboard.proximoSubtitleNA');
|
355
|
|
-
|
356
|
|
-
|
357
|
|
- let menuIcon = 'silverware-fork-knife';
|
358
|
|
- let menuColor = ThemeManager.getCurrentThemeVariables().menuColor;
|
359
|
|
- let menuTitle = i18n.t('homeScreen.dashboard.menuTitle');
|
360
|
|
- let isMenuAvailable = menuData.length > 0;
|
361
|
|
- let menuSubtitle;
|
362
|
|
- if (isMenuAvailable) {
|
363
|
|
- menuSubtitle = i18n.t('homeScreen.dashboard.menuSubtitle');
|
364
|
|
- } else
|
365
|
|
- menuSubtitle = i18n.t('homeScreen.dashboard.menuSubtitleNA');
|
366
|
|
- return (
|
367
|
|
- <View style={{
|
368
|
|
- flexDirection: 'row',
|
369
|
|
- marginLeft: 10,
|
370
|
|
- marginRight: 10,
|
371
|
|
- marginBottom: 10,
|
372
|
|
- }}>
|
373
|
|
- <SquareDashboardItem
|
374
|
|
- title={menuTitle}
|
375
|
|
- subtitle={menuSubtitle}
|
376
|
|
- color={menuColor}
|
377
|
|
- icon={menuIcon}
|
378
|
|
- clickAction={this.onMenuClick}
|
379
|
|
- isAvailable={isMenuAvailable}
|
380
|
|
- isLeft={true}/>
|
381
|
|
- <SquareDashboardItem
|
382
|
|
- title={proximoTitle}
|
383
|
|
- subtitle={proximoSubtitle}
|
384
|
|
- color={proximoColor}
|
385
|
|
- icon={proximoIcon}
|
386
|
|
- clickAction={this.onProximoClick}
|
387
|
|
- isAvailable={isProximoAvailable}
|
388
|
|
- isLeft={false}/>
|
389
|
|
- </View>
|
390
|
|
- );
|
391
|
|
- }
|
392
|
|
-
|
393
|
|
-
|
394
|
327
|
getDashboardMiddleItem(content: Array<Object>) {
|
395
|
328
|
let proxiwashData = content[0]['data'];
|
396
|
329
|
let tutorinsaData = content[1]['data'];
|
397
|
|
-
|
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 ?
|
404
|
|
- ThemeManager.getCurrentThemeVariables().text :
|
405
|
|
- ThemeManager.getCurrentThemeVariables().textDisabled;
|
406
|
|
- let washerColor = parseInt(proxiwashData['washers']) > 0 ?
|
407
|
|
- ThemeManager.getCurrentThemeVariables().text :
|
408
|
|
- ThemeManager.getCurrentThemeVariables().textDisabled;
|
409
|
|
- let availableDryers = proxiwashData['dryers'];
|
410
|
|
- let availableWashers = proxiwashData['washers'];
|
411
|
|
- if (proxiwashIsAvailable) {
|
412
|
|
- proxiwashSubtitle =
|
413
|
|
- <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
|
|
-
|
449
|
|
- let tutorinsaIcon = 'school';
|
450
|
|
- let tutorinsaColor = ThemeManager.getCurrentThemeVariables().tutorinsaColor;
|
451
|
|
- let tutorinsaTitle = 'Tutor\'INSA';
|
452
|
|
- let tutorinsaIsAvailable = tutorinsaData > 0;
|
453
|
|
- let tutorinsaSubtitle;
|
454
|
|
- if (tutorinsaIsAvailable) {
|
455
|
|
- tutorinsaSubtitle =
|
456
|
|
- <Text>
|
457
|
|
- <Text style={{fontWeight: "bold"}}>{tutorinsaData}</Text>
|
458
|
|
- <Text>
|
459
|
|
- {
|
460
|
|
- tutorinsaData > 1 ?
|
461
|
|
- i18n.t('homeScreen.dashboard.tutorinsaSubtitlePlural') :
|
462
|
|
- i18n.t('homeScreen.dashboard.tutorinsaSubtitle')
|
463
|
|
- }
|
464
|
|
- </Text>
|
465
|
|
- </Text>;
|
466
|
|
- } else
|
467
|
|
- tutorinsaSubtitle = i18n.t('homeScreen.dashboard.tutorinsaSubtitleNA');
|
468
|
|
-
|
|
330
|
+ let proximoData = content[2]['data'];
|
|
331
|
+ let menuData = content[3]['data'];
|
469
|
332
|
return (
|
470
|
333
|
<View style={{
|
|
334
|
+ flex: 1,
|
471
|
335
|
flexDirection: 'row',
|
472
|
|
- marginLeft: 10,
|
473
|
|
- marginRight: 10,
|
|
336
|
+ justifyContent: 'center',
|
|
337
|
+ flexWrap: 'wrap',
|
|
338
|
+ margin: 10,
|
474
|
339
|
}}>
|
475
|
340
|
<SquareDashboardItem
|
476
|
|
- title={proxiwashTitle}
|
477
|
|
- subtitle={proxiwashSubtitle}
|
478
|
|
- color={proxiwashColor}
|
479
|
|
- icon={proxiwashIcon}
|
|
341
|
+ color={ThemeManager.getCurrentThemeVariables().proxiwashColor}
|
|
342
|
+ icon={'washing-machine'}
|
|
343
|
+ clickAction={this.onProxiwashClick}
|
|
344
|
+ isAvailable={parseInt(proxiwashData['washers']) > 0}
|
|
345
|
+ badgeNumber={proxiwashData['washers']}
|
|
346
|
+ />
|
|
347
|
+ <SquareDashboardItem
|
|
348
|
+ color={ThemeManager.getCurrentThemeVariables().proxiwashColor}
|
|
349
|
+ icon={'tumble-dryer'}
|
480
|
350
|
clickAction={this.onProxiwashClick}
|
481
|
|
- isAvailable={proxiwashIsAvailable}
|
482
|
|
- isLeft={true}/>
|
|
351
|
+ isAvailable={parseInt(proxiwashData['dryers']) > 0}
|
|
352
|
+ badgeNumber={proxiwashData['dryers']}
|
|
353
|
+ />
|
483
|
354
|
<SquareDashboardItem
|
484
|
|
- title={tutorinsaTitle}
|
485
|
|
- subtitle={tutorinsaSubtitle}
|
486
|
|
- color={tutorinsaColor}
|
487
|
|
- icon={tutorinsaIcon}
|
|
355
|
+ color={ThemeManager.getCurrentThemeVariables().tutorinsaColor}
|
|
356
|
+ icon={'school'}
|
488
|
357
|
clickAction={this.onTutorInsaClick}
|
489
|
|
- isAvailable={tutorinsaIsAvailable}
|
490
|
|
- isLeft={false}/>
|
|
358
|
+ isAvailable={tutorinsaData > 0}
|
|
359
|
+ badgeNumber={tutorinsaData}
|
|
360
|
+ />
|
|
361
|
+ <SquareDashboardItem
|
|
362
|
+ color={ThemeManager.getCurrentThemeVariables().proximoColor}
|
|
363
|
+ icon={'shopping'}
|
|
364
|
+ clickAction={this.onProximoClick}
|
|
365
|
+ isAvailable={parseInt(proximoData) > 0}
|
|
366
|
+ badgeNumber={parseInt(proximoData)}
|
|
367
|
+ />
|
|
368
|
+ <SquareDashboardItem
|
|
369
|
+ color={ThemeManager.getCurrentThemeVariables().menuColor}
|
|
370
|
+ icon={'silverware-fork-knife'}
|
|
371
|
+ clickAction={this.onMenuClick}
|
|
372
|
+ isAvailable={menuData.length > 0}
|
|
373
|
+ badgeNumber={0}
|
|
374
|
+ />
|
491
|
375
|
</View>
|
492
|
376
|
);
|
493
|
377
|
}
|