forked from ant-design/ant-design-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStepsItem.tsx
105 lines (95 loc) · 3.16 KB
/
StepsItem.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import * as React from 'react';
import { View, Text, Image } from 'react-native';
import styles from './style';
export interface StepsItemProps {
width?: number;
size?: string;
current?: number;
index?: number;
last?: boolean;
direction?: string;
title?: string;
description?: string;
status?: string;
icon?: string;
errorTail?: number;
}
export default class StepsItem extends React.Component<StepsItemProps, any> {
render() {
const { size, current, index, last, title, description,
status, errorTail, icon } = this.props;
let iconImg;
let headCls;
let tailTopCls;
let tailBottomCls;
const sizeCls = size === 'small' ? '_s' : '_l';
if (index < current || status === 'finish') {
iconImg = 'check';
headCls = `head_blue${sizeCls}`;
tailTopCls = 'tail_blue';
tailBottomCls = 'tail_blue';
} else if (index === current || status === 'process') {
iconImg = 'check';
headCls = `head_blue${sizeCls}`;
tailTopCls = 'tail_blue';
tailBottomCls = 'tail_gray';
} else if (index > current || status === 'wait') {
iconImg = 'more';
headCls = `head_gray${sizeCls}`;
tailTopCls = 'tail_gray';
tailBottomCls = 'tail_gray';
} else if (status === 'error') {
iconImg = 'error';
headCls = `head_red${sizeCls}`;
tailTopCls = 'tail_gray';
tailBottomCls = 'tail_gray';
}
if (last) {
tailTopCls = 'tail_last';
tailBottomCls = 'tail_last';
}
if (errorTail > -1) {
tailBottomCls = 'tail_error';
}
let iconSource;
if (size === 'small') {
if (index < current || status === 'finish' || index === current || status === 'process') {
iconSource = require('../style/images/check.png');
} else if (index > current || status === 'wait') {
iconSource = require('../style/images/more.png');
} else if (status === 'error') {
iconSource = require('../style/images/cross.png');
}
} else {
if (index < current || status === 'finish' || index === current || status === 'process') {
iconSource = require('../style/images/check_w.png');
} else if (index > current || status === 'wait') {
iconSource = require('../style/images/more_w.png');
if (!!icon) {
iconSource = icon;
}
} else if (status === 'error') {
iconSource = require('../style/images/cross_w.png');
}
}
return (
<View style={{flex:1, flexDirection: 'row'}}>
<View style={{ flexDirection: 'column'}}>
<View style={[styles[`head_default${sizeCls}`], styles[headCls]]}>
<Image source={iconSource} style={styles[`icon${sizeCls}`]} />
</View>
{
<View style={[styles[`tail_default${sizeCls}`], styles[tailTopCls]]} />
}
{
<View style={[styles[`tail_default${sizeCls}`], styles[tailBottomCls]]} />
}
</View>
<View style={styles[`content${sizeCls}`]}>
<Text style={[styles[`title${sizeCls}`]]}>{ title }</Text>
<Text style={[styles[`description${sizeCls}`]]}>{ description }</Text>
</View>
</View>
);
}
}