|
@@ -26,9 +26,31 @@ import {
|
26
|
26
|
import {MASCOT_STYLE} from '../../components/Mascot/Mascot';
|
27
|
27
|
import MascotPopup from '../../components/Mascot/MascotPopup';
|
28
|
28
|
import type {SectionListDataType} from '../../components/Screens/WebSectionList';
|
|
29
|
+import type {CardTitleIconPropsType} from '../../constants/PaperStyles';
|
29
|
30
|
|
30
|
|
-const DATA_URL =
|
31
|
|
- 'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/washinsa_data.json';
|
|
31
|
+type LaverieType = {
|
|
32
|
+ title: string,
|
|
33
|
+ subtitle: string,
|
|
34
|
+ icon: string,
|
|
35
|
+ url: string,
|
|
36
|
+};
|
|
37
|
+
|
|
38
|
+const DATA = {
|
|
39
|
+ washinsa: {
|
|
40
|
+ title: 'Laverie INSA',
|
|
41
|
+ subtitle: 'Ta laverie préférer !!',
|
|
42
|
+ icon: 'school-outline',
|
|
43
|
+ url:
|
|
44
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/washinsa_data.json',
|
|
45
|
+ },
|
|
46
|
+ tripodeB: {
|
|
47
|
+ title: 'Laverie Tripode B',
|
|
48
|
+ subtitle: 'En vrai je sais pas trop quoi marqué.',
|
|
49
|
+ icon: 'domain',
|
|
50
|
+ url:
|
|
51
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/tripode_b_data.json',
|
|
52
|
+ },
|
|
53
|
+};
|
32
|
54
|
|
33
|
55
|
const modalStateStrings = {};
|
34
|
56
|
|
|
@@ -38,6 +60,7 @@ const LIST_ITEM_HEIGHT = 64;
|
38
|
60
|
export type ProxiwashMachineType = {
|
39
|
61
|
number: string,
|
40
|
62
|
state: string,
|
|
63
|
+ maxWeight: number,
|
41
|
64
|
startTime: string,
|
42
|
65
|
endTime: string,
|
43
|
66
|
donePercent: string,
|
|
@@ -53,6 +76,7 @@ type PropsType = {
|
53
|
76
|
type StateType = {
|
54
|
77
|
modalCurrentDisplayItem: React.Node,
|
55
|
78
|
machinesWatched: Array<ProxiwashMachineType>,
|
|
79
|
+ selectedWash: string,
|
56
|
80
|
};
|
57
|
81
|
|
58
|
82
|
/**
|
|
@@ -87,6 +111,9 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
|
87
|
111
|
machinesWatched: AsyncStorageManager.getObject(
|
88
|
112
|
AsyncStorageManager.PREFERENCES.proxiwashWatchedMachines.key,
|
89
|
113
|
),
|
|
114
|
+ selectedWash: AsyncStorageManager.getString(
|
|
115
|
+ AsyncStorageManager.PREFERENCES.selectedWash.key,
|
|
116
|
+ ),
|
90
|
117
|
};
|
91
|
118
|
modalStateStrings[ProxiwashConstants.machineStates.AVAILABLE] = i18n.t(
|
92
|
119
|
'screens.proxiwash.modal.ready',
|
|
@@ -396,6 +423,29 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
|
396
|
423
|
}
|
397
|
424
|
};
|
398
|
425
|
|
|
426
|
+ getListHeader = (): React.Node => {
|
|
427
|
+ const {selectedWash} = this.state;
|
|
428
|
+ let data: LaverieType;
|
|
429
|
+ switch (selectedWash) {
|
|
430
|
+ case 'tripodeB':
|
|
431
|
+ data = DATA.tripodeB;
|
|
432
|
+ break;
|
|
433
|
+ default:
|
|
434
|
+ data = DATA.washinsa;
|
|
435
|
+ }
|
|
436
|
+ return (
|
|
437
|
+ <Card>
|
|
438
|
+ <Card.Title
|
|
439
|
+ title={data.title}
|
|
440
|
+ subtitle={data.subtitle}
|
|
441
|
+ left={(iconProps: CardTitleIconPropsType): React.Node => (
|
|
442
|
+ <Avatar.Icon size={iconProps.size} icon={data.icon} />
|
|
443
|
+ )}
|
|
444
|
+ />
|
|
445
|
+ </Card>
|
|
446
|
+ );
|
|
447
|
+ };
|
|
448
|
+
|
399
|
449
|
/**
|
400
|
450
|
* Adds the given notifications associated to a machine ID to the watchlist, and saves the array to the preferences
|
401
|
451
|
*
|
|
@@ -437,8 +487,19 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
|
437
|
487
|
render(): React.Node {
|
438
|
488
|
const {state} = this;
|
439
|
489
|
const {navigation} = this.props;
|
|
490
|
+ let data: LaverieType;
|
|
491
|
+ switch (state.selectedWash) {
|
|
492
|
+ case 'tripodeB':
|
|
493
|
+ data = DATA.tripodeB;
|
|
494
|
+ break;
|
|
495
|
+ default:
|
|
496
|
+ data = DATA.washinsa;
|
|
497
|
+ }
|
440
|
498
|
return (
|
441
|
|
- <View style={{flex: 1}}>
|
|
499
|
+ <View
|
|
500
|
+ style={{
|
|
501
|
+ flex: 1,
|
|
502
|
+ }}>
|
442
|
503
|
<View
|
443
|
504
|
style={{
|
444
|
505
|
position: 'absolute',
|
|
@@ -448,12 +509,13 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
|
448
|
509
|
<WebSectionList
|
449
|
510
|
createDataset={this.createDataset}
|
450
|
511
|
navigation={navigation}
|
451
|
|
- fetchUrl={DATA_URL}
|
|
512
|
+ fetchUrl={data.url}
|
452
|
513
|
renderItem={this.getRenderItem}
|
453
|
514
|
renderSectionHeader={this.getRenderSectionHeader}
|
454
|
515
|
autoRefreshTime={REFRESH_TIME}
|
455
|
516
|
refreshOnFocus
|
456
|
517
|
updateData={state.machinesWatched.length}
|
|
518
|
+ renderListHeaderComponent={this.getListHeader}
|
457
|
519
|
/>
|
458
|
520
|
</View>
|
459
|
521
|
<MascotPopup
|