Browse Source

Fix errors induced by refactoring

Arnaud Vergnet 3 years ago
parent
commit
c5287611c4

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

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

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

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

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

30
 import {StyleSheet, View} from 'react-native';
30
 import {StyleSheet, View} from 'react-native';
31
 import i18n from 'i18n-js';
31
 import i18n from 'i18n-js';
32
 import * as Animatable from 'react-native-animatable';
32
 import * as Animatable from 'react-native-animatable';
33
-import ProxiwashConstants from '../../../constants/ProxiwashConstants';
33
+import ProxiwashConstants, {
34
+  MachineStates,
35
+} from '../../../constants/ProxiwashConstants';
34
 import AprilFoolsManager from '../../../managers/AprilFoolsManager';
36
 import AprilFoolsManager from '../../../managers/AprilFoolsManager';
35
 import type {ProxiwashMachineType} from '../../../screens/Proxiwash/ProxiwashScreen';
37
 import type {ProxiwashMachineType} from '../../../screens/Proxiwash/ProxiwashScreen';
36
 
38
 
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
  * Component used to display a proxiwash item, showing machine progression and state
83
  * Component used to display a proxiwash item, showing machine progression and state
70
  */
84
  */
71
 class ProxiwashListItem extends React.Component<PropsType> {
85
 class ProxiwashListItem extends React.Component<PropsType> {
72
   stateColors: {[key: string]: string};
86
   stateColors: {[key: string]: string};
73
 
87
 
74
-  stateStrings: {[key: string]: string};
75
-
76
   title: string;
88
   title: string;
77
 
89
 
78
   titlePopUp: string;
90
   titlePopUp: string;
80
   constructor(props: PropsType) {
92
   constructor(props: PropsType) {
81
     super(props);
93
     super(props);
82
     this.stateColors = {};
94
     this.stateColors = {};
83
-    this.stateStrings = {};
84
-
85
-    this.updateStateStrings();
86
 
95
 
87
     let displayNumber = props.item.number;
96
     let displayNumber = props.item.number;
88
     const displayMaxWeight = props.item.maxWeight;
97
     const displayMaxWeight = props.item.maxWeight;
114
     props.onPress(this.titlePopUp, props.item, props.isDryer);
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
   updateStateColors() {
126
   updateStateColors() {
142
     const {props} = this;
127
     const {props} = this;
143
     const {colors} = props.theme;
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
       colors.proxiwashRunningNotStartedColor;
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
   render() {
139
   render() {
161
     const {props} = this;
140
     const {props} = this;
162
     const {colors} = props.theme;
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
     const description = isRunning
145
     const description = isRunning
167
       ? `${props.item.startTime}/${props.item.endTime}`
146
       ? `${props.item.startTime}/${props.item.endTime}`
168
       : '';
147
       : '';
169
     const stateIcon = ProxiwashConstants.stateIcons[machineState];
148
     const stateIcon = ProxiwashConstants.stateIcons[machineState];
170
-    const stateString = this.stateStrings[machineState];
149
+    const stateString = stateStrings[machineState];
171
     let progress;
150
     let progress;
172
     if (isRunning && props.item.donePercent !== '') {
151
     if (isRunning && props.item.donePercent !== '') {
173
       progress = parseFloat(props.item.donePercent) / 100;
152
       progress = parseFloat(props.item.donePercent) / 100;
231
               <View style={{justifyContent: 'center'}}>
210
               <View style={{justifyContent: 'center'}}>
232
                 <Text
211
                 <Text
233
                   style={
212
                   style={
234
-                    machineState === ProxiwashConstants.machineStates.FINISHED
213
+                    machineState === MachineStates.FINISHED
235
                       ? {fontWeight: 'bold'}
214
                       ? {fontWeight: 'bold'}
236
                       : {}
215
                       : {}
237
                   }>
216
                   }>
238
                   {stateString}
217
                   {stateString}
239
                 </Text>
218
                 </Text>
240
-                {machineState === ProxiwashConstants.machineStates.RUNNING ? (
219
+                {machineState === MachineStates.RUNNING ? (
241
                   <Caption>{props.item.remainingTime} min</Caption>
220
                   <Caption>{props.item.remainingTime} min</Caption>
242
                 ) : null}
221
                 ) : null}
243
               </View>
222
               </View>

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

115
    */
115
    */
116
   getSearchBar = () => {
116
   getSearchBar = () => {
117
     return (
117
     return (
118
+      // @ts-ignore
118
       <Searchbar
119
       <Searchbar
119
         placeholder={i18n.t('screens.proximo.search')}
120
         placeholder={i18n.t('screens.proximo.search')}
120
         onChangeText={this.onSearchStringChange}
121
         onChangeText={this.onSearchStringChange}

Loading…
Cancel
Save