@momo-kits/step 0.0.56-beta → 0.0.56-beta.10
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.constants.js +1 -0
- package/Step.horizontal.js +430 -0
- package/Step.horizontal.web.js +434 -0
- package/Step.js +33 -280
- package/Step.vertical.js +402 -0
- package/Step.vertical.web.js +401 -0
- package/Step.web.js +41 -150
- package/package.json +15 -13
- package/publish.sh +1 -1
package/Step.js
CHANGED
|
@@ -1,303 +1,56 @@
|
|
|
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
|
-
});
|
|
3
|
+
import HorizontalStep from './Step.horizontal';
|
|
4
|
+
import VerticalStep from './Step.vertical';
|
|
76
5
|
|
|
6
|
+
import { Colors, IconSource } from '@momo-kits/core';
|
|
77
7
|
export default class Step extends Component {
|
|
78
8
|
constructor(props) {
|
|
79
9
|
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];
|
|
135
|
-
|
|
136
|
-
return (
|
|
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
|
-
}
|
|
168
|
-
|
|
169
|
-
<View style={{
|
|
170
|
-
position: 'absolute',
|
|
171
|
-
width: itemWidth,
|
|
172
|
-
left,
|
|
173
|
-
top: CIRCLE_SIZE + CIRCLE_SIZE / 4
|
|
174
|
-
}}
|
|
175
|
-
>
|
|
176
|
-
<Text.Caption style={[textStyle, bodyStyle]}>{value}</Text.Caption>
|
|
177
|
-
</View>
|
|
178
|
-
</View>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
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
|
-
|
|
257
|
-
renderCircle = () => {
|
|
258
|
-
const { data = [], isVertical } = this.props;
|
|
259
|
-
return data.map(isVertical ? this.circleColumn : this.circle);
|
|
260
10
|
}
|
|
261
11
|
|
|
262
12
|
render() {
|
|
263
|
-
const {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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
|
-
);
|
|
13
|
+
const { isVertical } = this.props;
|
|
14
|
+
let DefaultComponent = HorizontalStep;
|
|
15
|
+
if (isVertical) {
|
|
16
|
+
DefaultComponent = VerticalStep;
|
|
17
|
+
}
|
|
18
|
+
return <DefaultComponent {...this.props} />;
|
|
282
19
|
}
|
|
283
20
|
}
|
|
284
21
|
|
|
285
22
|
Step.propTypes = {
|
|
286
|
-
|
|
23
|
+
titles: PropTypes.array,
|
|
287
24
|
currentStep: PropTypes.number,
|
|
288
|
-
tintColor: PropTypes.string,
|
|
289
25
|
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
290
|
-
|
|
26
|
+
items: PropTypes.array,
|
|
291
27
|
isVertical: PropTypes.bool,
|
|
292
28
|
iconActive: PropTypes.any,
|
|
293
|
-
|
|
29
|
+
iconChecked: PropTypes.any,
|
|
30
|
+
iconUnchecked: PropTypes.any,
|
|
31
|
+
circleColorActive: PropTypes.string,
|
|
32
|
+
circleColorChecked: PropTypes.string,
|
|
33
|
+
circleColorUnchecked: PropTypes.string,
|
|
34
|
+
circleBorderColorActive: PropTypes.string,
|
|
35
|
+
circleBorderColorChecked: PropTypes.string,
|
|
36
|
+
circleBorderColorUnchecked: PropTypes.string,
|
|
294
37
|
lineColorActive: PropTypes.string,
|
|
295
38
|
lineColorInActive: PropTypes.string,
|
|
296
|
-
|
|
39
|
+
titleStyle: PropTypes.object,
|
|
40
|
+
descriptionStyle: PropTypes.object,
|
|
41
|
+
dateStyle: PropTypes.object,
|
|
297
42
|
};
|
|
298
43
|
|
|
299
44
|
Step.defaultProps = {
|
|
300
|
-
|
|
45
|
+
titles: [],
|
|
301
46
|
currentStep: 0,
|
|
302
|
-
|
|
303
|
-
|
|
47
|
+
isVertical: false,
|
|
48
|
+
circleColorActive: '#d82d8b',
|
|
49
|
+
circleColorChecked: '#ffadd2',
|
|
50
|
+
circleColorUnchecked: Colors.black_06,
|
|
51
|
+
circleBorderColorActive: Colors.pink_09,
|
|
52
|
+
circleBorderColorChecked: Colors.pink_09,
|
|
53
|
+
circleBorderColorUnchecked: Colors.black_04,
|
|
54
|
+
lineColorActive: '#ffd6e7',
|
|
55
|
+
lineColorInActive: Colors.black_04,
|
|
56
|
+
};
|