@momo-kits/step 0.0.43-beta.25 → 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 +290 -117
- package/Step.horizontal.web.js +298 -121
- package/Step.js +24 -4
- package/Step.vertical.js +268 -112
- package/Step.vertical.web.js +274 -112
- package/Step.web.js +25 -4
- package/package.json +1 -1
package/Step.vertical.js
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import { Colors, IconSource, Image, Text } from '@momo-kits/core';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React, { Component } from 'react';
|
|
4
|
-
import { StyleSheet,
|
|
5
|
-
import { ScrollView } from 'react-native-gesture-handler';
|
|
6
|
-
|
|
4
|
+
import { View, StyleSheet, ScrollView } from 'react-native';
|
|
7
5
|
|
|
8
6
|
const CIRCLE_SIZE = 24;
|
|
9
7
|
|
|
10
|
-
// this is layout of each item (flexdirection row)
|
|
11
|
-
// this is left container (flex 0.2, )
|
|
12
|
-
// this is value label
|
|
13
|
-
// this is image
|
|
14
|
-
// this is caption label
|
|
15
|
-
// this is desc label
|
|
16
|
-
// this is right container (flex 0.8)
|
|
17
|
-
// this is line (width flex = 1 or width 100 percent)
|
|
18
|
-
|
|
19
8
|
const styles = StyleSheet.create({
|
|
20
9
|
circle: {
|
|
21
10
|
width: CIRCLE_SIZE,
|
|
@@ -24,13 +13,12 @@ const styles = StyleSheet.create({
|
|
|
24
13
|
borderWidth: 2,
|
|
25
14
|
padding: 4,
|
|
26
15
|
},
|
|
27
|
-
|
|
28
|
-
width:
|
|
29
|
-
height:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
borderColor: Colors.pink_09,
|
|
16
|
+
iconImage: {
|
|
17
|
+
width: 16,
|
|
18
|
+
height: 16,
|
|
19
|
+
position: 'absolute',
|
|
20
|
+
top: 2,
|
|
21
|
+
left: 2,
|
|
34
22
|
},
|
|
35
23
|
titleDefault: {
|
|
36
24
|
color: Colors.black_12,
|
|
@@ -42,8 +30,15 @@ const styles = StyleSheet.create({
|
|
|
42
30
|
fontSize: 14,
|
|
43
31
|
fontWeight: 'bold',
|
|
44
32
|
},
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
container: {
|
|
34
|
+
width: '100%',
|
|
35
|
+
paddingRight: 48,
|
|
36
|
+
marginTop: 4,
|
|
37
|
+
},
|
|
38
|
+
titleAndDate: {
|
|
39
|
+
flexDirection: 'row',
|
|
40
|
+
justifyContent: 'space-between',
|
|
41
|
+
alignItems: 'center',
|
|
47
42
|
},
|
|
48
43
|
description: {
|
|
49
44
|
fontSize: 12,
|
|
@@ -92,113 +87,266 @@ export default class VerticalStep extends Component {
|
|
|
92
87
|
});
|
|
93
88
|
};
|
|
94
89
|
|
|
95
|
-
|
|
90
|
+
/* #region render cust */
|
|
91
|
+
_renderCircleImage = ({ icon = '', circleColor, circleBorderColor }) => {
|
|
92
|
+
return (
|
|
93
|
+
<View>
|
|
94
|
+
<View
|
|
95
|
+
style={[
|
|
96
|
+
styles.circle,
|
|
97
|
+
{
|
|
98
|
+
backgroundColor: circleColor,
|
|
99
|
+
borderColor: circleBorderColor,
|
|
100
|
+
},
|
|
101
|
+
]}>
|
|
102
|
+
<Image
|
|
103
|
+
source={icon}
|
|
104
|
+
style={[styles.iconImage, { tintColor: '#ffffff' }]}
|
|
105
|
+
/>
|
|
106
|
+
</View>
|
|
107
|
+
</View>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
_renderCircleText = ({
|
|
112
|
+
circleColor = '',
|
|
113
|
+
circleBorderColor = '',
|
|
114
|
+
index = 0,
|
|
115
|
+
}) => {
|
|
96
116
|
return (
|
|
97
|
-
<View
|
|
98
|
-
<
|
|
117
|
+
<View>
|
|
118
|
+
<View
|
|
119
|
+
style={[
|
|
120
|
+
styles.circle,
|
|
121
|
+
{
|
|
122
|
+
backgroundColor: circleColor,
|
|
123
|
+
borderColor: circleBorderColor,
|
|
124
|
+
},
|
|
125
|
+
]}>
|
|
126
|
+
<Text style={styles.number}>{index + 1}</Text>
|
|
127
|
+
</View>
|
|
128
|
+
</View>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
_renderCircle = ({
|
|
133
|
+
circleColor = '',
|
|
134
|
+
circleBorderColor = '',
|
|
135
|
+
isActiveState = false,
|
|
136
|
+
circleUnchecked = false,
|
|
137
|
+
iconActive,
|
|
138
|
+
iconUnchecked,
|
|
139
|
+
icon = {},
|
|
140
|
+
index = 0,
|
|
141
|
+
}) => {
|
|
142
|
+
let resultComponent = <></>;
|
|
143
|
+
if (!isActiveState) {
|
|
144
|
+
if (circleUnchecked) {
|
|
145
|
+
if (Object.keys(iconUnchecked).length === 0) {
|
|
146
|
+
resultComponent = this._renderCircleImage({
|
|
147
|
+
icon,
|
|
148
|
+
circleColor,
|
|
149
|
+
circleBorderColor,
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
resultComponent = this._renderCircleText({
|
|
153
|
+
circleColor,
|
|
154
|
+
circleBorderColor,
|
|
155
|
+
index,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
resultComponent = this._renderCircleImage({
|
|
160
|
+
icon,
|
|
161
|
+
circleColor,
|
|
162
|
+
circleBorderColor,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
// This is active case
|
|
167
|
+
// If icon diff "" & regex http or https url so will render image component
|
|
168
|
+
if (Object.keys(iconActive).length === 0) {
|
|
169
|
+
resultComponent = this._renderCircleImage({
|
|
170
|
+
icon,
|
|
171
|
+
circleColor,
|
|
172
|
+
circleBorderColor,
|
|
173
|
+
});
|
|
174
|
+
} else {
|
|
175
|
+
// Otherwise render index number in text component
|
|
176
|
+
resultComponent = resultComponent = this._renderCircleText({
|
|
177
|
+
circleColor,
|
|
178
|
+
circleBorderColor,
|
|
179
|
+
index,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return resultComponent;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
_renderLine = ({ titles = {}, index = 0, lineActive = '' }) => {
|
|
187
|
+
let resultComponent = <></>;
|
|
188
|
+
|
|
189
|
+
if (titles?.length - 1 !== index) {
|
|
190
|
+
resultComponent = (
|
|
191
|
+
<View
|
|
192
|
+
style={[
|
|
193
|
+
styles.lineVertical,
|
|
194
|
+
{
|
|
195
|
+
backgroundColor: lineActive,
|
|
196
|
+
},
|
|
197
|
+
]}
|
|
198
|
+
/>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
return resultComponent;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
_renderTitle = ({ textFontStyle = {}, titleStyle = {}, value = {} }) => {
|
|
205
|
+
let resultComponent = (
|
|
206
|
+
<View>
|
|
207
|
+
<Text.Caption
|
|
208
|
+
style={[{ marginLeft: 10 }, textFontStyle, titleStyle]}>
|
|
209
|
+
{value}
|
|
210
|
+
</Text.Caption>
|
|
99
211
|
</View>
|
|
100
212
|
);
|
|
213
|
+
return resultComponent;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
_renderDateOrValue = ({
|
|
217
|
+
date = '',
|
|
218
|
+
isActiveState = false,
|
|
219
|
+
circleChecked = false,
|
|
220
|
+
dateStyle = {},
|
|
221
|
+
index = 0,
|
|
222
|
+
}) => {
|
|
223
|
+
// Init states in render function
|
|
224
|
+
let resultComponent = <></>;
|
|
225
|
+
if (!date) {
|
|
226
|
+
return resultComponent;
|
|
227
|
+
}
|
|
228
|
+
if (isActiveState || circleChecked) {
|
|
229
|
+
resultComponent = (
|
|
230
|
+
<Text style={[styles.date, dateStyle]}>{date[index]}</Text>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
return resultComponent;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
_renderDescription = ({ items = {}, descriptionStyle = {}, index = 0 }) => {
|
|
237
|
+
let resultComponent = <></>;
|
|
238
|
+
|
|
239
|
+
if (items) {
|
|
240
|
+
resultComponent = (
|
|
241
|
+
<View>
|
|
242
|
+
{typeof items[index] == 'string' ? (
|
|
243
|
+
<Text style={[styles.description, descriptionStyle]}>
|
|
244
|
+
{items[index]}
|
|
245
|
+
</Text>
|
|
246
|
+
) : (
|
|
247
|
+
<View style={[styles.description]}>{items[index]}</View>
|
|
248
|
+
)}
|
|
249
|
+
</View>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
return resultComponent;
|
|
101
253
|
};
|
|
254
|
+
/* #endregion */
|
|
102
255
|
|
|
103
256
|
circleColumn = (value, index) => {
|
|
104
257
|
const {
|
|
105
258
|
currentStep,
|
|
106
259
|
titles,
|
|
107
|
-
lineStyle,
|
|
108
260
|
iconActive,
|
|
109
|
-
|
|
261
|
+
iconChecked,
|
|
262
|
+
iconUnchecked,
|
|
263
|
+
circleColorActive,
|
|
264
|
+
circleColorChecked,
|
|
265
|
+
circleColorUnchecked,
|
|
266
|
+
circleBorderColorActive,
|
|
267
|
+
circleBorderColorChecked,
|
|
268
|
+
circleBorderColorUnchecked,
|
|
110
269
|
lineColorActive,
|
|
111
270
|
lineColorInActive,
|
|
112
271
|
items,
|
|
113
|
-
currentStepColor,
|
|
114
272
|
date,
|
|
115
|
-
|
|
273
|
+
titleStyle,
|
|
274
|
+
descriptionStyle,
|
|
275
|
+
dateStyle,
|
|
116
276
|
} = this.props;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
277
|
+
|
|
278
|
+
// Three circle states
|
|
279
|
+
const isActiveState = currentStep == index + 1;
|
|
280
|
+
const circleChecked = currentStep > index + 1;
|
|
281
|
+
const circleUnchecked = currentStep < index + 1;
|
|
282
|
+
|
|
283
|
+
// Default properties is inactive state
|
|
284
|
+
let icon = {};
|
|
285
|
+
let circleColor = circleColorUnchecked || Colors.black_06;
|
|
286
|
+
let circleBorderColor = circleBorderColorUnchecked || Colors.black_04;
|
|
287
|
+
let textFontStyle = styles.titleDefault;
|
|
288
|
+
let lineActive = lineColorInActive || Colors.black_04;
|
|
289
|
+
|
|
290
|
+
let tintColor = '#ffd6e7';
|
|
291
|
+
|
|
292
|
+
// This is all properties in active state
|
|
293
|
+
if (isActiveState) {
|
|
294
|
+
icon = iconActive || index + 1;
|
|
295
|
+
circleColor = circleColorActive || '#d82d8b';
|
|
296
|
+
circleBorderColor = circleBorderColorActive || Colors.pink_09;
|
|
297
|
+
textFontStyle = styles.titleActive;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (circleChecked) {
|
|
301
|
+
icon = iconChecked || IconSource.ic_check_24;
|
|
302
|
+
lineActive = lineColorActive || tintColor;
|
|
303
|
+
circleColor = circleColorChecked || '#ffadd2';
|
|
304
|
+
circleBorderColor = circleBorderColorChecked || Colors.pink_09;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (circleUnchecked) {
|
|
308
|
+
icon = iconUnchecked || index + 1;
|
|
309
|
+
}
|
|
310
|
+
|
|
135
311
|
return (
|
|
136
312
|
<View key={index} style={{ flexDirection: 'row' }}>
|
|
137
313
|
<View>
|
|
138
|
-
{
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
)
|
|
153
|
-
<View>
|
|
154
|
-
<Image
|
|
155
|
-
source={icon}
|
|
156
|
-
style={[
|
|
157
|
-
styles.checkedCircle,
|
|
158
|
-
{ tintColor: '#ffd6e7' },
|
|
159
|
-
]}
|
|
160
|
-
/>
|
|
161
|
-
</View>
|
|
162
|
-
)}
|
|
163
|
-
{titles?.length - 1 !== index && (
|
|
164
|
-
<View
|
|
165
|
-
style={[
|
|
166
|
-
styles.lineVertical,
|
|
167
|
-
{
|
|
168
|
-
backgroundColor: lineActive,
|
|
169
|
-
},
|
|
170
|
-
lineStyle,
|
|
171
|
-
]}
|
|
172
|
-
/>
|
|
173
|
-
)}
|
|
314
|
+
{this._renderCircle({
|
|
315
|
+
circleColor,
|
|
316
|
+
circleBorderColor,
|
|
317
|
+
isActiveState,
|
|
318
|
+
circleUnchecked,
|
|
319
|
+
iconActive,
|
|
320
|
+
iconUnchecked,
|
|
321
|
+
icon,
|
|
322
|
+
index,
|
|
323
|
+
})}
|
|
324
|
+
{this._renderLine({
|
|
325
|
+
titles,
|
|
326
|
+
index,
|
|
327
|
+
lineActive,
|
|
328
|
+
})}
|
|
174
329
|
</View>
|
|
175
|
-
<View
|
|
176
|
-
style={
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
)}
|
|
190
|
-
</View>
|
|
191
|
-
<View>
|
|
192
|
-
{typeof items[index] == 'string' ? (
|
|
193
|
-
<Text style={[styles.description]}>
|
|
194
|
-
{items[index]}
|
|
195
|
-
</Text>
|
|
196
|
-
) : (
|
|
197
|
-
<View style={[styles.description]}>
|
|
198
|
-
{items[index]}
|
|
199
|
-
</View>
|
|
200
|
-
)}
|
|
330
|
+
<View style={styles.container}>
|
|
331
|
+
<View style={styles.titleAndDate}>
|
|
332
|
+
{this._renderTitle({
|
|
333
|
+
textFontStyle,
|
|
334
|
+
titleStyle,
|
|
335
|
+
value,
|
|
336
|
+
})}
|
|
337
|
+
{this._renderDateOrValue({
|
|
338
|
+
date,
|
|
339
|
+
isActiveState,
|
|
340
|
+
circleChecked,
|
|
341
|
+
dateStyle,
|
|
342
|
+
index,
|
|
343
|
+
})}
|
|
201
344
|
</View>
|
|
345
|
+
{this._renderDescription({
|
|
346
|
+
items,
|
|
347
|
+
descriptionStyle,
|
|
348
|
+
index,
|
|
349
|
+
})}
|
|
202
350
|
</View>
|
|
203
351
|
</View>
|
|
204
352
|
);
|
|
@@ -212,7 +360,7 @@ export default class VerticalStep extends Component {
|
|
|
212
360
|
render() {
|
|
213
361
|
return (
|
|
214
362
|
<ScrollView>
|
|
215
|
-
<View
|
|
363
|
+
<View onLayout={this.onLayout}>
|
|
216
364
|
<View style={[styles.circleColumn]}>
|
|
217
365
|
{this.renderCircle()}
|
|
218
366
|
</View>
|
|
@@ -229,11 +377,19 @@ VerticalStep.propTypes = {
|
|
|
229
377
|
items: PropTypes.array,
|
|
230
378
|
isVertical: PropTypes.bool,
|
|
231
379
|
iconActive: PropTypes.any,
|
|
232
|
-
|
|
380
|
+
iconChecked: PropTypes.any,
|
|
381
|
+
iconUnchecked: PropTypes.any,
|
|
382
|
+
circleColorActive: PropTypes.string,
|
|
383
|
+
circleColorChecked: PropTypes.string,
|
|
384
|
+
circleColorUnchecked: PropTypes.string,
|
|
385
|
+
circleBorderColorActive: PropTypes.string,
|
|
386
|
+
circleBorderColorChecked: PropTypes.string,
|
|
387
|
+
circleBorderColorUnchecked: PropTypes.string,
|
|
233
388
|
lineColorActive: PropTypes.string,
|
|
234
389
|
lineColorInActive: PropTypes.string,
|
|
235
|
-
|
|
236
|
-
|
|
390
|
+
titleStyle: PropTypes.object,
|
|
391
|
+
descriptionStyle: PropTypes.object,
|
|
392
|
+
dateStyle: PropTypes.object,
|
|
237
393
|
};
|
|
238
394
|
|
|
239
395
|
VerticalStep.defaultProps = {
|