@momo-kits/step 0.0.40-beta → 0.0.40-beta.3
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.js +171 -34
- package/Step.web.js +174 -38
- package/package.json +1 -1
- package/publish.sh +1 -1
package/Step.js
CHANGED
|
@@ -6,25 +6,25 @@ import {
|
|
|
6
6
|
Colors, Text, IconSource, Image
|
|
7
7
|
} from '@momo-kits/core';
|
|
8
8
|
|
|
9
|
-
const CIRCLE_SIZE =
|
|
9
|
+
const CIRCLE_SIZE = 24;
|
|
10
10
|
|
|
11
11
|
const styles = StyleSheet.create({
|
|
12
12
|
circle: {
|
|
13
13
|
width: CIRCLE_SIZE,
|
|
14
14
|
height: CIRCLE_SIZE,
|
|
15
|
-
borderWidth: 1,
|
|
16
|
-
borderColor: Colors.sepia_05,
|
|
17
|
-
borderRadius:
|
|
15
|
+
// borderWidth: 1,
|
|
16
|
+
// borderColor: Colors.sepia_05,
|
|
17
|
+
borderRadius: CIRCLE_SIZE / 2,
|
|
18
18
|
backgroundColor: 'white'
|
|
19
19
|
},
|
|
20
20
|
line: {
|
|
21
|
-
height:
|
|
21
|
+
height: 4,
|
|
22
22
|
backgroundColor: 'white',
|
|
23
|
-
borderWidth: 1,
|
|
24
|
-
borderRadius: 1,
|
|
25
|
-
borderStyle: 'dashed',
|
|
23
|
+
// borderWidth: 1,
|
|
24
|
+
// borderRadius: 1,
|
|
25
|
+
// borderStyle: 'dashed',
|
|
26
26
|
zIndex: 0,
|
|
27
|
-
marginTop:
|
|
27
|
+
// marginTop: 8
|
|
28
28
|
},
|
|
29
29
|
topRight: {
|
|
30
30
|
position: 'absolute',
|
|
@@ -58,6 +58,10 @@ const styles = StyleSheet.create({
|
|
|
58
58
|
justifyContent: 'space-between',
|
|
59
59
|
flexDirection: 'row',
|
|
60
60
|
},
|
|
61
|
+
circleColumn: {
|
|
62
|
+
// position: 'absolute',
|
|
63
|
+
justifyContent: 'space-between',
|
|
64
|
+
},
|
|
61
65
|
titleDefault: {
|
|
62
66
|
color: Colors.black_12
|
|
63
67
|
},
|
|
@@ -74,31 +78,41 @@ export default class Step extends Component {
|
|
|
74
78
|
constructor(props) {
|
|
75
79
|
super(props);
|
|
76
80
|
this.state = {
|
|
77
|
-
width: 0
|
|
81
|
+
width: 0,
|
|
82
|
+
height: 0
|
|
78
83
|
};
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
onLayout = (e) => {
|
|
82
|
-
this.setState({ width: e.nativeEvent.layout.width });
|
|
87
|
+
this.setState({ width: e.nativeEvent.layout.width, height: e.nativeEvent.layout.height });
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
renderLine = () => {
|
|
86
|
-
const {
|
|
91
|
+
const {
|
|
92
|
+
lineColor, lineStyle, currentStep, data
|
|
93
|
+
} = this.props;
|
|
87
94
|
return (
|
|
88
|
-
<View style={[styles.line, { borderColor: lineColor }]}>
|
|
89
|
-
<View style={styles.topLeft} />
|
|
95
|
+
<View style={[styles.line, { borderColor: lineColor }, lineStyle]}>
|
|
96
|
+
{/* <View style={styles.topLeft} />
|
|
90
97
|
<View style={styles.topLeftWidth} />
|
|
91
|
-
<View style={styles.topRight} />
|
|
98
|
+
<View style={styles.topRight} /> */}
|
|
92
99
|
</View>
|
|
93
100
|
);
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
circle = (value, index) => {
|
|
97
|
-
const {
|
|
104
|
+
const {
|
|
105
|
+
currentStep, tintColor, data, lineStyle, isNumber, iconActive,
|
|
106
|
+
iconInActive, lineColorActive, lineColorInActive, bodyStyle, iconStyle, checkedPreviousStep, borderColorActive, borderColorInActive,
|
|
107
|
+
} = this.props;
|
|
98
108
|
const { width } = this.state;
|
|
99
|
-
const icon = currentStep >= (index + 1) ? IconSource.ic_step_active : IconSource.ic_step_coming;
|
|
109
|
+
const icon = currentStep >= (index + 1) ? iconActive || IconSource.ic_step_active : iconInActive || IconSource.ic_step_coming;
|
|
100
110
|
const textFontStyle = currentStep >= (index + 1) ? styles.titleActive : styles.titleDefault;
|
|
101
111
|
const itemWidth = (width - CIRCLE_SIZE) / data?.length;
|
|
112
|
+
const lineActive = currentStep >= (index + 1) ? lineColorActive || isNumber ? lineColorActive || 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
|
+
const borderColor = currentStep >= (index + 1) ? borderColorActive || Colors.pink_09 : borderColorInActive || Colors.pink_09;
|
|
102
116
|
let left = 0;
|
|
103
117
|
let textAlignStyle = { textAlign: 'center' };
|
|
104
118
|
/**
|
|
@@ -119,53 +133,176 @@ export default class Step extends Component {
|
|
|
119
133
|
*/
|
|
120
134
|
} else { left = -itemWidth / 2 + CIRCLE_SIZE / 2; }
|
|
121
135
|
const textStyle = [textAlignStyle, textFontStyle];
|
|
136
|
+
|
|
122
137
|
return (
|
|
123
|
-
<View>
|
|
124
|
-
|
|
138
|
+
<View key={index}>
|
|
139
|
+
{
|
|
140
|
+
data?.length - 1 !== index && (
|
|
141
|
+
<View style={[styles.line, {
|
|
142
|
+
position: 'absolute',
|
|
143
|
+
top: 10,
|
|
144
|
+
backgroundColor: lineActive,
|
|
145
|
+
width: lineWidth,
|
|
146
|
+
height: 4,
|
|
147
|
+
marginTop: 0
|
|
148
|
+
}, lineStyle]}
|
|
149
|
+
/>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
{
|
|
153
|
+
(isNumber && !checkedPreviousStep) || (isNumber && checkedPreviousStep && index >= currentStep -1 ) ? (
|
|
154
|
+
<View style={{
|
|
155
|
+
width: CIRCLE_SIZE,
|
|
156
|
+
height: CIRCLE_SIZE,
|
|
157
|
+
borderRadius: CIRCLE_SIZE / 2,
|
|
158
|
+
backgroundColor: backgroundActive,
|
|
159
|
+
borderColor: borderColor,
|
|
160
|
+
borderWidth: 2,
|
|
161
|
+
alignItems: 'center',
|
|
162
|
+
justifyContent: 'center'
|
|
163
|
+
}}
|
|
164
|
+
>
|
|
165
|
+
<Text.SubTitle style={{ color: 'white' }} weight="bold">{index + 1}</Text.SubTitle>
|
|
166
|
+
</View>
|
|
167
|
+
) : <Image source={icon} style={[styles.circle, { tintColor }, iconStyle]} />
|
|
168
|
+
}
|
|
169
|
+
|
|
125
170
|
<View style={{
|
|
126
171
|
position: 'absolute',
|
|
127
172
|
width: itemWidth,
|
|
128
173
|
left,
|
|
129
|
-
top: CIRCLE_SIZE + CIRCLE_SIZE /
|
|
174
|
+
top: CIRCLE_SIZE + CIRCLE_SIZE / 4
|
|
130
175
|
}}
|
|
131
176
|
>
|
|
132
|
-
<Text.
|
|
177
|
+
<Text.Caption style={[textStyle, bodyStyle]}>{value}</Text.Caption>
|
|
133
178
|
</View>
|
|
134
179
|
</View>
|
|
135
180
|
);
|
|
136
181
|
}
|
|
137
182
|
|
|
183
|
+
circleColumn = (value, index) => {
|
|
184
|
+
const {
|
|
185
|
+
currentStep, tintColor, data, lineStyle, isNumber, iconActive,
|
|
186
|
+
iconInActive, lineColorActive, lineColorInActive, bodyStyle, iconStyle
|
|
187
|
+
} = this.props;
|
|
188
|
+
const { height } = this.state;
|
|
189
|
+
const icon = currentStep >= (index + 1) ? iconActive || IconSource.ic_step_active : iconInActive || IconSource.ic_step_coming;
|
|
190
|
+
const textFontStyle = currentStep >= (index + 1) ? styles.titleActive : styles.titleDefault;
|
|
191
|
+
const itemWidth = (height - CIRCLE_SIZE) / data?.length;
|
|
192
|
+
const lineActive = currentStep >= (index + 1) ? lineColorActive || isNumber ? Colors.pink_09 : Colors.sepia_05 : lineColorInActive || Colors.black_02;
|
|
193
|
+
const lineWidth = (height - CIRCLE_SIZE) / (data.length - 1);
|
|
194
|
+
const backgroundActive = currentStep >= (index + 1) ? Colors.pink_05_b : Colors.black_09;
|
|
195
|
+
let left = 0;
|
|
196
|
+
let textAlignStyle = { textAlign: 'center' };
|
|
197
|
+
/**
|
|
198
|
+
* item lefr
|
|
199
|
+
*/
|
|
200
|
+
if (index === 0) {
|
|
201
|
+
left = 0;
|
|
202
|
+
textAlignStyle = { textAlign: 'left' };
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* item right
|
|
206
|
+
*/
|
|
207
|
+
} else if (index === data?.length - 1) {
|
|
208
|
+
left = -itemWidth + CIRCLE_SIZE;
|
|
209
|
+
textAlignStyle = { textAlign: 'right' };
|
|
210
|
+
/**
|
|
211
|
+
* center item
|
|
212
|
+
*/
|
|
213
|
+
} else { left = -itemWidth / 2 + CIRCLE_SIZE / 2; }
|
|
214
|
+
const textStyle = [textAlignStyle, textFontStyle];
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<View key={index}>
|
|
218
|
+
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
219
|
+
{
|
|
220
|
+
isNumber ? (
|
|
221
|
+
<View style={{
|
|
222
|
+
width: CIRCLE_SIZE,
|
|
223
|
+
height: CIRCLE_SIZE,
|
|
224
|
+
borderRadius: CIRCLE_SIZE / 2,
|
|
225
|
+
backgroundColor: backgroundActive,
|
|
226
|
+
borderColor: Colors.pink_09,
|
|
227
|
+
borderWidth: 1,
|
|
228
|
+
alignItems: 'center',
|
|
229
|
+
justifyContent: 'center'
|
|
230
|
+
}}
|
|
231
|
+
>
|
|
232
|
+
{
|
|
233
|
+
iconActive ? <Image source={iconActive} style={[styles.circle, { tintColor }, iconStyle]} /> : <Text.SubTitle style={{ color: 'white' }} weight="bold">{index + 1}</Text.SubTitle>
|
|
234
|
+
}
|
|
235
|
+
</View>
|
|
236
|
+
) : <Image source={icon} style={[styles.circle, { tintColor }, iconStyle]} />
|
|
237
|
+
}
|
|
238
|
+
<Text.Caption style={[{ marginLeft: 10 }, textStyle, bodyStyle]}>{value}</Text.Caption>
|
|
239
|
+
</View>
|
|
240
|
+
|
|
241
|
+
{
|
|
242
|
+
data?.length - 1 !== index && (
|
|
243
|
+
<View style={[styles.line, {
|
|
244
|
+
left: 10,
|
|
245
|
+
backgroundColor: lineActive,
|
|
246
|
+
width: 4,
|
|
247
|
+
height: lineWidth,
|
|
248
|
+
marginTop: 0,
|
|
249
|
+
}, lineStyle]}
|
|
250
|
+
/>
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
</View>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
138
258
|
renderCircle = () => {
|
|
139
|
-
const { data = [] } = this.props;
|
|
140
|
-
|
|
141
|
-
return views;
|
|
259
|
+
const { data = [], isVertical } = this.props;
|
|
260
|
+
return data.map(isVertical ? this.circleColumn : this.circle);
|
|
142
261
|
}
|
|
143
262
|
|
|
144
263
|
render() {
|
|
145
|
-
const { width } = this.state;
|
|
146
|
-
const { style } = this.props;
|
|
264
|
+
const { width, height } = this.state;
|
|
265
|
+
const { style, isVertical } = this.props;
|
|
147
266
|
return (
|
|
148
267
|
<View style={[styles.containerStyle, style]} onLayout={this.onLayout}>
|
|
149
|
-
{this.renderLine()}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
268
|
+
{/* {this.renderLine()} */}
|
|
269
|
+
{
|
|
270
|
+
isVertical ? (
|
|
271
|
+
<View style={[styles.circleColumn, { height }]}>
|
|
272
|
+
{this.renderCircle()}
|
|
273
|
+
</View>
|
|
274
|
+
) : (
|
|
275
|
+
<View style={[styles.circleRow, { width }]}>
|
|
276
|
+
{this.renderCircle()}
|
|
277
|
+
</View>
|
|
278
|
+
)
|
|
279
|
+
}
|
|
280
|
+
|
|
153
281
|
</View>
|
|
154
282
|
);
|
|
155
283
|
}
|
|
156
284
|
}
|
|
157
285
|
|
|
158
286
|
Step.propTypes = {
|
|
159
|
-
lineColor: PropTypes.string,
|
|
160
287
|
data: PropTypes.arrayOf(PropTypes.string),
|
|
161
288
|
currentStep: PropTypes.number,
|
|
162
289
|
tintColor: PropTypes.string,
|
|
163
290
|
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
291
|
+
isNumber: PropTypes.bool,
|
|
292
|
+
isVertical: PropTypes.bool,
|
|
293
|
+
iconActive: PropTypes.any,
|
|
294
|
+
iconInActive: PropTypes.any,
|
|
295
|
+
lineColorActive: PropTypes.string,
|
|
296
|
+
lineColorInActive: PropTypes.string,
|
|
297
|
+
bodyStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
298
|
+
checkedPreviousStep: PropTypes.bool,
|
|
299
|
+
borderColorActive: PropTypes.string,
|
|
300
|
+
borderColorInActive: PropTypes.string,
|
|
164
301
|
};
|
|
165
302
|
|
|
166
303
|
Step.defaultProps = {
|
|
167
304
|
data: [],
|
|
168
|
-
lineColor: Colors.sepia_05,
|
|
169
305
|
currentStep: 0,
|
|
170
|
-
tintColor: Colors.sepia_05
|
|
171
|
-
|
|
306
|
+
tintColor: Colors.sepia_05,
|
|
307
|
+
checkedPreviousStep: false,
|
|
308
|
+
};
|
package/Step.web.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import { View, StyleSheet, Image } from 'react-native';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { ColorCore } from '../../core/colors/colorCore';
|
|
4
|
+
import { ColorCore as Colors } from '../../core/colors/colorCore';
|
|
5
5
|
import Text from '../../core/components/typography';
|
|
6
|
-
import { Icons } from '../../core/icons';
|
|
6
|
+
import { Icons as IconSource } from '../../core/icons';
|
|
7
7
|
|
|
8
|
-
const CIRCLE_SIZE =
|
|
8
|
+
const CIRCLE_SIZE = 24;
|
|
9
9
|
|
|
10
10
|
const styles = StyleSheet.create({
|
|
11
11
|
circle: {
|
|
12
12
|
width: CIRCLE_SIZE,
|
|
13
13
|
height: CIRCLE_SIZE,
|
|
14
|
-
borderWidth: 1,
|
|
15
|
-
borderColor:
|
|
16
|
-
borderRadius:
|
|
14
|
+
// borderWidth: 1,
|
|
15
|
+
// borderColor: Colors.sepia_05,
|
|
16
|
+
borderRadius: CIRCLE_SIZE / 2,
|
|
17
17
|
backgroundColor: 'white'
|
|
18
18
|
},
|
|
19
19
|
line: {
|
|
20
|
-
height:
|
|
20
|
+
height: 4,
|
|
21
21
|
backgroundColor: 'white',
|
|
22
|
-
borderWidth: 1,
|
|
23
|
-
borderRadius: 1,
|
|
24
|
-
borderStyle: 'dashed',
|
|
22
|
+
// borderWidth: 1,
|
|
23
|
+
// borderRadius: 1,
|
|
24
|
+
// borderStyle: 'dashed',
|
|
25
25
|
zIndex: 0,
|
|
26
|
-
marginTop:
|
|
26
|
+
// marginTop: 8
|
|
27
27
|
},
|
|
28
28
|
topRight: {
|
|
29
29
|
position: 'absolute',
|
|
@@ -57,11 +57,15 @@ const styles = StyleSheet.create({
|
|
|
57
57
|
justifyContent: 'space-between',
|
|
58
58
|
flexDirection: 'row',
|
|
59
59
|
},
|
|
60
|
+
circleColumn: {
|
|
61
|
+
// position: 'absolute',
|
|
62
|
+
justifyContent: 'space-between',
|
|
63
|
+
},
|
|
60
64
|
titleDefault: {
|
|
61
|
-
color:
|
|
65
|
+
color: Colors.black_12
|
|
62
66
|
},
|
|
63
67
|
titleActive: {
|
|
64
|
-
color:
|
|
68
|
+
color: Colors.black_17,
|
|
65
69
|
fontWeight: 'bold'
|
|
66
70
|
},
|
|
67
71
|
containerStyle: {
|
|
@@ -73,31 +77,41 @@ export default class Step extends Component {
|
|
|
73
77
|
constructor(props) {
|
|
74
78
|
super(props);
|
|
75
79
|
this.state = {
|
|
76
|
-
width: 0
|
|
80
|
+
width: 0,
|
|
81
|
+
height: 0
|
|
77
82
|
};
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
onLayout = (e) => {
|
|
81
|
-
this.setState({ width: e.nativeEvent.layout.width });
|
|
86
|
+
this.setState({ width: e.nativeEvent.layout.width, height: e.nativeEvent.layout.height });
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
renderLine = () => {
|
|
85
|
-
const {
|
|
90
|
+
const {
|
|
91
|
+
lineColor, lineStyle, currentStep, data
|
|
92
|
+
} = this.props;
|
|
86
93
|
return (
|
|
87
|
-
<View style={[styles.line, { borderColor: lineColor }]}>
|
|
88
|
-
<View style={styles.topLeft} />
|
|
94
|
+
<View style={[styles.line, { borderColor: lineColor }, lineStyle]}>
|
|
95
|
+
{/* <View style={styles.topLeft} />
|
|
89
96
|
<View style={styles.topLeftWidth} />
|
|
90
|
-
<View style={styles.topRight} />
|
|
97
|
+
<View style={styles.topRight} /> */}
|
|
91
98
|
</View>
|
|
92
99
|
);
|
|
93
100
|
}
|
|
94
101
|
|
|
95
102
|
circle = (value, index) => {
|
|
96
|
-
const {
|
|
103
|
+
const {
|
|
104
|
+
currentStep, tintColor, data, lineStyle, isNumber, iconActive,
|
|
105
|
+
iconInActive, lineColorActive, lineColorInActive, bodyStyle, iconStyle, checkedPreviousStep, borderColorActive, borderColorInActive,
|
|
106
|
+
} = this.props;
|
|
97
107
|
const { width } = this.state;
|
|
98
|
-
const icon = currentStep >= (index + 1) ?
|
|
108
|
+
const icon = currentStep >= (index + 1) ? iconActive || IconSource.ic_step_active : iconInActive || IconSource.ic_step_coming;
|
|
99
109
|
const textFontStyle = currentStep >= (index + 1) ? styles.titleActive : styles.titleDefault;
|
|
100
110
|
const itemWidth = (width - CIRCLE_SIZE) / data?.length;
|
|
111
|
+
const lineActive = currentStep >= (index + 1) ? lineColorActive || isNumber ? lineColorActive || Colors.pink_09 : Colors.sepia_05 : lineColorInActive || Colors.black_02;
|
|
112
|
+
const lineWidth = (width - CIRCLE_SIZE) / (data.length - 1);
|
|
113
|
+
const backgroundActive = currentStep >= (index + 1) ? Colors.pink_05_b : Colors.black_09;
|
|
114
|
+
const borderColor = currentStep >= (index + 1) ? borderColorActive || Colors.pink_09 : borderColorInActive || Colors.pink_09;
|
|
101
115
|
let left = 0;
|
|
102
116
|
let textAlignStyle = { textAlign: 'center' };
|
|
103
117
|
/**
|
|
@@ -118,53 +132,175 @@ export default class Step extends Component {
|
|
|
118
132
|
*/
|
|
119
133
|
} else { left = -itemWidth / 2 + CIRCLE_SIZE / 2; }
|
|
120
134
|
const textStyle = [textAlignStyle, textFontStyle];
|
|
135
|
+
|
|
121
136
|
return (
|
|
122
|
-
<View>
|
|
123
|
-
|
|
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 && !checkedPreviousStep) || (isNumber && checkedPreviousStep && index >= currentStep -1 ) ? (
|
|
153
|
+
<View style={{
|
|
154
|
+
width: CIRCLE_SIZE,
|
|
155
|
+
height: CIRCLE_SIZE,
|
|
156
|
+
borderRadius: CIRCLE_SIZE / 2,
|
|
157
|
+
backgroundColor: backgroundActive,
|
|
158
|
+
borderColor: borderColor,
|
|
159
|
+
borderWidth: 2,
|
|
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
|
+
}
|
|
168
|
+
|
|
124
169
|
<View style={{
|
|
125
170
|
position: 'absolute',
|
|
126
171
|
width: itemWidth,
|
|
127
172
|
left,
|
|
128
|
-
top: CIRCLE_SIZE + CIRCLE_SIZE /
|
|
173
|
+
top: CIRCLE_SIZE + CIRCLE_SIZE / 4
|
|
129
174
|
}}
|
|
130
175
|
>
|
|
131
|
-
<Text.
|
|
176
|
+
<Text.Caption style={[textStyle, bodyStyle]}>{value}</Text.Caption>
|
|
132
177
|
</View>
|
|
133
178
|
</View>
|
|
134
179
|
);
|
|
135
180
|
}
|
|
136
181
|
|
|
182
|
+
circleColumn = (value, index) => {
|
|
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
|
+
|
|
137
257
|
renderCircle = () => {
|
|
138
|
-
const { data = [] } = this.props;
|
|
139
|
-
|
|
140
|
-
return views;
|
|
258
|
+
const { data = [], isVertical } = this.props;
|
|
259
|
+
return data.map(isVertical ? this.circleColumn : this.circle);
|
|
141
260
|
}
|
|
142
261
|
|
|
143
262
|
render() {
|
|
144
|
-
const { width } = this.state;
|
|
145
|
-
const { style } = this.props;
|
|
263
|
+
const { width, height } = this.state;
|
|
264
|
+
const { style, isVertical } = this.props;
|
|
146
265
|
return (
|
|
147
266
|
<View style={[styles.containerStyle, style]} onLayout={this.onLayout}>
|
|
148
|
-
{this.renderLine()}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
+
|
|
152
280
|
</View>
|
|
153
281
|
);
|
|
154
282
|
}
|
|
155
283
|
}
|
|
156
284
|
|
|
157
285
|
Step.propTypes = {
|
|
158
|
-
lineColor: PropTypes.string,
|
|
159
286
|
data: PropTypes.arrayOf(PropTypes.string),
|
|
160
287
|
currentStep: PropTypes.number,
|
|
161
288
|
tintColor: PropTypes.string,
|
|
162
289
|
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
290
|
+
isNumber: PropTypes.bool,
|
|
291
|
+
isVertical: PropTypes.bool,
|
|
292
|
+
iconActive: PropTypes.any,
|
|
293
|
+
iconInActive: PropTypes.any,
|
|
294
|
+
lineColorActive: PropTypes.string,
|
|
295
|
+
lineColorInActive: PropTypes.string,
|
|
296
|
+
bodyStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
297
|
+
checkedPreviousStep: PropTypes.bool,
|
|
298
|
+
borderColorActive: PropTypes.string,
|
|
299
|
+
borderColorInActive: PropTypes.string,
|
|
163
300
|
};
|
|
164
301
|
|
|
165
302
|
Step.defaultProps = {
|
|
166
303
|
data: [],
|
|
167
|
-
lineColor: '#fa541c',
|
|
168
304
|
currentStep: 0,
|
|
169
|
-
tintColor:
|
|
170
|
-
};
|
|
305
|
+
tintColor: Colors.sepia_05
|
|
306
|
+
};
|
package/package.json
CHANGED