@momo-kits/step 0.0.43-beta.27 → 0.0.43-beta.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,13 +14,12 @@ const styles = StyleSheet.create({
14
14
  borderWidth: 2,
15
15
  padding: 4,
16
16
  },
17
- checkedCircle: {
18
- width: CIRCLE_SIZE,
19
- height: CIRCLE_SIZE,
20
- borderRadius: CIRCLE_SIZE / 2,
21
- backgroundColor: '#ffadd2',
22
- borderWidth: 2,
23
- borderColor: Colors.pink_09,
17
+ iconImage: {
18
+ width: 16,
19
+ height: 16,
20
+ position: 'absolute',
21
+ top: 2,
22
+ left: 2,
24
23
  },
25
24
  titleDefault: {
26
25
  fontSize: 14,
@@ -75,12 +74,195 @@ export default class HorizontalStep extends Component {
75
74
  });
76
75
  };
77
76
 
78
- circleStep = (index) => {
77
+ _renderCircleImage = ({
78
+ icon = '',
79
+ circleColor = '',
80
+ circleBorderColor = '',
81
+ }) => {
82
+ return (
83
+ <View>
84
+ <View
85
+ style={[
86
+ styles.circle,
87
+ {
88
+ backgroundColor: circleColor,
89
+ borderColor: circleBorderColor,
90
+ },
91
+ ]}>
92
+ <Image
93
+ source={icon}
94
+ style={[styles.iconImage, { tintColor: '#ffffff' }]}
95
+ />
96
+ </View>
97
+ </View>
98
+ );
99
+ };
100
+
101
+ _renderCircleText = ({
102
+ circleColor = '',
103
+ circleBorderColor = '',
104
+ index = 0,
105
+ }) => {
79
106
  return (
80
- <View style={[styles.circle]}>
81
- <Text style={styles.number}>{index}</Text>
107
+ <View>
108
+ <View
109
+ style={[
110
+ styles.circle,
111
+ {
112
+ backgroundColor: circleColor,
113
+ borderColor: circleBorderColor,
114
+ },
115
+ ]}>
116
+ <Text style={styles.number}>{index + 1}</Text>
117
+ </View>
118
+ </View>
119
+ );
120
+ };
121
+
122
+ _renderDateOrValue = ({
123
+ date = '',
124
+ isActiveState = false,
125
+ circleChecked = false,
126
+ minHeight = 0,
127
+ dateStyle = {},
128
+ index = 0,
129
+ }) => {
130
+ // Init states in render function
131
+ let resultComponent = <></>;
132
+ if (!date) {
133
+ return resultComponent;
134
+ }
135
+ if (isActiveState || circleChecked) {
136
+ resultComponent = (
137
+ <Text
138
+ style={[
139
+ styles.date,
140
+ dateStyle,
141
+ { minHeight: 12, marginBottom: 4 },
142
+ ]}>
143
+ {date[index]}
144
+ </Text>
145
+ );
146
+ } else {
147
+ resultComponent = <View style={minHeight}></View>;
148
+ }
149
+ return resultComponent;
150
+ };
151
+
152
+ _renderCircle = ({
153
+ circleColor = '',
154
+ circleBorderColor = '',
155
+ isActiveState = false,
156
+ circleUnchecked = false,
157
+ iconActive = {},
158
+ iconUnchecked = {},
159
+ icon = {},
160
+ index = 0,
161
+ }) => {
162
+ let resultComponent = <></>;
163
+ if (!isActiveState) {
164
+ if (circleUnchecked) {
165
+ if (Object.keys(iconUnchecked).length === 0) {
166
+ resultComponent = this._renderCircleImage({
167
+ icon,
168
+ circleColor,
169
+ circleBorderColor,
170
+ });
171
+ } else {
172
+ resultComponent = this._renderCircleText({
173
+ circleColor,
174
+ circleBorderColor,
175
+ index,
176
+ });
177
+ }
178
+ } else {
179
+ resultComponent = this._renderCircleImage({
180
+ icon,
181
+ circleColor,
182
+ circleBorderColor,
183
+ });
184
+ }
185
+ } else {
186
+ // This is active case
187
+ // If icon diff "" & regex http or https url so will render image component
188
+ if (Object.keys(iconActive).length === 0) {
189
+ resultComponent = this._renderCircleImage({
190
+ icon,
191
+ circleColor,
192
+ circleBorderColor,
193
+ });
194
+ } else {
195
+ // Otherwise render index number in text component
196
+ resultComponent = resultComponent = this._renderCircleText({
197
+ circleColor,
198
+ circleBorderColor,
199
+ index,
200
+ });
201
+ }
202
+ }
203
+ return resultComponent;
204
+ };
205
+
206
+ _renderTitle = ({ textFontStyle = {}, titleStyle = {}, value = {} }) => {
207
+ let resultComponent = (
208
+ <View>
209
+ <Text.Caption
210
+ style={[{ marginTop: 4 }, textFontStyle, titleStyle]}>
211
+ {value}
212
+ </Text.Caption>
82
213
  </View>
83
214
  );
215
+ return resultComponent;
216
+ };
217
+
218
+ _renderDescription = ({ items = {}, descriptionStyle = {}, index = 0 }) => {
219
+ let resultComponent = <></>;
220
+
221
+ if (items) {
222
+ resultComponent = (
223
+ <View>
224
+ <Text style={[{ fontSize: 10 }, descriptionStyle]}>
225
+ {items[index]}
226
+ </Text>
227
+ </View>
228
+ );
229
+ }
230
+ return resultComponent;
231
+ };
232
+
233
+ _renderLine = ({
234
+ titles = {},
235
+ index = 0,
236
+ lineRight = 0,
237
+ lineWidth = 0,
238
+ lineActive = '',
239
+ date = {},
240
+ }) => {
241
+ let resultComponent = <></>;
242
+
243
+ if (titles?.length - 1 !== index) {
244
+ resultComponent = (
245
+ <View
246
+ style={{
247
+ position: 'absolute',
248
+ right: lineRight,
249
+ width: lineWidth,
250
+ zIndex: -1,
251
+ }}>
252
+ <View
253
+ style={[
254
+ styles.lineHorizontal,
255
+ {
256
+ backgroundColor: lineActive,
257
+ },
258
+ date ? { marginTop: 27 } : { marginTop: 27 - 16 },
259
+ /* subtracting spacing from date */
260
+ ]}
261
+ />
262
+ </View>
263
+ );
264
+ }
265
+ return resultComponent;
84
266
  };
85
267
 
86
268
  circleColumn = (value, index) => {
@@ -88,40 +270,63 @@ export default class HorizontalStep extends Component {
88
270
  currentStep,
89
271
  titles,
90
272
  iconActive,
91
- iconInActive,
273
+ iconChecked,
274
+ iconUnchecked,
275
+ circleColorActive,
276
+ circleColorChecked,
277
+ circleColorUnchecked,
278
+ circleBorderColorActive,
279
+ circleBorderColorChecked,
280
+ circleBorderColorUnchecked,
92
281
  lineColorActive,
93
282
  lineColorInActive,
94
283
  items,
95
- currentStepColor,
96
284
  date,
97
285
  isVertical,
98
286
  titleStyle,
99
287
  descriptionStyle,
100
288
  dateStyle,
101
289
  } = this.props;
102
- const icon =
103
- currentStep >= index + 2
104
- ? iconActive || IconSource.ic_check_24
105
- : iconInActive || index + 1;
106
- var circleColor =
107
- currentStep >= index + 1 ? currentStepColor : Colors.black_06;
108
- var circleBorderColor =
109
- currentStep >= index + 1 ? Colors.pink_09 : Colors.black_04;
110
- const textFontStyle =
111
- currentStep === index + 1
112
- ? styles.titleActive
113
- : styles.titleDefault;
114
- const lineActive =
115
- currentStep >= index + 2
116
- ? lineColorActive
117
- ? Colors.pink_09
118
- : '#ffd6e7'
119
- : lineColorInActive || Colors.black_04;
120
- const minHeight = !isVertical && styles.minHeight;
290
+
291
+ // Three circle states
292
+ const isActiveState = currentStep == index + 1;
293
+ const circleChecked = currentStep > index + 1;
294
+ const circleUnchecked = currentStep < index + 1;
295
+
296
+ // Default properties is inactive state
297
+ let icon = {};
298
+ let circleColor = circleColorUnchecked || Colors.black_06;
299
+ let circleBorderColor = circleBorderColorUnchecked || Colors.black_04;
300
+ let textFontStyle = styles.titleDefault;
301
+ let lineActive = lineColorInActive || Colors.black_04;
302
+ let minHeight = !isVertical && styles.minHeight;
303
+
304
+ let tintColor = '#ffd6e7';
305
+
306
+ // This is all properties in active state
307
+ if (isActiveState) {
308
+ icon = iconActive || index + 1;
309
+ circleColor = circleColorActive || '#d82d8b';
310
+ circleBorderColor = circleBorderColorActive || Colors.pink_09;
311
+ textFontStyle = styles.titleActive;
312
+ }
313
+
314
+ if (circleChecked) {
315
+ icon = iconChecked || IconSource.ic_check_24;
316
+ lineActive = lineColorActive || tintColor;
317
+ circleColor = circleColorChecked || '#ffadd2';
318
+ circleBorderColor = circleBorderColorChecked || Colors.pink_09;
319
+ }
320
+
321
+ if (circleUnchecked) {
322
+ icon = iconUnchecked || index + 1;
323
+ }
324
+
121
325
  const lineWidth = Math.round(
122
326
  (SCREEN_WIDTH - 10 - CIRCLE_SIZE - 4) / titles.length,
123
327
  );
124
328
  const lineRight = parseInt(`-${lineWidth / 2}`);
329
+
125
330
  return (
126
331
  <View
127
332
  key={index}
@@ -135,85 +340,43 @@ export default class HorizontalStep extends Component {
135
340
  flexDirection: 'column',
136
341
  alignItems: 'center',
137
342
  }}>
138
- {date &&
139
- (currentStep >= index + 1 ? (
140
- <Text
141
- style={[
142
- styles.date,
143
- dateStyle,
144
- { minHeight: 12, marginBottom: 4 },
145
- ]}>
146
- {date[index]}
147
- </Text>
148
- ) : (
149
- <View style={minHeight}></View>
150
- ))}
151
- {currentStep <= index + 1 ? (
152
- <View>
153
- {/* image */}
154
- <View
155
- style={[
156
- styles.circle,
157
- {
158
- backgroundColor: circleColor,
159
- borderColor: circleBorderColor,
160
- },
161
- ]}>
162
- <Text style={styles.number}>{icon}</Text>
163
- </View>
164
- </View>
165
- ) : (
166
- <View>
167
- <Image
168
- source={icon}
169
- style={[
170
- styles.checkedCircle,
171
- { tintColor: '#ffd6e7' },
172
- ]}
173
- />
174
- </View>
175
- )}
176
- <View>
177
- <Text.Caption
178
- style={[
179
- { marginTop: 4 },
180
- textFontStyle,
181
- titleStyle,
182
- ]}>
183
- {value}
184
- </Text.Caption>
185
- </View>
186
-
187
- {items && (
188
- <View>
189
- <Text style={[{ fontSize: 10 }, descriptionStyle]}>
190
- {items[index]}
191
- </Text>
192
- </View>
193
- )}
343
+ {this._renderDateOrValue({
344
+ date,
345
+ isActiveState,
346
+ circleChecked,
347
+ minHeight,
348
+ dateStyle,
349
+ index,
350
+ })}
351
+ {this._renderCircle({
352
+ circleColor,
353
+ circleBorderColor,
354
+ isActiveState,
355
+ circleUnchecked,
356
+ iconActive,
357
+ iconUnchecked,
358
+ icon,
359
+ index,
360
+ })}
361
+ {this._renderTitle({
362
+ textFontStyle,
363
+ titleStyle,
364
+ value,
365
+ })}
366
+ {this._renderDescription({
367
+ items,
368
+ descriptionStyle,
369
+ index,
370
+ })}
194
371
  </View>
195
- {titles?.length - 1 !== index && (
196
- <View
197
- style={{
198
- position: 'absolute',
199
- right: lineRight,
200
- width: lineWidth,
201
- zIndex: -1,
202
- }}>
203
- <View
204
- style={[
205
- styles.lineHorizontal,
206
- {
207
- backgroundColor: lineActive,
208
- },
209
- date
210
- ? { marginTop: 27 }
211
- : { marginTop: 27 - 16 },
212
- /* subtracting spacing from date */
213
- ]}
214
- />
215
- </View>
216
- )}
372
+ {this._renderLine({
373
+ titles,
374
+ index,
375
+ lineRight,
376
+ lineWidth,
377
+ lineActive,
378
+ date,
379
+ })}
217
380
  </View>
218
381
  );
219
382
  };
@@ -247,11 +410,16 @@ HorizontalStep.propTypes = {
247
410
  items: PropTypes.array,
248
411
  isVertical: PropTypes.bool,
249
412
  iconActive: PropTypes.any,
250
- iconInActive: PropTypes.any,
413
+ iconChecked: PropTypes.any,
414
+ iconUnchecked: PropTypes.any,
415
+ circleColorActive: PropTypes.string,
416
+ circleColorChecked: PropTypes.string,
417
+ circleColorUnchecked: PropTypes.string,
418
+ circleBorderColorActive: PropTypes.string,
419
+ circleBorderColorChecked: PropTypes.string,
420
+ circleBorderColorUnchecked: PropTypes.string,
251
421
  lineColorActive: PropTypes.string,
252
422
  lineColorInActive: PropTypes.string,
253
- borderColorActive: PropTypes.string,
254
- borderColorInActive: PropTypes.string,
255
423
  titleStyle: PropTypes.object,
256
424
  descriptionStyle: PropTypes.object,
257
425
  dateStyle: PropTypes.object,