@momo-kits/step 0.0.43-beta.27 → 0.0.43-beta.28
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.
- package/Step.horizontal.js +280 -112
- package/Step.horizontal.web.js +280 -112
- package/Step.js +21 -3
- package/Step.vertical.js +261 -111
- package/Step.vertical.web.js +261 -111
- package/Step.web.js +22 -3
- package/package.json +1 -1
package/Step.horizontal.js
CHANGED
|
@@ -14,13 +14,12 @@ const styles = StyleSheet.create({
|
|
|
14
14
|
borderWidth: 2,
|
|
15
15
|
padding: 4,
|
|
16
16
|
},
|
|
17
|
-
|
|
18
|
-
width:
|
|
19
|
-
height:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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
|
|
81
|
-
<
|
|
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
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
{
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
{
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
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,
|