|
@@ -3,7 +3,7 @@
|
3
|
3
|
import * as React from 'react';
|
4
|
4
|
import {Alert, View} from 'react-native';
|
5
|
5
|
import i18n from 'i18n-js';
|
6
|
|
-import {Avatar, Button, Card, Text, withTheme} from 'react-native-paper';
|
|
6
|
+import {Avatar, Button, Card, List, Text, withTheme} from 'react-native-paper';
|
7
|
7
|
import {StackNavigationProp} from '@react-navigation/stack';
|
8
|
8
|
import {Modalize} from 'react-native-modalize';
|
9
|
9
|
import WebSectionList from '../../components/Screens/WebSectionList';
|
|
@@ -26,31 +26,8 @@ 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';
|
30
|
|
-
|
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
|
|
-};
|
|
29
|
+import type {ListIconPropsType} from '../../constants/PaperStyles';
|
|
30
|
+import {PROXIWASH_DATA} from './ProxiwashSettingsScreen';
|
54
|
31
|
|
55
|
32
|
const modalStateStrings = {};
|
56
|
33
|
|
|
@@ -225,9 +202,6 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
|
225
|
202
|
remaining: remainingTime,
|
226
|
203
|
program: item.program,
|
227
|
204
|
});
|
228
|
|
- } else if (item.state === ProxiwashConstants.machineStates.AVAILABLE) {
|
229
|
|
- if (isDryer) message += `\n${i18n.t('screens.proxiwash.dryersTariff')}`;
|
230
|
|
- else message += `\n${i18n.t('screens.proxiwash.washersTariff')}`;
|
231
|
205
|
}
|
232
|
206
|
return (
|
233
|
207
|
<View
|
|
@@ -370,6 +344,31 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
|
370
|
344
|
}
|
371
|
345
|
|
372
|
346
|
/**
|
|
347
|
+ * Gets a chevron icon
|
|
348
|
+ *
|
|
349
|
+ * @param props
|
|
350
|
+ * @return {*}
|
|
351
|
+ */
|
|
352
|
+ static getChevronIcon(props: ListIconPropsType): React.Node {
|
|
353
|
+ return (
|
|
354
|
+ <List.Icon color={props.color} style={props.style} icon="chevron-right" />
|
|
355
|
+ );
|
|
356
|
+ }
|
|
357
|
+
|
|
358
|
+ /**
|
|
359
|
+ * Gets a custom list item icon
|
|
360
|
+ *
|
|
361
|
+ * @param item The item to show the icon for
|
|
362
|
+ * @param props
|
|
363
|
+ * @return {*}
|
|
364
|
+ */
|
|
365
|
+ static getItemIcon(item: ListItemType, props: ListIconPropsType): React.Node {
|
|
366
|
+ return (
|
|
367
|
+ <List.Icon color={props.color} style={props.style} icon={item.icon} />
|
|
368
|
+ );
|
|
369
|
+ }
|
|
370
|
+
|
|
371
|
+ /**
|
373
|
372
|
* Creates the dataset to be used by the FlatList
|
374
|
373
|
*
|
375
|
374
|
* @param fetchedData
|
|
@@ -423,24 +422,31 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
|
423
|
422
|
}
|
424
|
423
|
};
|
425
|
424
|
|
|
425
|
+ onPressCallback = () => {
|
|
426
|
+ const {navigation} = this.props;
|
|
427
|
+ navigation.navigate('proxiwash-settings');
|
|
428
|
+ };
|
|
429
|
+
|
426
|
430
|
getListHeader = (): React.Node => {
|
427
|
431
|
const {selectedWash} = this.state;
|
428
|
|
- let data: LaverieType;
|
|
432
|
+ let item: LaverieType;
|
429
|
433
|
switch (selectedWash) {
|
430
|
434
|
case 'tripodeB':
|
431
|
|
- data = DATA.tripodeB;
|
|
435
|
+ item = PROXIWASH_DATA.tripodeB;
|
432
|
436
|
break;
|
433
|
437
|
default:
|
434
|
|
- data = DATA.washinsa;
|
|
438
|
+ item = PROXIWASH_DATA.washinsa;
|
435
|
439
|
}
|
|
440
|
+ const getItemIcon = (props: ListIconPropsType): React.Node =>
|
|
441
|
+ ProxiwashScreen.getItemIcon(item, props);
|
436
|
442
|
return (
|
437
|
443
|
<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
|
+ <List.Item
|
|
445
|
+ title={item.title}
|
|
446
|
+ description={item.subtitle}
|
|
447
|
+ left={getItemIcon}
|
|
448
|
+ right={ProxiwashScreen.getChevronIcon}
|
|
449
|
+ onPress={this.onPressCallback}
|
444
|
450
|
/>
|
445
|
451
|
</Card>
|
446
|
452
|
);
|
|
@@ -490,10 +496,10 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
|
490
|
496
|
let data: LaverieType;
|
491
|
497
|
switch (state.selectedWash) {
|
492
|
498
|
case 'tripodeB':
|
493
|
|
- data = DATA.tripodeB;
|
|
499
|
+ data = PROXIWASH_DATA.tripodeB;
|
494
|
500
|
break;
|
495
|
501
|
default:
|
496
|
|
- data = DATA.washinsa;
|
|
502
|
+ data = PROXIWASH_DATA.washinsa;
|
497
|
503
|
}
|
498
|
504
|
return (
|
499
|
505
|
<View
|