@momo-kits/step 0.0.73-beta → 0.72.1
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 +279 -0
- package/Step.horizontal.web.js +299 -0
- package/Step.js +39 -290
- package/Step.vertical.js +313 -0
- package/Step.vertical.web.js +325 -0
- package/Step.web.js +44 -295
- package/package.json +13 -13
- package/publish.sh +1 -1
package/Step.js
CHANGED
|
@@ -1,303 +1,52 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
-
import { View, StyleSheet } from 'react-native';
|
|
3
|
-
|
|
4
2
|
import PropTypes from 'prop-types';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
} from '@momo-kits/core';
|
|
8
|
-
|
|
9
|
-
const CIRCLE_SIZE = 24;
|
|
10
|
-
|
|
11
|
-
const styles = StyleSheet.create({
|
|
12
|
-
circle: {
|
|
13
|
-
width: CIRCLE_SIZE,
|
|
14
|
-
height: CIRCLE_SIZE,
|
|
15
|
-
// borderWidth: 1,
|
|
16
|
-
// borderColor: Colors.sepia_05,
|
|
17
|
-
borderRadius: CIRCLE_SIZE / 2,
|
|
18
|
-
backgroundColor: 'white'
|
|
19
|
-
},
|
|
20
|
-
line: {
|
|
21
|
-
height: 4,
|
|
22
|
-
backgroundColor: 'white',
|
|
23
|
-
// borderWidth: 1,
|
|
24
|
-
// borderRadius: 1,
|
|
25
|
-
// borderStyle: 'dashed',
|
|
26
|
-
zIndex: 0,
|
|
27
|
-
// marginTop: 8
|
|
28
|
-
},
|
|
29
|
-
topRight: {
|
|
30
|
-
position: 'absolute',
|
|
31
|
-
right: -1,
|
|
32
|
-
top: -1,
|
|
33
|
-
width: 1,
|
|
34
|
-
height: '100%',
|
|
35
|
-
backgroundColor: 'white',
|
|
36
|
-
zIndex: 1
|
|
37
|
-
},
|
|
38
|
-
topLeft: {
|
|
39
|
-
position: 'absolute',
|
|
40
|
-
left: -1,
|
|
41
|
-
top: -1,
|
|
42
|
-
width: '100%',
|
|
43
|
-
height: 1,
|
|
44
|
-
backgroundColor: 'white',
|
|
45
|
-
zIndex: 1
|
|
46
|
-
},
|
|
47
|
-
topLeftWidth: {
|
|
48
|
-
position: 'absolute',
|
|
49
|
-
left: -1,
|
|
50
|
-
top: -1,
|
|
51
|
-
width: 1,
|
|
52
|
-
height: '100%',
|
|
53
|
-
backgroundColor: 'white',
|
|
54
|
-
zIndex: 1
|
|
55
|
-
},
|
|
56
|
-
circleRow: {
|
|
57
|
-
position: 'absolute',
|
|
58
|
-
justifyContent: 'space-between',
|
|
59
|
-
flexDirection: 'row',
|
|
60
|
-
},
|
|
61
|
-
circleColumn: {
|
|
62
|
-
// position: 'absolute',
|
|
63
|
-
justifyContent: 'space-between',
|
|
64
|
-
},
|
|
65
|
-
titleDefault: {
|
|
66
|
-
color: Colors.black_12
|
|
67
|
-
},
|
|
68
|
-
titleActive: {
|
|
69
|
-
color: Colors.black_17,
|
|
70
|
-
fontWeight: 'bold'
|
|
71
|
-
},
|
|
72
|
-
containerStyle: {
|
|
73
|
-
minHeight: CIRCLE_SIZE + 20 + CIRCLE_SIZE
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
export default class Step extends Component {
|
|
78
|
-
constructor(props) {
|
|
79
|
-
super(props);
|
|
80
|
-
this.state = {
|
|
81
|
-
width: 0,
|
|
82
|
-
height: 0
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
onLayout = (e) => {
|
|
87
|
-
this.setState({ width: e.nativeEvent.layout.width, height: e.nativeEvent.layout.height });
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
renderLine = () => {
|
|
91
|
-
const {
|
|
92
|
-
lineColor, lineStyle, currentStep, data
|
|
93
|
-
} = this.props;
|
|
94
|
-
return (
|
|
95
|
-
<View style={[styles.line, { borderColor: lineColor }, lineStyle]}>
|
|
96
|
-
{/* <View style={styles.topLeft} />
|
|
97
|
-
<View style={styles.topLeftWidth} />
|
|
98
|
-
<View style={styles.topRight} /> */}
|
|
99
|
-
</View>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
circle = (value, index) => {
|
|
104
|
-
const {
|
|
105
|
-
currentStep, tintColor, data, lineStyle, isNumber, iconActive,
|
|
106
|
-
iconInActive, lineColorActive, lineColorInActive, bodyStyle, iconStyle
|
|
107
|
-
} = this.props;
|
|
108
|
-
const { width } = this.state;
|
|
109
|
-
const icon = currentStep >= (index + 1) ? iconActive || IconSource.ic_step_active : iconInActive || IconSource.ic_step_coming;
|
|
110
|
-
const textFontStyle = currentStep >= (index + 1) ? styles.titleActive : styles.titleDefault;
|
|
111
|
-
const itemWidth = (width - CIRCLE_SIZE) / data?.length;
|
|
112
|
-
const lineActive = currentStep >= (index + 1) ? lineColorActive || isNumber ? Colors.pink_09 : Colors.sepia_05 : lineColorInActive || Colors.black_02;
|
|
113
|
-
const lineWidth = (width - CIRCLE_SIZE) / (data.length - 1);
|
|
114
|
-
const backgroundActive = currentStep >= (index + 1) ? Colors.pink_05_b : Colors.black_09;
|
|
115
|
-
let left = 0;
|
|
116
|
-
let textAlignStyle = { textAlign: 'center' };
|
|
117
|
-
/**
|
|
118
|
-
* item lefr
|
|
119
|
-
*/
|
|
120
|
-
if (index === 0) {
|
|
121
|
-
left = 0;
|
|
122
|
-
textAlignStyle = { textAlign: 'left' };
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* item right
|
|
126
|
-
*/
|
|
127
|
-
} else if (index === data?.length - 1) {
|
|
128
|
-
left = -itemWidth + CIRCLE_SIZE;
|
|
129
|
-
textAlignStyle = { textAlign: 'right' };
|
|
130
|
-
/**
|
|
131
|
-
* center item
|
|
132
|
-
*/
|
|
133
|
-
} else { left = -itemWidth / 2 + CIRCLE_SIZE / 2; }
|
|
134
|
-
const textStyle = [textAlignStyle, textFontStyle];
|
|
3
|
+
import HorizontalStep from './Step.horizontal';
|
|
4
|
+
import VerticalStep from './Step.vertical';
|
|
135
5
|
|
|
136
|
-
|
|
137
|
-
<View key={index}>
|
|
138
|
-
{
|
|
139
|
-
data?.length - 1 !== index && (
|
|
140
|
-
<View style={[styles.line, {
|
|
141
|
-
position: 'absolute',
|
|
142
|
-
top: 10,
|
|
143
|
-
backgroundColor: lineActive,
|
|
144
|
-
width: lineWidth,
|
|
145
|
-
height: 4,
|
|
146
|
-
marginTop: 0
|
|
147
|
-
}, lineStyle]}
|
|
148
|
-
/>
|
|
149
|
-
)
|
|
150
|
-
}
|
|
151
|
-
{
|
|
152
|
-
isNumber ? (
|
|
153
|
-
<View style={{
|
|
154
|
-
width: CIRCLE_SIZE,
|
|
155
|
-
height: CIRCLE_SIZE,
|
|
156
|
-
borderRadius: CIRCLE_SIZE / 2,
|
|
157
|
-
backgroundColor: backgroundActive,
|
|
158
|
-
borderColor: Colors.pink_09,
|
|
159
|
-
borderWidth: 1,
|
|
160
|
-
alignItems: 'center',
|
|
161
|
-
justifyContent: 'center'
|
|
162
|
-
}}
|
|
163
|
-
>
|
|
164
|
-
<Text.SubTitle style={{ color: 'white' }} weight="bold">{index + 1}</Text.SubTitle>
|
|
165
|
-
</View>
|
|
166
|
-
) : <Image source={icon} style={[styles.circle, { tintColor }, iconStyle]} />
|
|
167
|
-
}
|
|
6
|
+
import { Colors } from '@momo-kits/core-v2';
|
|
168
7
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}}
|
|
175
|
-
>
|
|
176
|
-
<Text.Caption style={[textStyle, bodyStyle]}>{value}</Text.Caption>
|
|
177
|
-
</View>
|
|
178
|
-
</View>
|
|
179
|
-
);
|
|
8
|
+
const Step = (props) => {
|
|
9
|
+
alert("CCCC")
|
|
10
|
+
const { isVertical } = props;
|
|
11
|
+
if (isVertical) {
|
|
12
|
+
return <VerticalStep {...props} />;
|
|
180
13
|
}
|
|
14
|
+
return <HorizontalStep {...props} />;
|
|
15
|
+
};
|
|
181
16
|
|
|
182
|
-
|
|
183
|
-
const {
|
|
184
|
-
currentStep, tintColor, data, lineStyle, isNumber, iconActive,
|
|
185
|
-
iconInActive, lineColorActive, lineColorInActive, bodyStyle, iconStyle
|
|
186
|
-
} = this.props;
|
|
187
|
-
const { height } = this.state;
|
|
188
|
-
const icon = currentStep >= (index + 1) ? iconActive || IconSource.ic_step_active : iconInActive || IconSource.ic_step_coming;
|
|
189
|
-
const textFontStyle = currentStep >= (index + 1) ? styles.titleActive : styles.titleDefault;
|
|
190
|
-
const itemWidth = (height - CIRCLE_SIZE) / data?.length;
|
|
191
|
-
const lineActive = currentStep >= (index + 1) ? lineColorActive || isNumber ? Colors.pink_09 : Colors.sepia_05 : lineColorInActive || Colors.black_02;
|
|
192
|
-
const lineWidth = (height - CIRCLE_SIZE) / (data.length - 1);
|
|
193
|
-
const backgroundActive = currentStep >= (index + 1) ? Colors.pink_05_b : Colors.black_09;
|
|
194
|
-
let left = 0;
|
|
195
|
-
let textAlignStyle = { textAlign: 'center' };
|
|
196
|
-
/**
|
|
197
|
-
* item lefr
|
|
198
|
-
*/
|
|
199
|
-
if (index === 0) {
|
|
200
|
-
left = 0;
|
|
201
|
-
textAlignStyle = { textAlign: 'left' };
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* item right
|
|
205
|
-
*/
|
|
206
|
-
} else if (index === data?.length - 1) {
|
|
207
|
-
left = -itemWidth + CIRCLE_SIZE;
|
|
208
|
-
textAlignStyle = { textAlign: 'right' };
|
|
209
|
-
/**
|
|
210
|
-
* center item
|
|
211
|
-
*/
|
|
212
|
-
} else { left = -itemWidth / 2 + CIRCLE_SIZE / 2; }
|
|
213
|
-
const textStyle = [textAlignStyle, textFontStyle];
|
|
214
|
-
|
|
215
|
-
return (
|
|
216
|
-
<View key={index}>
|
|
217
|
-
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
218
|
-
{
|
|
219
|
-
isNumber ? (
|
|
220
|
-
<View style={{
|
|
221
|
-
width: CIRCLE_SIZE,
|
|
222
|
-
height: CIRCLE_SIZE,
|
|
223
|
-
borderRadius: CIRCLE_SIZE / 2,
|
|
224
|
-
backgroundColor: backgroundActive,
|
|
225
|
-
borderColor: Colors.pink_09,
|
|
226
|
-
borderWidth: 1,
|
|
227
|
-
alignItems: 'center',
|
|
228
|
-
justifyContent: 'center'
|
|
229
|
-
}}
|
|
230
|
-
>
|
|
231
|
-
{
|
|
232
|
-
iconActive ? <Image source={iconActive} style={[styles.circle, { tintColor }, iconStyle]} /> : <Text.SubTitle style={{ color: 'white' }} weight="bold">{index + 1}</Text.SubTitle>
|
|
233
|
-
}
|
|
234
|
-
</View>
|
|
235
|
-
) : <Image source={icon} style={[styles.circle, { tintColor }, iconStyle]} />
|
|
236
|
-
}
|
|
237
|
-
<Text.Caption style={[{ marginLeft: 10 }, textStyle, bodyStyle]}>{value}</Text.Caption>
|
|
238
|
-
</View>
|
|
239
|
-
|
|
240
|
-
{
|
|
241
|
-
data?.length - 1 !== index && (
|
|
242
|
-
<View style={[styles.line, {
|
|
243
|
-
left: 10,
|
|
244
|
-
backgroundColor: lineActive,
|
|
245
|
-
width: 4,
|
|
246
|
-
height: lineWidth,
|
|
247
|
-
marginTop: 0,
|
|
248
|
-
}, lineStyle]}
|
|
249
|
-
/>
|
|
250
|
-
)
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
</View>
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
renderCircle = () => {
|
|
258
|
-
const { data = [], isVertical } = this.props;
|
|
259
|
-
return data.map(isVertical ? this.circleColumn : this.circle);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
render() {
|
|
263
|
-
const { width, height } = this.state;
|
|
264
|
-
const { style, isVertical } = this.props;
|
|
265
|
-
return (
|
|
266
|
-
<View style={[styles.containerStyle, style]} onLayout={this.onLayout}>
|
|
267
|
-
{/* {this.renderLine()} */}
|
|
268
|
-
{
|
|
269
|
-
isVertical ? (
|
|
270
|
-
<View style={[styles.circleColumn, { height }]}>
|
|
271
|
-
{this.renderCircle()}
|
|
272
|
-
</View>
|
|
273
|
-
) : (
|
|
274
|
-
<View style={[styles.circleRow, { width }]}>
|
|
275
|
-
{this.renderCircle()}
|
|
276
|
-
</View>
|
|
277
|
-
)
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
</View>
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
17
|
+
export default Step;
|
|
284
18
|
|
|
285
19
|
Step.propTypes = {
|
|
286
|
-
|
|
20
|
+
steps: PropTypes.arrayOf({
|
|
21
|
+
title: PropTypes.string.isRequired,
|
|
22
|
+
subTitle: PropTypes.string,
|
|
23
|
+
content: PropTypes.oneOfType([PropTypes.string || PropTypes.element]),
|
|
24
|
+
error: PropTypes.bool,
|
|
25
|
+
}),
|
|
287
26
|
currentStep: PropTypes.number,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
27
|
+
type: PropTypes.oneOf(['check', 'combine', 'text']),
|
|
28
|
+
size: PropTypes.oneOf(['default', 'small']),
|
|
29
|
+
activeCircleColor: PropTypes.string,
|
|
30
|
+
inactiveCircleColor: PropTypes.string,
|
|
31
|
+
checkedCircleColor: PropTypes.string,
|
|
32
|
+
activeBorderColor: PropTypes.string,
|
|
33
|
+
inactiveBorderColor: PropTypes.string,
|
|
34
|
+
activeLineColor: PropTypes.string,
|
|
35
|
+
inactiveLineColor: PropTypes.string,
|
|
36
|
+
style: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
37
|
+
checkIcon: PropTypes.string,
|
|
38
|
+
errorIcon: PropTypes.string,
|
|
297
39
|
};
|
|
298
40
|
|
|
299
41
|
Step.defaultProps = {
|
|
300
|
-
data: [],
|
|
301
42
|
currentStep: 0,
|
|
302
|
-
|
|
303
|
-
|
|
43
|
+
type: 'check',
|
|
44
|
+
size: 'normal',
|
|
45
|
+
activeCircleColor: Colors.pink_03,
|
|
46
|
+
inactiveCircleColor: Colors.black_06,
|
|
47
|
+
checkedCircleColor: Colors.pink_08,
|
|
48
|
+
activeBorderColor: Colors.pink_10,
|
|
49
|
+
inactiveBorderColor: Colors.black_04,
|
|
50
|
+
activeLineColor: Colors.pink_08,
|
|
51
|
+
inactiveLineColor: Colors.black_04,
|
|
52
|
+
};
|
package/Step.vertical.js
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Colors,
|
|
3
|
+
IconSource,
|
|
4
|
+
Image,
|
|
5
|
+
ScaleSize,
|
|
6
|
+
Spacing,
|
|
7
|
+
Text,
|
|
8
|
+
} from '@momo-kits/core-v2';
|
|
9
|
+
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import {StyleSheet, View} from 'react-native';
|
|
12
|
+
|
|
13
|
+
const ICON_URL = IconSource.ic_check_24;
|
|
14
|
+
|
|
15
|
+
const VerticalStep = props => {
|
|
16
|
+
const {
|
|
17
|
+
steps = {},
|
|
18
|
+
currentStep,
|
|
19
|
+
type,
|
|
20
|
+
activeCircleColor,
|
|
21
|
+
inactiveCircleColor,
|
|
22
|
+
checkedCircleColor,
|
|
23
|
+
activeBorderColor,
|
|
24
|
+
inactiveBorderColor,
|
|
25
|
+
activeLineColor,
|
|
26
|
+
inactiveLineColor,
|
|
27
|
+
style,
|
|
28
|
+
size = 'default',
|
|
29
|
+
checkIcon,
|
|
30
|
+
errorIcon,
|
|
31
|
+
} = props;
|
|
32
|
+
let CIRCLE_SIZE = 24;
|
|
33
|
+
let CIRCLE_TEXT_SIZE = 12;
|
|
34
|
+
let ICON_SIZE = 16;
|
|
35
|
+
let TITLE_SIZE = {
|
|
36
|
+
size: 14,
|
|
37
|
+
lineHeight: 20,
|
|
38
|
+
};
|
|
39
|
+
let SUBTITLE_SIZE = {
|
|
40
|
+
size: 10,
|
|
41
|
+
lineHeight: 14,
|
|
42
|
+
};
|
|
43
|
+
let CONTENT_SIZE = {
|
|
44
|
+
size: 12,
|
|
45
|
+
lineHeight: 16,
|
|
46
|
+
};
|
|
47
|
+
const ICON_URL = checkIcon || IconSource.ic_check_24;
|
|
48
|
+
const ERROR_ICON_URL = errorIcon || IconSource.ic_close_x_24;
|
|
49
|
+
if (size === 'small') {
|
|
50
|
+
CIRCLE_SIZE = 16;
|
|
51
|
+
CIRCLE_TEXT_SIZE = 8;
|
|
52
|
+
ICON_SIZE = 12;
|
|
53
|
+
TITLE_SIZE = {
|
|
54
|
+
size: 12,
|
|
55
|
+
lineHeight: 16,
|
|
56
|
+
};
|
|
57
|
+
SUBTITLE_SIZE = {
|
|
58
|
+
size: 10,
|
|
59
|
+
lineHeight: 14,
|
|
60
|
+
};
|
|
61
|
+
CONTENT_SIZE = {
|
|
62
|
+
size: 10,
|
|
63
|
+
lineHeight: 14,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const renderCircle = (error, index) => {
|
|
68
|
+
let circleColor = inactiveCircleColor;
|
|
69
|
+
let borderColor = inactiveBorderColor;
|
|
70
|
+
|
|
71
|
+
if (index < currentStep) {
|
|
72
|
+
circleColor = checkedCircleColor;
|
|
73
|
+
} else if (index === currentStep) circleColor = activeCircleColor;
|
|
74
|
+
|
|
75
|
+
if (index <= currentStep) borderColor = activeBorderColor;
|
|
76
|
+
if (error) {
|
|
77
|
+
circleColor = Colors.red_03;
|
|
78
|
+
borderColor = Colors.red_08;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<View
|
|
83
|
+
style={[
|
|
84
|
+
styles.circle,
|
|
85
|
+
{
|
|
86
|
+
width: CIRCLE_SIZE,
|
|
87
|
+
height: CIRCLE_SIZE,
|
|
88
|
+
borderRadius: CIRCLE_SIZE / 2,
|
|
89
|
+
borderColor: borderColor,
|
|
90
|
+
backgroundColor: circleColor,
|
|
91
|
+
},
|
|
92
|
+
]}>
|
|
93
|
+
{renderCircleContent(error, index)}
|
|
94
|
+
</View>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const renderCircleContent = (error, index) => {
|
|
99
|
+
const icon = error ? ERROR_ICON_URL : ICON_URL;
|
|
100
|
+
|
|
101
|
+
if (type === 'check') {
|
|
102
|
+
return (
|
|
103
|
+
<Image
|
|
104
|
+
source={icon}
|
|
105
|
+
style={[
|
|
106
|
+
styles.icon,
|
|
107
|
+
{
|
|
108
|
+
width: ICON_SIZE,
|
|
109
|
+
height: ICON_SIZE,
|
|
110
|
+
},
|
|
111
|
+
]}
|
|
112
|
+
/>
|
|
113
|
+
);
|
|
114
|
+
} else if (type === 'combine') {
|
|
115
|
+
return index < currentStep ? (
|
|
116
|
+
<Image
|
|
117
|
+
source={icon}
|
|
118
|
+
style={[
|
|
119
|
+
styles.icon,
|
|
120
|
+
{
|
|
121
|
+
width: ICON_SIZE,
|
|
122
|
+
height: ICON_SIZE,
|
|
123
|
+
},
|
|
124
|
+
]}
|
|
125
|
+
/>
|
|
126
|
+
) : (
|
|
127
|
+
<Text
|
|
128
|
+
style={[
|
|
129
|
+
styles.circleText,
|
|
130
|
+
{
|
|
131
|
+
fontSize: CIRCLE_TEXT_SIZE,
|
|
132
|
+
lineHeight: CIRCLE_TEXT_SIZE + 2,
|
|
133
|
+
},
|
|
134
|
+
]}>
|
|
135
|
+
{index + 1}
|
|
136
|
+
</Text>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
return (
|
|
140
|
+
<Text
|
|
141
|
+
style={[
|
|
142
|
+
styles.circleText,
|
|
143
|
+
{
|
|
144
|
+
fontSize: CIRCLE_TEXT_SIZE,
|
|
145
|
+
lineHeight: CIRCLE_TEXT_SIZE + 2,
|
|
146
|
+
},
|
|
147
|
+
]}>
|
|
148
|
+
{index + 1}
|
|
149
|
+
</Text>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const renderLine = index => {
|
|
154
|
+
if (index === steps.length - 1) return null;
|
|
155
|
+
const lineColor = index < currentStep ? activeLineColor : inactiveLineColor;
|
|
156
|
+
|
|
157
|
+
return <View style={[styles.line, {backgroundColor: lineColor}]} />;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const renderHeader = (title, subTitle, error, index) => {
|
|
161
|
+
const weight = index === currentStep ? '600' : '400';
|
|
162
|
+
const disabledColor = Colors.black_09;
|
|
163
|
+
const errorColor = Colors.red_03;
|
|
164
|
+
return (
|
|
165
|
+
<View style={styles.header}>
|
|
166
|
+
<Text
|
|
167
|
+
style={[
|
|
168
|
+
styles.title,
|
|
169
|
+
{
|
|
170
|
+
lineHeight: TITLE_SIZE.lineHeight,
|
|
171
|
+
fontSize: TITLE_SIZE.size,
|
|
172
|
+
fontWeight: weight,
|
|
173
|
+
color: error
|
|
174
|
+
? errorColor
|
|
175
|
+
: index < currentStep
|
|
176
|
+
? disabledColor
|
|
177
|
+
: Colors.black_17,
|
|
178
|
+
},
|
|
179
|
+
]}>
|
|
180
|
+
{title}
|
|
181
|
+
</Text>
|
|
182
|
+
<Text
|
|
183
|
+
style={[
|
|
184
|
+
styles.subTitle,
|
|
185
|
+
{
|
|
186
|
+
fontSize: SUBTITLE_SIZE.size,
|
|
187
|
+
lineHeight: SUBTITLE_SIZE.lineHeight,
|
|
188
|
+
color:
|
|
189
|
+
index < currentStep && !error ? disabledColor : Colors.black_12,
|
|
190
|
+
},
|
|
191
|
+
]}>
|
|
192
|
+
{subTitle}
|
|
193
|
+
</Text>
|
|
194
|
+
</View>
|
|
195
|
+
);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const renderContent = (content, error, index, size) => {
|
|
199
|
+
const disabledColor = Colors.black_09;
|
|
200
|
+
let marginBottom = size === 'small' ? Spacing.S : Spacing.M;
|
|
201
|
+
let minHeight = ScaleSize(30);
|
|
202
|
+
|
|
203
|
+
if (index === steps.length - 1) {
|
|
204
|
+
marginBottom = 0;
|
|
205
|
+
minHeight = 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return (
|
|
209
|
+
<View
|
|
210
|
+
style={[
|
|
211
|
+
styles.content,
|
|
212
|
+
{
|
|
213
|
+
marginBottom,
|
|
214
|
+
minHeight,
|
|
215
|
+
},
|
|
216
|
+
]}>
|
|
217
|
+
{content && typeof content === 'string' ? (
|
|
218
|
+
<Text
|
|
219
|
+
style={[
|
|
220
|
+
styles.contentText,
|
|
221
|
+
{
|
|
222
|
+
fontSize: CONTENT_SIZE.size,
|
|
223
|
+
lineHeight: CONTENT_SIZE.lineHeight,
|
|
224
|
+
color:
|
|
225
|
+
index < currentStep && !error
|
|
226
|
+
? disabledColor
|
|
227
|
+
: Colors.black_12,
|
|
228
|
+
},
|
|
229
|
+
]}>
|
|
230
|
+
{content}
|
|
231
|
+
</Text>
|
|
232
|
+
) : (
|
|
233
|
+
content
|
|
234
|
+
)}
|
|
235
|
+
</View>
|
|
236
|
+
);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const renderStepPart = (item, index) => {
|
|
240
|
+
const {title, subTitle, content, error} = item;
|
|
241
|
+
return (
|
|
242
|
+
<View
|
|
243
|
+
key={index.toString()}
|
|
244
|
+
style={{
|
|
245
|
+
flexDirection: 'row',
|
|
246
|
+
}}>
|
|
247
|
+
<View style={styles.circleContainer}>
|
|
248
|
+
{renderCircle(error, index)}
|
|
249
|
+
{renderLine(index)}
|
|
250
|
+
</View>
|
|
251
|
+
<View style={styles.contentContainer}>
|
|
252
|
+
{renderHeader(title, subTitle, error, index)}
|
|
253
|
+
{renderContent(content, error, index, size)}
|
|
254
|
+
</View>
|
|
255
|
+
</View>
|
|
256
|
+
);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
return (
|
|
260
|
+
<View style={style}>
|
|
261
|
+
{steps.map((item, index) => {
|
|
262
|
+
return renderStepPart(item, index);
|
|
263
|
+
})}
|
|
264
|
+
</View>
|
|
265
|
+
);
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export default VerticalStep;
|
|
269
|
+
|
|
270
|
+
const styles = StyleSheet.create({
|
|
271
|
+
circleContainer: {
|
|
272
|
+
flexDirection: 'column',
|
|
273
|
+
alignItems: 'center',
|
|
274
|
+
height: '100%',
|
|
275
|
+
},
|
|
276
|
+
circle: {
|
|
277
|
+
borderWidth: 2,
|
|
278
|
+
justifyContent: 'center',
|
|
279
|
+
alignItems: 'center',
|
|
280
|
+
},
|
|
281
|
+
contentContainer: {
|
|
282
|
+
marginLeft: Spacing.S,
|
|
283
|
+
flex: 1,
|
|
284
|
+
},
|
|
285
|
+
content: {
|
|
286
|
+
marginTop: Spacing.XS,
|
|
287
|
+
},
|
|
288
|
+
contentText: {
|
|
289
|
+
color: Colors.black_12,
|
|
290
|
+
},
|
|
291
|
+
header: {
|
|
292
|
+
flexDirection: 'row',
|
|
293
|
+
justifyContent: 'space-between',
|
|
294
|
+
alignItems: 'center',
|
|
295
|
+
},
|
|
296
|
+
title: {},
|
|
297
|
+
subTitle: {
|
|
298
|
+
color: Colors.black_12,
|
|
299
|
+
},
|
|
300
|
+
line: {
|
|
301
|
+
width: 2,
|
|
302
|
+
flex: 1,
|
|
303
|
+
marginVertical: Spacing.XS,
|
|
304
|
+
borderRadius: 1,
|
|
305
|
+
},
|
|
306
|
+
icon: {
|
|
307
|
+
tintColor: Colors.white,
|
|
308
|
+
},
|
|
309
|
+
circleText: {
|
|
310
|
+
color: Colors.white,
|
|
311
|
+
fontWeight: '600',
|
|
312
|
+
},
|
|
313
|
+
});
|