Browse Source

Fix errors induced by refactoring

Arnaud Vergnet 1 year ago
parent
commit
c5287611c4

+ 1
- 1
src/components/Animations/AnimatedAccordion.tsx View File

@@ -27,7 +27,7 @@ type PropsType = {
27 27
   theme: ReactNativePaper.Theme;
28 28
   title: string;
29 29
   subtitle?: string;
30
-  style: ViewStyle;
30
+  style?: ViewStyle;
31 31
   left?: (props: {
32 32
     color: string;
33 33
     style?: {

+ 4
- 3
src/components/Lists/PlanexGroups/GroupListItem.tsx View File

@@ -22,6 +22,7 @@ import {List, TouchableRipple, withTheme} from 'react-native-paper';
22 22
 import * as Animatable from 'react-native-animatable';
23 23
 import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
24 24
 import type {PlanexGroupType} from '../../../screens/Planex/GroupSelectionScreen';
25
+import {View} from 'react-native';
25 26
 
26 27
 type PropsType = {
27 28
   theme: ReactNativePaper.Theme;
@@ -37,11 +38,11 @@ const REPLACE_REGEX = /_/g;
37 38
 class GroupListItem extends React.Component<PropsType> {
38 39
   isFav: boolean;
39 40
 
40
-  starRef: {current: null | Animatable.View};
41
+  starRef: {current: null | (Animatable.View & View)};
41 42
 
42 43
   constructor(props: PropsType) {
43 44
     super(props);
44
-    this.starRef = React.createRef<Animatable.View>();
45
+    this.starRef = React.createRef();
45 46
     this.isFav = this.isGroupInFavorites(props.favorites);
46 47
   }
47 48
 
@@ -60,7 +61,7 @@ class GroupListItem extends React.Component<PropsType> {
60 61
   onStarPress = () => {
61 62
     const {props} = this;
62 63
     const ref = this.starRef;
63
-    if (ref.current) {
64
+    if (ref.current && ref.current.rubberBand && ref.current.swing) {
64 65
       if (this.isFav) {
65 66
         ref.current.rubberBand();
66 67
       } else {

+ 28
- 49
src/components/Lists/Proxiwash/ProxiwashListItem.tsx View File

@@ -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>

+ 1
- 0
src/screens/Amicale/Clubs/ClubListScreen.tsx View File

@@ -115,6 +115,7 @@ class ClubListScreen extends React.Component<PropsType, StateType> {
115 115
    */
116 116
   getSearchBar = () => {
117 117
     return (
118
+      // @ts-ignore
118 119
       <Searchbar
119 120
         placeholder={i18n.t('screens.proximo.search')}
120 121
         onChangeText={this.onSearchStringChange}

Loading…
Cancel
Save