@momo-kits/step 0.0.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.js +303 -0
- package/Step.web.js +302 -0
- package/index.js +3 -0
- package/package.json +15 -0
- package/publish.sh +29 -0
package/Step.js
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import {
|
|
6
|
+
Colors, Text, IconSource, Image
|
|
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];
|
|
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
|
+
}
|
|
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
|
+
}
|
|
284
|
+
|
|
285
|
+
Step.propTypes = {
|
|
286
|
+
data: PropTypes.arrayOf(PropTypes.string),
|
|
287
|
+
currentStep: PropTypes.number,
|
|
288
|
+
tintColor: PropTypes.string,
|
|
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
|
+
};
|
|
298
|
+
|
|
299
|
+
Step.defaultProps = {
|
|
300
|
+
data: [],
|
|
301
|
+
currentStep: 0,
|
|
302
|
+
tintColor: Colors.sepia_05
|
|
303
|
+
};
|
package/Step.web.js
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { View, StyleSheet, Image } from 'react-native';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { ColorCore as Colors } from '../../core/colors/colorCore';
|
|
5
|
+
import Text from '../../core/components/typography';
|
|
6
|
+
import { Icons as IconSource } from '../../core/icons';
|
|
7
|
+
|
|
8
|
+
const CIRCLE_SIZE = 24;
|
|
9
|
+
|
|
10
|
+
const styles = StyleSheet.create({
|
|
11
|
+
circle: {
|
|
12
|
+
width: CIRCLE_SIZE,
|
|
13
|
+
height: CIRCLE_SIZE,
|
|
14
|
+
// borderWidth: 1,
|
|
15
|
+
// borderColor: Colors.sepia_05,
|
|
16
|
+
borderRadius: CIRCLE_SIZE / 2,
|
|
17
|
+
backgroundColor: 'white'
|
|
18
|
+
},
|
|
19
|
+
line: {
|
|
20
|
+
height: 4,
|
|
21
|
+
backgroundColor: 'white',
|
|
22
|
+
// borderWidth: 1,
|
|
23
|
+
// borderRadius: 1,
|
|
24
|
+
// borderStyle: 'dashed',
|
|
25
|
+
zIndex: 0,
|
|
26
|
+
// marginTop: 8
|
|
27
|
+
},
|
|
28
|
+
topRight: {
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
right: -1,
|
|
31
|
+
top: -1,
|
|
32
|
+
width: 1,
|
|
33
|
+
height: '100%',
|
|
34
|
+
backgroundColor: 'white',
|
|
35
|
+
zIndex: 1
|
|
36
|
+
},
|
|
37
|
+
topLeft: {
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
left: -1,
|
|
40
|
+
top: -1,
|
|
41
|
+
width: '100%',
|
|
42
|
+
height: 1,
|
|
43
|
+
backgroundColor: 'white',
|
|
44
|
+
zIndex: 1
|
|
45
|
+
},
|
|
46
|
+
topLeftWidth: {
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
left: -1,
|
|
49
|
+
top: -1,
|
|
50
|
+
width: 1,
|
|
51
|
+
height: '100%',
|
|
52
|
+
backgroundColor: 'white',
|
|
53
|
+
zIndex: 1
|
|
54
|
+
},
|
|
55
|
+
circleRow: {
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
justifyContent: 'space-between',
|
|
58
|
+
flexDirection: 'row',
|
|
59
|
+
},
|
|
60
|
+
circleColumn: {
|
|
61
|
+
// position: 'absolute',
|
|
62
|
+
justifyContent: 'space-between',
|
|
63
|
+
},
|
|
64
|
+
titleDefault: {
|
|
65
|
+
color: Colors.black_12
|
|
66
|
+
},
|
|
67
|
+
titleActive: {
|
|
68
|
+
color: Colors.black_17,
|
|
69
|
+
fontWeight: 'bold'
|
|
70
|
+
},
|
|
71
|
+
containerStyle: {
|
|
72
|
+
minHeight: CIRCLE_SIZE + 20 + CIRCLE_SIZE
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export default class Step extends Component {
|
|
77
|
+
constructor(props) {
|
|
78
|
+
super(props);
|
|
79
|
+
this.state = {
|
|
80
|
+
width: 0,
|
|
81
|
+
height: 0
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
onLayout = (e) => {
|
|
86
|
+
this.setState({ width: e.nativeEvent.layout.width, height: e.nativeEvent.layout.height });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
renderLine = () => {
|
|
90
|
+
const {
|
|
91
|
+
lineColor, lineStyle, currentStep, data
|
|
92
|
+
} = this.props;
|
|
93
|
+
return (
|
|
94
|
+
<View style={[styles.line, { borderColor: lineColor }, lineStyle]}>
|
|
95
|
+
{/* <View style={styles.topLeft} />
|
|
96
|
+
<View style={styles.topLeftWidth} />
|
|
97
|
+
<View style={styles.topRight} /> */}
|
|
98
|
+
</View>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
circle = (value, index) => {
|
|
103
|
+
const {
|
|
104
|
+
currentStep, tintColor, data, lineStyle, isNumber, iconActive,
|
|
105
|
+
iconInActive, lineColorActive, lineColorInActive, bodyStyle, iconStyle
|
|
106
|
+
} = this.props;
|
|
107
|
+
const { width } = this.state;
|
|
108
|
+
const icon = currentStep >= (index + 1) ? iconActive || IconSource.ic_step_active : iconInActive || IconSource.ic_step_coming;
|
|
109
|
+
const textFontStyle = currentStep >= (index + 1) ? styles.titleActive : styles.titleDefault;
|
|
110
|
+
const itemWidth = (width - CIRCLE_SIZE) / data?.length;
|
|
111
|
+
const lineActive = currentStep >= (index + 1) ? lineColorActive || isNumber ? 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
|
+
let left = 0;
|
|
115
|
+
let textAlignStyle = { textAlign: 'center' };
|
|
116
|
+
/**
|
|
117
|
+
* item lefr
|
|
118
|
+
*/
|
|
119
|
+
if (index === 0) {
|
|
120
|
+
left = 0;
|
|
121
|
+
textAlignStyle = { textAlign: 'left' };
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* item right
|
|
125
|
+
*/
|
|
126
|
+
} else if (index === data?.length - 1) {
|
|
127
|
+
left = -itemWidth + CIRCLE_SIZE;
|
|
128
|
+
textAlignStyle = { textAlign: 'right' };
|
|
129
|
+
/**
|
|
130
|
+
* center item
|
|
131
|
+
*/
|
|
132
|
+
} else { left = -itemWidth / 2 + CIRCLE_SIZE / 2; }
|
|
133
|
+
const textStyle = [textAlignStyle, textFontStyle];
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<View key={index}>
|
|
137
|
+
{
|
|
138
|
+
data?.length - 1 !== index && (
|
|
139
|
+
<View style={[styles.line, {
|
|
140
|
+
position: 'absolute',
|
|
141
|
+
top: 10,
|
|
142
|
+
backgroundColor: lineActive,
|
|
143
|
+
width: lineWidth,
|
|
144
|
+
height: 4,
|
|
145
|
+
marginTop: 0
|
|
146
|
+
}, lineStyle]}
|
|
147
|
+
/>
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
{
|
|
151
|
+
isNumber ? (
|
|
152
|
+
<View style={{
|
|
153
|
+
width: CIRCLE_SIZE,
|
|
154
|
+
height: CIRCLE_SIZE,
|
|
155
|
+
borderRadius: CIRCLE_SIZE / 2,
|
|
156
|
+
backgroundColor: backgroundActive,
|
|
157
|
+
borderColor: Colors.pink_09,
|
|
158
|
+
borderWidth: 1,
|
|
159
|
+
alignItems: 'center',
|
|
160
|
+
justifyContent: 'center'
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
<Text.SubTitle style={{ color: 'white' }} weight="bold">{index + 1}</Text.SubTitle>
|
|
164
|
+
</View>
|
|
165
|
+
) : <Image source={icon} style={[styles.circle, { tintColor }, iconStyle]} />
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
<View style={{
|
|
169
|
+
position: 'absolute',
|
|
170
|
+
width: itemWidth,
|
|
171
|
+
left,
|
|
172
|
+
top: CIRCLE_SIZE + CIRCLE_SIZE / 4
|
|
173
|
+
}}
|
|
174
|
+
>
|
|
175
|
+
<Text.Caption style={[textStyle, bodyStyle]}>{value}</Text.Caption>
|
|
176
|
+
</View>
|
|
177
|
+
</View>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
circleColumn = (value, index) => {
|
|
182
|
+
const {
|
|
183
|
+
currentStep, tintColor, data, lineStyle, isNumber, iconActive,
|
|
184
|
+
iconInActive, lineColorActive, lineColorInActive, bodyStyle, iconStyle
|
|
185
|
+
} = this.props;
|
|
186
|
+
const { height } = this.state;
|
|
187
|
+
const icon = currentStep >= (index + 1) ? iconActive || IconSource.ic_step_active : iconInActive || IconSource.ic_step_coming;
|
|
188
|
+
const textFontStyle = currentStep >= (index + 1) ? styles.titleActive : styles.titleDefault;
|
|
189
|
+
const itemWidth = (height - CIRCLE_SIZE) / data?.length;
|
|
190
|
+
const lineActive = currentStep >= (index + 1) ? lineColorActive || isNumber ? Colors.pink_09 : Colors.sepia_05 : lineColorInActive || Colors.black_02;
|
|
191
|
+
const lineWidth = (height - CIRCLE_SIZE) / (data.length - 1);
|
|
192
|
+
const backgroundActive = currentStep >= (index + 1) ? Colors.pink_05_b : Colors.black_09;
|
|
193
|
+
let left = 0;
|
|
194
|
+
let textAlignStyle = { textAlign: 'center' };
|
|
195
|
+
/**
|
|
196
|
+
* item lefr
|
|
197
|
+
*/
|
|
198
|
+
if (index === 0) {
|
|
199
|
+
left = 0;
|
|
200
|
+
textAlignStyle = { textAlign: 'left' };
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* item right
|
|
204
|
+
*/
|
|
205
|
+
} else if (index === data?.length - 1) {
|
|
206
|
+
left = -itemWidth + CIRCLE_SIZE;
|
|
207
|
+
textAlignStyle = { textAlign: 'right' };
|
|
208
|
+
/**
|
|
209
|
+
* center item
|
|
210
|
+
*/
|
|
211
|
+
} else { left = -itemWidth / 2 + CIRCLE_SIZE / 2; }
|
|
212
|
+
const textStyle = [textAlignStyle, textFontStyle];
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
<View key={index}>
|
|
216
|
+
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
217
|
+
{
|
|
218
|
+
isNumber ? (
|
|
219
|
+
<View style={{
|
|
220
|
+
width: CIRCLE_SIZE,
|
|
221
|
+
height: CIRCLE_SIZE,
|
|
222
|
+
borderRadius: CIRCLE_SIZE / 2,
|
|
223
|
+
backgroundColor: backgroundActive,
|
|
224
|
+
borderColor: Colors.pink_09,
|
|
225
|
+
borderWidth: 1,
|
|
226
|
+
alignItems: 'center',
|
|
227
|
+
justifyContent: 'center'
|
|
228
|
+
}}
|
|
229
|
+
>
|
|
230
|
+
{
|
|
231
|
+
iconActive ? <Image source={iconActive} style={[styles.circle, { tintColor }, iconStyle]} /> : <Text.SubTitle style={{ color: 'white' }} weight="bold">{index + 1}</Text.SubTitle>
|
|
232
|
+
}
|
|
233
|
+
</View>
|
|
234
|
+
) : <Image source={icon} style={[styles.circle, { tintColor }, iconStyle]} />
|
|
235
|
+
}
|
|
236
|
+
<Text.Caption style={[{ marginLeft: 10 }, textStyle, bodyStyle]}>{value}</Text.Caption>
|
|
237
|
+
</View>
|
|
238
|
+
|
|
239
|
+
{
|
|
240
|
+
data?.length - 1 !== index && (
|
|
241
|
+
<View style={[styles.line, {
|
|
242
|
+
left: 10,
|
|
243
|
+
backgroundColor: lineActive,
|
|
244
|
+
width: 4,
|
|
245
|
+
height: lineWidth,
|
|
246
|
+
marginTop: 0,
|
|
247
|
+
}, lineStyle]}
|
|
248
|
+
/>
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
</View>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
renderCircle = () => {
|
|
257
|
+
const { data = [], isVertical } = this.props;
|
|
258
|
+
return data.map(isVertical ? this.circleColumn : this.circle);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
render() {
|
|
262
|
+
const { width, height } = this.state;
|
|
263
|
+
const { style, isVertical } = this.props;
|
|
264
|
+
return (
|
|
265
|
+
<View style={[styles.containerStyle, style]} onLayout={this.onLayout}>
|
|
266
|
+
{/* {this.renderLine()} */}
|
|
267
|
+
{
|
|
268
|
+
isVertical ? (
|
|
269
|
+
<View style={[styles.circleColumn, { height }]}>
|
|
270
|
+
{this.renderCircle()}
|
|
271
|
+
</View>
|
|
272
|
+
) : (
|
|
273
|
+
<View style={[styles.circleRow, { width }]}>
|
|
274
|
+
{this.renderCircle()}
|
|
275
|
+
</View>
|
|
276
|
+
)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
</View>
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
Step.propTypes = {
|
|
285
|
+
data: PropTypes.arrayOf(PropTypes.string),
|
|
286
|
+
currentStep: PropTypes.number,
|
|
287
|
+
tintColor: PropTypes.string,
|
|
288
|
+
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
289
|
+
isNumber: PropTypes.bool,
|
|
290
|
+
isVertical: PropTypes.bool,
|
|
291
|
+
iconActive: PropTypes.any,
|
|
292
|
+
iconInActive: PropTypes.any,
|
|
293
|
+
lineColorActive: PropTypes.string,
|
|
294
|
+
lineColorInActive: PropTypes.string,
|
|
295
|
+
bodyStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
Step.defaultProps = {
|
|
299
|
+
data: [],
|
|
300
|
+
currentStep: 0,
|
|
301
|
+
tintColor: Colors.sepia_05
|
|
302
|
+
};
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@momo-kits/step",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"dependencies": {},
|
|
7
|
+
"peerDependencies": {
|
|
8
|
+
"react-native": ">=0.55",
|
|
9
|
+
"prop-types": "^15.7.2",
|
|
10
|
+
"react": "16.9.0",
|
|
11
|
+
"@momo-kits/core": ">=0.0.5-beta"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {},
|
|
14
|
+
"license": "MoMo"
|
|
15
|
+
}
|
package/publish.sh
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
rm -rf dist
|
|
3
|
+
mkdir dist
|
|
4
|
+
|
|
5
|
+
cp . ./dist
|
|
6
|
+
|
|
7
|
+
# GET VERSION from mck_package.json
|
|
8
|
+
VERSIONSTRING=( v$(jq .version package.json) )
|
|
9
|
+
VERSION=(${VERSIONSTRING//[\"]/})
|
|
10
|
+
echo VERSION: $VERSION
|
|
11
|
+
|
|
12
|
+
rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
|
|
13
|
+
|
|
14
|
+
# #babel component to dist
|
|
15
|
+
#babel ./dist -d dist --copy-files
|
|
16
|
+
|
|
17
|
+
#copy option
|
|
18
|
+
#cp -r ./src/ dist
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
#npm login
|
|
22
|
+
#publish dist to npm
|
|
23
|
+
cd dist
|
|
24
|
+
npm publish --access=public
|
|
25
|
+
cd ..
|
|
26
|
+
rm -rf dist
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/step new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/step"}'
|