|
@@ -30,7 +30,9 @@ import {
|
30
|
30
|
import {StyleSheet, View} from 'react-native';
|
31
|
31
|
import i18n from 'i18n-js';
|
32
|
32
|
import * as Animatable from 'react-native-animatable';
|
33
|
|
-import ProxiwashConstants from '../../../constants/ProxiwashConstants';
|
|
33
|
+import ProxiwashConstants, {
|
|
34
|
+ MachineStates,
|
|
35
|
+} from '../../../constants/ProxiwashConstants';
|
34
|
36
|
import AprilFoolsManager from '../../../managers/AprilFoolsManager';
|
35
|
37
|
import type {ProxiwashMachineType} from '../../../screens/Proxiwash/ProxiwashScreen';
|
36
|
38
|
|
|
@@ -65,14 +67,24 @@ const styles = StyleSheet.create({
|
65
|
67
|
},
|
66
|
68
|
});
|
67
|
69
|
|
|
70
|
+const stateStrings: {[key in MachineStates]: string} = {
|
|
71
|
+ [MachineStates.AVAILABLE]: i18n.t('screens.proxiwash.states.ready'),
|
|
72
|
+ [MachineStates.RUNNING]: i18n.t('screens.proxiwash.states.running'),
|
|
73
|
+ [MachineStates.RUNNING_NOT_STARTED]: i18n.t(
|
|
74
|
+ 'screens.proxiwash.states.runningNotStarted',
|
|
75
|
+ ),
|
|
76
|
+ [MachineStates.FINISHED]: i18n.t('screens.proxiwash.states.finished'),
|
|
77
|
+ [MachineStates.UNAVAILABLE]: i18n.t('screens.proxiwash.states.broken'),
|
|
78
|
+ [MachineStates.ERROR]: i18n.t('screens.proxiwash.states.error'),
|
|
79
|
+ [MachineStates.UNKNOWN]: i18n.t('screens.proxiwash.states.unknown'),
|
|
80
|
+};
|
|
81
|
+
|
68
|
82
|
/**
|
69
|
83
|
* Component used to display a proxiwash item, showing machine progression and state
|
70
|
84
|
*/
|
71
|
85
|
class ProxiwashListItem extends React.Component<PropsType> {
|
72
|
86
|
stateColors: {[key: string]: string};
|
73
|
87
|
|
74
|
|
- stateStrings: {[key: string]: string};
|
75
|
|
-
|
76
|
88
|
title: string;
|
77
|
89
|
|
78
|
90
|
titlePopUp: string;
|
|
@@ -80,9 +92,6 @@ class ProxiwashListItem extends React.Component<PropsType> {
|
80
|
92
|
constructor(props: PropsType) {
|
81
|
93
|
super(props);
|
82
|
94
|
this.stateColors = {};
|
83
|
|
- this.stateStrings = {};
|
84
|
|
-
|
85
|
|
- this.updateStateStrings();
|
86
|
95
|
|
87
|
96
|
let displayNumber = props.item.number;
|
88
|
97
|
const displayMaxWeight = props.item.maxWeight;
|
|
@@ -114,60 +123,30 @@ class ProxiwashListItem extends React.Component<PropsType> {
|
114
|
123
|
props.onPress(this.titlePopUp, props.item, props.isDryer);
|
115
|
124
|
};
|
116
|
125
|
|
117
|
|
- updateStateStrings() {
|
118
|
|
- this.stateStrings[ProxiwashConstants.machineStates.AVAILABLE] = i18n.t(
|
119
|
|
- 'screens.proxiwash.states.ready',
|
120
|
|
- );
|
121
|
|
- this.stateStrings[ProxiwashConstants.machineStates.RUNNING] = i18n.t(
|
122
|
|
- 'screens.proxiwash.states.running',
|
123
|
|
- );
|
124
|
|
- this.stateStrings[
|
125
|
|
- ProxiwashConstants.machineStates.RUNNING_NOT_STARTED
|
126
|
|
- ] = i18n.t('screens.proxiwash.states.runningNotStarted');
|
127
|
|
- this.stateStrings[ProxiwashConstants.machineStates.FINISHED] = i18n.t(
|
128
|
|
- 'screens.proxiwash.states.finished',
|
129
|
|
- );
|
130
|
|
- this.stateStrings[ProxiwashConstants.machineStates.UNAVAILABLE] = i18n.t(
|
131
|
|
- 'screens.proxiwash.states.broken',
|
132
|
|
- );
|
133
|
|
- this.stateStrings[ProxiwashConstants.machineStates.ERROR] = i18n.t(
|
134
|
|
- 'screens.proxiwash.states.error',
|
135
|
|
- );
|
136
|
|
- this.stateStrings[ProxiwashConstants.machineStates.UNKNOWN] = i18n.t(
|
137
|
|
- 'screens.proxiwash.states.unknown',
|
138
|
|
- );
|
139
|
|
- }
|
140
|
|
-
|
141
|
126
|
updateStateColors() {
|
142
|
127
|
const {props} = this;
|
143
|
128
|
const {colors} = props.theme;
|
144
|
|
- this.stateColors[ProxiwashConstants.machineStates.AVAILABLE] =
|
145
|
|
- colors.proxiwashReadyColor;
|
146
|
|
- this.stateColors[ProxiwashConstants.machineStates.RUNNING] =
|
147
|
|
- colors.proxiwashRunningColor;
|
148
|
|
- this.stateColors[ProxiwashConstants.machineStates.RUNNING_NOT_STARTED] =
|
|
129
|
+ this.stateColors[MachineStates.AVAILABLE] = colors.proxiwashReadyColor;
|
|
130
|
+ this.stateColors[MachineStates.RUNNING] = colors.proxiwashRunningColor;
|
|
131
|
+ this.stateColors[MachineStates.RUNNING_NOT_STARTED] =
|
149
|
132
|
colors.proxiwashRunningNotStartedColor;
|
150
|
|
- this.stateColors[ProxiwashConstants.machineStates.FINISHED] =
|
151
|
|
- colors.proxiwashFinishedColor;
|
152
|
|
- this.stateColors[ProxiwashConstants.machineStates.UNAVAILABLE] =
|
153
|
|
- colors.proxiwashBrokenColor;
|
154
|
|
- this.stateColors[ProxiwashConstants.machineStates.ERROR] =
|
155
|
|
- colors.proxiwashErrorColor;
|
156
|
|
- this.stateColors[ProxiwashConstants.machineStates.UNKNOWN] =
|
157
|
|
- colors.proxiwashUnknownColor;
|
|
133
|
+ this.stateColors[MachineStates.FINISHED] = colors.proxiwashFinishedColor;
|
|
134
|
+ this.stateColors[MachineStates.UNAVAILABLE] = colors.proxiwashBrokenColor;
|
|
135
|
+ this.stateColors[MachineStates.ERROR] = colors.proxiwashErrorColor;
|
|
136
|
+ this.stateColors[MachineStates.UNKNOWN] = colors.proxiwashUnknownColor;
|
158
|
137
|
}
|
159
|
138
|
|
160
|
139
|
render() {
|
161
|
140
|
const {props} = this;
|
162
|
141
|
const {colors} = props.theme;
|
163
|
|
- const machineState = parseInt(props.item.state, 10);
|
164
|
|
- const isRunning = machineState === ProxiwashConstants.machineStates.RUNNING;
|
165
|
|
- const isReady = machineState === ProxiwashConstants.machineStates.AVAILABLE;
|
|
142
|
+ const machineState = props.item.state;
|
|
143
|
+ const isRunning = machineState === MachineStates.RUNNING;
|
|
144
|
+ const isReady = machineState === MachineStates.AVAILABLE;
|
166
|
145
|
const description = isRunning
|
167
|
146
|
? `${props.item.startTime}/${props.item.endTime}`
|
168
|
147
|
: '';
|
169
|
148
|
const stateIcon = ProxiwashConstants.stateIcons[machineState];
|
170
|
|
- const stateString = this.stateStrings[machineState];
|
|
149
|
+ const stateString = stateStrings[machineState];
|
171
|
150
|
let progress;
|
172
|
151
|
if (isRunning && props.item.donePercent !== '') {
|
173
|
152
|
progress = parseFloat(props.item.donePercent) / 100;
|
|
@@ -231,13 +210,13 @@ class ProxiwashListItem extends React.Component<PropsType> {
|
231
|
210
|
<View style={{justifyContent: 'center'}}>
|
232
|
211
|
<Text
|
233
|
212
|
style={
|
234
|
|
- machineState === ProxiwashConstants.machineStates.FINISHED
|
|
213
|
+ machineState === MachineStates.FINISHED
|
235
|
214
|
? {fontWeight: 'bold'}
|
236
|
215
|
: {}
|
237
|
216
|
}>
|
238
|
217
|
{stateString}
|
239
|
218
|
</Text>
|
240
|
|
- {machineState === ProxiwashConstants.machineStates.RUNNING ? (
|
|
219
|
+ {machineState === MachineStates.RUNNING ? (
|
241
|
220
|
<Caption>{props.item.remainingTime} min</Caption>
|
242
|
221
|
) : null}
|
243
|
222
|
</View>
|