Browse Source

Improved list update performance

Arnaud Vergnet 4 years ago
parent
commit
47fd8b7474

+ 142
- 80
src/components/Lists/ProxiwashListItem.js View File

@@ -1,107 +1,169 @@
1 1
 import * as React from 'react';
2
-import {Avatar, Card, Text, withTheme} from 'react-native-paper';
2
+import {Avatar, List, ProgressBar, Surface, Text, withTheme} from 'react-native-paper';
3 3
 import {StyleSheet, View} from "react-native";
4 4
 import ProxiwashConstants from "../../constants/ProxiwashConstants";
5
+import i18n from "i18n-js";
6
+import AprilFoolsManager from "../../managers/AprilFoolsManager";
7
+
8
+type Props = {
9
+    item: Object,
10
+    onPress: Function,
11
+    isWatched: boolean,
12
+    isDryer: boolean,
13
+    height: number,
14
+}
5 15
 
6 16
 /**
7 17
  * Component used to display a proxiwash item, showing machine progression and state
8
- *
9
- * @param props Props to pass to the component
10
- * @return {*}
11 18
  */
12
-function ProxiwashListItem(props) {
13
-    const {colors} = props.theme;
14
-    let stateColors = {};
15
-    stateColors[ProxiwashConstants.machineStates.TERMINE] = colors.proxiwashFinishedColor;
16
-    stateColors[ProxiwashConstants.machineStates.DISPONIBLE] = colors.proxiwashReadyColor;
17
-    stateColors[ProxiwashConstants.machineStates["EN COURS"]] = colors.proxiwashRunningColor;
18
-    stateColors[ProxiwashConstants.machineStates.HS] = colors.proxiwashBrokenColor;
19
-    stateColors[ProxiwashConstants.machineStates.ERREUR] = colors.proxiwashErrorColor;
20
-    const icon = (
21
-        props.isWatched ?
22
-            <Avatar.Icon
19
+class ProxiwashListItem extends React.Component<Props> {
20
+
21
+    stateColors: Object;
22
+    stateStrings: Object;
23
+
24
+    title: string;
25
+
26
+    constructor(props) {
27
+        super(props);
28
+        this.stateColors = {};
29
+        this.stateStrings = {};
30
+
31
+        this.updateStateStrings();
32
+
33
+        let displayNumber = props.item.number;
34
+        if (AprilFoolsManager.getInstance().isAprilFoolsEnabled())
35
+            displayNumber = AprilFoolsManager.getProxiwashMachineDisplayNumber(parseInt(props.item.number));
36
+
37
+        this.title = props.isDryer
38
+            ? i18n.t('proxiwashScreen.dryer')
39
+            : i18n.t('proxiwashScreen.washer');
40
+        this.title += ' n°' + displayNumber;
41
+    }
42
+
43
+    shouldComponentUpdate(nextProps: Props): boolean {
44
+        const props = this.props;
45
+        return (nextProps.theme.dark !== props.theme.dark)
46
+            || (nextProps.item.state !== props.item.state)
47
+            || (nextProps.item.donePercent !== props.item.donePercent)
48
+            || (nextProps.isWatched !== props.isWatched);
49
+    }
50
+
51
+    updateStateStrings() {
52
+        this.stateStrings[ProxiwashConstants.machineStates.TERMINE] = i18n.t('proxiwashScreen.states.finished');
53
+        this.stateStrings[ProxiwashConstants.machineStates.DISPONIBLE] = i18n.t('proxiwashScreen.states.ready');
54
+        this.stateStrings[ProxiwashConstants.machineStates["EN COURS"]] = i18n.t('proxiwashScreen.states.running');
55
+        this.stateStrings[ProxiwashConstants.machineStates.HS] = i18n.t('proxiwashScreen.states.broken');
56
+        this.stateStrings[ProxiwashConstants.machineStates.ERREUR] = i18n.t('proxiwashScreen.states.error');
57
+    }
58
+
59
+    updateStateColors() {
60
+        const colors = this.props.theme.colors;
61
+        this.stateColors[ProxiwashConstants.machineStates.TERMINE] = colors.proxiwashFinishedColor;
62
+        this.stateColors[ProxiwashConstants.machineStates.DISPONIBLE] = colors.proxiwashReadyColor;
63
+        this.stateColors[ProxiwashConstants.machineStates["EN COURS"]] = colors.proxiwashRunningColor;
64
+        this.stateColors[ProxiwashConstants.machineStates.HS] = colors.proxiwashBrokenColor;
65
+        this.stateColors[ProxiwashConstants.machineStates.ERREUR] = colors.proxiwashErrorColor;
66
+    }
67
+
68
+    onListItemPress = () => this.props.onPress(this.title, this.props.item, this.props.isDryer);
69
+
70
+    render() {
71
+        const props = this.props;
72
+        const colors = props.theme.colors;
73
+        const machineState = props.item.state;
74
+        const isRunning = ProxiwashConstants.machineStates[machineState] === ProxiwashConstants.machineStates["EN COURS"];
75
+        const isReady = ProxiwashConstants.machineStates[machineState] === ProxiwashConstants.machineStates.DISPONIBLE;
76
+        const description = isRunning ? props.item.startTime + '/' + props.item.endTime : '';
77
+        const stateIcon = ProxiwashConstants.stateIcons[machineState];
78
+        const stateString = this.stateStrings[ProxiwashConstants.machineStates[machineState]];
79
+        const progress = isRunning
80
+            ? props.item.donePercent !== ''
81
+                ? parseInt(props.item.donePercent) / 100
82
+                : 0
83
+            : 1;
84
+
85
+        const icon = props.isWatched
86
+            ? <Avatar.Icon
23 87
                 icon={'bell-ring'}
24 88
                 size={45}
25 89
                 color={colors.primary}
26 90
                 style={styles.icon}
27
-            /> :
28
-            <Avatar.Icon
91
+            />
92
+            : <Avatar.Icon
29 93
                 icon={props.isDryer ? 'tumble-dryer' : 'washing-machine'}
30
-                color={colors.text}
31 94
                 size={40}
95
+                color={colors.text}
32 96
                 style={styles.icon}
33
-            />
34
-    );
35
-    return (
36
-        <Card
37
-            style={{
38
-                margin: 5,
39
-                height: props.height,
40
-                justifyContent: 'center',
41
-            }}
42
-            onPress={props.onPress}
43
-        >
44
-            {ProxiwashConstants.machineStates[props.state] === ProxiwashConstants.machineStates["EN COURS"] ?
45
-                <Card style={{
46
-                    ...styles.backgroundCard,
47
-                    backgroundColor: colors.proxiwashRunningBgColor,
48
-
49
-                }}/> : null
50
-            }
51
-
52
-            <Card style={{
53
-                ...styles.progressionCard,
54
-                width: props.progress,
55
-                backgroundColor: stateColors[ProxiwashConstants.machineStates[props.state]],
56
-            }}/>
57
-            <Card.Title
58
-                title={props.title}
59
-                titleStyle={{fontSize: 17}}
60
-                subtitle={props.description}
61
-                style={styles.title}
62
-                left={() => icon}
63
-                right={() => (
64
-                    <View style={{flexDirection: 'row'}}>
65
-                        <View style={{justifyContent: 'center'}}>
66
-                            <Text style={
67
-                                ProxiwashConstants.machineStates[props.state] === ProxiwashConstants.machineStates.TERMINE ?
68
-                                    {fontWeight: 'bold',} : {}}
69
-                            >
70
-                                {props.statusText}
71
-                            </Text>
72
-                        </View>
73
-                        <Avatar.Icon
74
-                            icon={props.statusIcon}
75
-                            color={colors.text}
76
-                            size={30}
77
-                            style={styles.icon}
97
+            />;
98
+        this.updateStateColors();
99
+        return (
100
+            <Surface
101
+                style={{
102
+                    ...styles.container,
103
+                    height: props.height,
104
+                    borderRadius: 4,
105
+                }}
106
+            >
107
+                {
108
+                    !isReady
109
+                        ? <ProgressBar
110
+                            style={{
111
+                                ...styles.progressBar,
112
+                                height: props.height
113
+                            }}
114
+                            progress={progress}
115
+                            color={this.stateColors[ProxiwashConstants.machineStates[machineState]]}
78 116
                         />
79
-                    </View>)}
80
-            />
81
-        </Card>
82
-    );
117
+                        : null
118
+                }
119
+                <List.Item
120
+                    title={this.title}
121
+                    description={description}
122
+                    style={{
123
+                        height: props.height,
124
+                        justifyContent: 'center',
125
+                    }}
126
+                    onPress={this.onListItemPress}
127
+                    left={() => icon}
128
+                    right={() => (
129
+                        <View style={{flexDirection: 'row',}}>
130
+                            <View style={{justifyContent: 'center',}}>
131
+                                <Text style={
132
+                                    ProxiwashConstants.machineStates[machineState] === ProxiwashConstants.machineStates.TERMINE ?
133
+                                        {fontWeight: 'bold',} : {}}
134
+                                >
135
+                                    {stateString}
136
+                                </Text>
137
+                            </View>
138
+                            <View style={{justifyContent: 'center',}}>
139
+                                <Avatar.Icon
140
+                                    icon={stateIcon}
141
+                                    color={colors.text}
142
+                                    size={30}
143
+                                    style={styles.icon}
144
+                                />
145
+                            </View>
146
+                        </View>)}
147
+                />
148
+            </Surface>
149
+        );
150
+    }
83 151
 }
84 152
 
85 153
 const styles = StyleSheet.create({
154
+    container: {
155
+        margin: 5,
156
+        justifyContent: 'center',
157
+        elevation: 1
158
+    },
86 159
     icon: {
87 160
         backgroundColor: 'transparent'
88 161
     },
89
-    backgroundCard: {
90
-        height: '100%',
162
+    progressBar: {
91 163
         position: 'absolute',
92 164
         left: 0,
93
-        width: '100%',
94
-        elevation: 0,
165
+        borderRadius: 4,
95 166
     },
96
-    progressionCard: {
97
-        height: '100%',
98
-        position: 'absolute',
99
-        left: 0,
100
-        elevation: 0,
101
-    },
102
-    title: {
103
-        backgroundColor: 'transparent',
104
-    }
105 167
 });
106 168
 
107 169
 export default withTheme(ProxiwashListItem);

+ 69
- 0
src/components/Lists/ProxiwashSectionHeader.js View File

@@ -0,0 +1,69 @@
1
+import * as React from 'react';
2
+import {Avatar, Text, withTheme} from 'react-native-paper';
3
+import {StyleSheet, View} from "react-native";
4
+import i18n from "i18n-js";
5
+
6
+type Props = {
7
+    title: string,
8
+    isDryer: boolean,
9
+    nbAvailable: number,
10
+}
11
+
12
+/**
13
+ * Component used to display a proxiwash item, showing machine progression and state
14
+ */
15
+class ProxiwashListItem extends React.Component<Props> {
16
+
17
+    constructor(props) {
18
+        super(props);
19
+    }
20
+
21
+    shouldComponentUpdate(nextProps: Props) {
22
+        return (nextProps.theme.dark !== this.props.theme.dark)
23
+            || (nextProps.nbAvailable !== this.props.nbAvailable)
24
+    }
25
+
26
+    render() {
27
+        const props = this.props;
28
+        const subtitle = props.nbAvailable + ' ' + (
29
+            (props.nbAvailable <= 1)
30
+                ? i18n.t('proxiwashScreen.numAvailable')
31
+                : i18n.t('proxiwashScreen.numAvailablePlural'));
32
+        return (
33
+            <View style={styles.container}>
34
+                <Avatar.Icon
35
+                    icon={props.isDryer ? 'tumble-dryer' : 'washing-machine'}
36
+                    color={this.props.theme.colors.primary}
37
+                    style={styles.icon}
38
+                />
39
+                <View style={{justifyContent: 'center'}}>
40
+                    <Text style={styles.text}>
41
+                        {props.title}
42
+                    </Text>
43
+                    <Text style={{color: this.props.theme.colors.subtitle}}>
44
+                        {subtitle}
45
+                    </Text>
46
+                </View>
47
+            </View>
48
+        );
49
+    }
50
+}
51
+
52
+const styles = StyleSheet.create({
53
+    container: {
54
+        flexDirection: 'row',
55
+        marginLeft: 5,
56
+        marginRight: 5,
57
+        marginBottom: 10,
58
+        marginTop: 20,
59
+    },
60
+    icon: {
61
+        backgroundColor: 'transparent'
62
+    },
63
+    text: {
64
+        fontSize: 20,
65
+        fontWeight: 'bold',
66
+    }
67
+});
68
+
69
+export default withTheme(ProxiwashListItem);

+ 7
- 1
src/constants/ProxiwashConstants.js View File

@@ -1,4 +1,3 @@
1
-
2 1
 export default {
3 2
     machineStates: {
4 3
         "TERMINE": "0",
@@ -7,4 +6,11 @@ export default {
7 6
         "HS": "3",
8 7
         "ERREUR": "4"
9 8
     },
9
+    stateIcons: {
10
+        "TERMINE": 'check-circle',
11
+        "DISPONIBLE": 'radiobox-blank',
12
+        "EN COURS": 'progress-check',
13
+        "HS": 'alert-octagram-outline',
14
+        "ERREUR": 'alert'
15
+    }
10 16
 };

+ 25
- 105
src/screens/Proxiwash/ProxiwashScreen.js View File

@@ -13,12 +13,11 @@ import ProxiwashConstants from "../../constants/ProxiwashConstants";
13 13
 import CustomModal from "../../components/Custom/CustomModal";
14 14
 import AprilFoolsManager from "../../managers/AprilFoolsManager";
15 15
 import MaterialHeaderButtons, {Item} from "../../components/Custom/HeaderButton";
16
+import ProxiwashSectionHeader from "../../components/Lists/ProxiwashSectionHeader";
16 17
 
17 18
 const DATA_URL = "https://etud.insa-toulouse.fr/~amicale_app/washinsa/washinsa.json";
18 19
 
19
-let stateStrings = {};
20 20
 let modalStateStrings = {};
21
-let stateIcons = {};
22 21
 
23 22
 const REFRESH_TIME = 1000 * 10; // Refresh every 10 seconds
24 23
 const LIST_ITEM_HEIGHT = 64;
@@ -30,7 +29,6 @@ type Props = {
30 29
 
31 30
 type State = {
32 31
     refreshing: boolean,
33
-    firstLoading: boolean,
34 32
     modalCurrentDisplayItem: React.Node,
35 33
     machinesWatched: Array<string>,
36 34
     bannerVisible: boolean,
@@ -45,22 +43,12 @@ class ProxiwashScreen extends React.Component<Props, State> {
45 43
 
46 44
     modalRef: Object;
47 45
 
48
-    onAboutPress: Function;
49
-    getRenderItem: Function;
50
-    getRenderSectionHeader: Function;
51
-    createDataset: Function;
52
-    onHideBanner: Function;
53
-    onModalRef: Function;
54
-
55 46
     fetchedData: Object;
56
-    colors: Object;
57 47
 
58 48
     state = {
59 49
         refreshing: false,
60
-        firstLoading: true,
61
-        fetchedData: {},
62
-        machinesWatched: [],
63 50
         modalCurrentDisplayItem: null,
51
+        machinesWatched: [],
64 52
         bannerVisible: AsyncStorageManager.getInstance().preferences.proxiwashShowBanner.current === '1',
65 53
     };
66 54
 
@@ -69,53 +57,31 @@ class ProxiwashScreen extends React.Component<Props, State> {
69 57
      */
70 58
     constructor(props) {
71 59
         super(props);
72
-        stateStrings[ProxiwashConstants.machineStates.TERMINE] = i18n.t('proxiwashScreen.states.finished');
73
-        stateStrings[ProxiwashConstants.machineStates.DISPONIBLE] = i18n.t('proxiwashScreen.states.ready');
74
-        stateStrings[ProxiwashConstants.machineStates["EN COURS"]] = i18n.t('proxiwashScreen.states.running');
75
-        stateStrings[ProxiwashConstants.machineStates.HS] = i18n.t('proxiwashScreen.states.broken');
76
-        stateStrings[ProxiwashConstants.machineStates.ERREUR] = i18n.t('proxiwashScreen.states.error');
77
-
78 60
         modalStateStrings[ProxiwashConstants.machineStates.TERMINE] = i18n.t('proxiwashScreen.modal.finished');
79 61
         modalStateStrings[ProxiwashConstants.machineStates.DISPONIBLE] = i18n.t('proxiwashScreen.modal.ready');
80 62
         modalStateStrings[ProxiwashConstants.machineStates["EN COURS"]] = i18n.t('proxiwashScreen.modal.running');
81 63
         modalStateStrings[ProxiwashConstants.machineStates.HS] = i18n.t('proxiwashScreen.modal.broken');
82 64
         modalStateStrings[ProxiwashConstants.machineStates.ERREUR] = i18n.t('proxiwashScreen.modal.error');
83
-
84
-        stateIcons[ProxiwashConstants.machineStates.TERMINE] = 'check-circle';
85
-        stateIcons[ProxiwashConstants.machineStates.DISPONIBLE] = 'radiobox-blank';
86
-        stateIcons[ProxiwashConstants.machineStates["EN COURS"]] = 'progress-check';
87
-        stateIcons[ProxiwashConstants.machineStates.HS] = 'alert-octagram-outline';
88
-        stateIcons[ProxiwashConstants.machineStates.ERREUR] = 'alert';
89
-
90
-        // let dataString = AsyncStorageManager.getInstance().preferences.proxiwashWatchedMachines.current;
91
-        this.onAboutPress = this.onAboutPress.bind(this);
92
-        this.getRenderItem = this.getRenderItem.bind(this);
93
-        this.getRenderSectionHeader = this.getRenderSectionHeader.bind(this);
94
-        this.createDataset = this.createDataset.bind(this);
95
-        this.onHideBanner = this.onHideBanner.bind(this);
96
-        this.onModalRef = this.onModalRef.bind(this);
97
-        this.colors = props.theme.colors;
98 65
     }
99 66
 
100 67
     /**
101 68
      * Callback used when closing the banner.
102 69
      * This hides the banner and saves to preferences to prevent it from reopening
103 70
      */
104
-    onHideBanner() {
71
+    onHideBanner = () => {
105 72
         this.setState({bannerVisible: false});
106 73
         AsyncStorageManager.getInstance().savePref(
107 74
             AsyncStorageManager.getInstance().preferences.proxiwashShowBanner.key,
108 75
             '0'
109 76
         );
110
-    }
77
+    };
111 78
 
112 79
     /**
113 80
      * Setup notification channel for android and add listeners to detect notifications fired
114 81
      */
115 82
     componentDidMount() {
116
-        const rightButton = this.getAboutButton.bind(this);
117 83
         this.props.navigation.setOptions({
118
-            headerRight: rightButton,
84
+            headerRight: this.getAboutButton,
119 85
         });
120 86
         if (AsyncStorageManager.getInstance().preferences.expoToken.current !== '') {
121 87
             // Get latest watchlist from server
@@ -142,20 +108,17 @@ class ProxiwashScreen extends React.Component<Props, State> {
142 108
      * Callback used when pressing the about button.
143 109
      * This will open the ProxiwashAboutScreen.
144 110
      */
145
-    onAboutPress() {
146
-        this.props.navigation.navigate('proxiwash-about');
147
-    }
111
+    onAboutPress = () => this.props.navigation.navigate('proxiwash-about');
148 112
 
149 113
     /**
150 114
      * Gets the about header button
151 115
      *
152 116
      * @return {*}
153 117
      */
154
-    getAboutButton() {
155
-        return <MaterialHeaderButtons>
118
+    getAboutButton = () =>
119
+        <MaterialHeaderButtons>
156 120
             <Item title="information" iconName="information" onPress={this.onAboutPress}/>
157 121
         </MaterialHeaderButtons>;
158
-    }
159 122
 
160 123
     /**
161 124
      * Extracts the key for the given item
@@ -261,7 +224,7 @@ class ProxiwashScreen extends React.Component<Props, State> {
261 224
      * @param fetchedData
262 225
      * @return {*}
263 226
      */
264
-    createDataset(fetchedData: Object) {
227
+    createDataset = (fetchedData: Object) => {
265 228
         let data = fetchedData;
266 229
         if (AprilFoolsManager.getInstance().isAprilFoolsEnabled()) {
267 230
             data = JSON.parse(JSON.stringify(fetchedData)); // Deep copy
@@ -284,7 +247,7 @@ class ProxiwashScreen extends React.Component<Props, State> {
284 247
                 keyExtractor: this.getKeyExtractor
285 248
             },
286 249
         ];
287
-    }
250
+    };
288 251
 
289 252
     /**
290 253
      * Shows a modal for the given item
@@ -293,14 +256,14 @@ class ProxiwashScreen extends React.Component<Props, State> {
293 256
      * @param item The item to display information for in the modal
294 257
      * @param isDryer True if the given item is a dryer
295 258
      */
296
-    showModal(title: string, item: Object, isDryer: boolean) {
259
+    showModal = (title: string, item: Object, isDryer: boolean) => {
297 260
         this.setState({
298 261
             modalCurrentDisplayItem: this.getModalContent(title, item, isDryer)
299 262
         });
300 263
         if (this.modalRef) {
301 264
             this.modalRef.open();
302 265
         }
303
-    }
266
+    };
304 267
 
305 268
     /**
306 269
      * Callback used when the user clicks on enable notifications for a machine
@@ -362,7 +325,7 @@ class ProxiwashScreen extends React.Component<Props, State> {
362 325
                     title={title}
363 326
                     left={() => <Avatar.Icon
364 327
                         icon={isDryer ? 'tumble-dryer' : 'washing-machine'}
365
-                        color={this.colors.text}
328
+                        color={this.props.theme.colors.text}
366 329
                         style={{backgroundColor: 'transparent'}}/>}
367 330
 
368 331
                 />
@@ -390,9 +353,9 @@ class ProxiwashScreen extends React.Component<Props, State> {
390 353
      *
391 354
      * @param ref
392 355
      */
393
-    onModalRef(ref: Object) {
356
+    onModalRef = (ref: Object) => {
394 357
         this.modalRef = ref;
395
-    }
358
+    };
396 359
 
397 360
     /**
398 361
      * Gets the number of machines available
@@ -420,43 +383,16 @@ class ProxiwashScreen extends React.Component<Props, State> {
420 383
      * @param section The section to render
421 384
      * @return {*}
422 385
      */
423
-    getRenderSectionHeader({section}: Object) {
386
+    getRenderSectionHeader = ({section}: Object) => {
424 387
         const isDryer = section.title === i18n.t('proxiwashScreen.dryers');
425 388
         const nbAvailable = this.getMachineAvailableNumber(isDryer);
426
-        const subtitle = nbAvailable + ' ' + ((nbAvailable <= 1) ? i18n.t('proxiwashScreen.numAvailable')
427
-            : i18n.t('proxiwashScreen.numAvailablePlural'));
428 389
         return (
429
-            <View style={{
430
-                flexDirection: 'row',
431
-                marginLeft: 5,
432
-                marginRight: 5,
433
-                marginBottom: 10,
434
-                marginTop: 20,
435
-            }}>
436
-                <Avatar.Icon
437
-                    icon={isDryer ? 'tumble-dryer' : 'washing-machine'}
438
-                    color={this.colors.primary}
439
-                    style={{backgroundColor: 'transparent'}}
440
-                />
441
-                <View style={{
442
-                    justifyContent: 'center',
443
-                }}>
444
-                    <Text style={{
445
-                        fontSize: 20,
446
-                        fontWeight: 'bold',
447
-                    }}>
448
-                        {section.title}
449
-                    </Text>
450
-
451
-                    <Text style={{
452
-                        color: this.colors.subtitle,
453
-                    }}>
454
-                        {subtitle}
455
-                    </Text>
456
-                </View>
457
-            </View>
390
+            <ProxiwashSectionHeader
391
+                title={section.title}
392
+                nbAvailable={nbAvailable}
393
+                isDryer={isDryer}/>
458 394
         );
459
-    }
395
+    };
460 396
 
461 397
     /**
462 398
      * Gets the list item to be rendered
@@ -465,34 +401,18 @@ class ProxiwashScreen extends React.Component<Props, State> {
465 401
      * @param section The object describing the current SectionList section
466 402
      * @returns {React.Node}
467 403
      */
468
-    getRenderItem({item, section}: Object) {
469
-        const isMachineRunning = ProxiwashConstants.machineStates[item.state] === ProxiwashConstants.machineStates["EN COURS"];
470
-        let displayNumber = item.number;
471
-        if (AprilFoolsManager.getInstance().isAprilFoolsEnabled())
472
-            displayNumber = AprilFoolsManager.getProxiwashMachineDisplayNumber(parseInt(item.number));
473
-        const machineName = (section.title === i18n.t('proxiwashScreen.dryers') ?
474
-            i18n.t('proxiwashScreen.dryer') :
475
-            i18n.t('proxiwashScreen.washer')) + ' n°' + displayNumber;
404
+    getRenderItem = ({item, section}: Object) => {
476 405
         const isDryer = section.title === i18n.t('proxiwashScreen.dryers');
477
-        const onPress = this.showModal.bind(this, machineName, item, isDryer);
478
-        let width = item.donePercent !== '' ? (parseInt(item.donePercent)).toString() + '%' : 0;
479
-        if (ProxiwashConstants.machineStates[item.state] === '0')
480
-            width = '100%';
481 406
         return (
482 407
             <ProxiwashListItem
483
-                title={machineName}
484
-                description={isMachineRunning ? item.startTime + '/' + item.endTime : ''}
485
-                onPress={onPress}
486
-                progress={width}
487
-                state={item.state}
408
+                item={item}
409
+                onPress={this.showModal}
488 410
                 isWatched={this.isMachineWatched(item.number)}
489 411
                 isDryer={isDryer}
490
-                statusText={stateStrings[ProxiwashConstants.machineStates[item.state]]}
491
-                statusIcon={stateIcons[ProxiwashConstants.machineStates[item.state]]}
492 412
                 height={LIST_ITEM_HEIGHT}
493 413
             />
494 414
         );
495
-    }
415
+    };
496 416
 
497 417
     render() {
498 418
         const nav = this.props.navigation;

+ 0
- 1
src/screens/Websites/AmicaleWebsiteScreen.js View File

@@ -19,7 +19,6 @@ export const AmicaleWebsiteScreen = (props: Object) => {
19 19
             props.navigation.dispatch(CommonActions.setParams({path: null}));
20 20
         }
21 21
     }
22
-    console.log(path);
23 22
     return (
24 23
         <WebViewScreen
25 24
             {...props}

+ 1
- 3
src/utils/Notifications.js View File

@@ -38,9 +38,7 @@ export async function initExpoToken() {
38 38
             let expoToken = await Notifications.getExpoPushTokenAsync();
39 39
             // Save token for instant use later on
40 40
             AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken);
41
-        } catch (e) {
42
-            console.log(e);
43
-        }
41
+        } catch (e) {}
44 42
     }
45 43
 }
46 44
 

Loading…
Cancel
Save