TrendText.js
2.73 KB
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
106
107
108
109
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
Component,
} = React;
const {
View,
Text,
Image,
Platform,
StyleSheet,
} = ReactNative;
export default class TrendText extends Component {
static propTypes = {
topText: React.PropTypes.string,
bottomText: React.PropTypes.string,
smallText: React.PropTypes.string,
arrowUp: React.PropTypes.bool,
containerStyle: View.propTypes.style,
topTextStyle: View.propTypes.style,
bottomTextStyle: View.propTypes.style,
imageStyle: View.propTypes.style,
smallTextStyle: View.propTypes.style,
hasTrendData: React.PropTypes.bool,
};
renderTrendText() {
let arrow = this.props.arrowUp ? require('../images/arrow_up.png') : require('../images/arrow_down.png');
let bottomTextColor = this.props.arrowUp ? styles.bottomTextUp : styles.bottomTextDown;
if (this.props.hasTrendData) {
return (
<View style={styles.richContainer}>
<Image source={arrow} style={[styles.image, this.props.imageStyle]} />
<Text style={[styles.bottomText, bottomTextColor, this.props.bottomTextStyle]}>{this.props.bottomText}</Text>
<Text style={[styles.smallText, this.props.smallTextStyle]}>{this.props.smallText}</Text>
</View>
);
} else {
return (
<View style={styles.richContainer}>
<Text style={[styles.bottomText, bottomTextColor, this.props.bottomTextStyle]}>--</Text>
</View>
);
}
}
render() {
return (
<View style={[styles.container, this.props.containerStyle]}>
<Text style={[styles.topText, this.props.topTextStyle]}>{this.props.topText}</Text>
{this.renderTrendText()}
</View>
);
}
}
let styles = StyleSheet.create({
container: {
},
topText: {
fontSize: 14,
color: '#444444',
textAlign: 'center',
lineHeight: 20,
marginTop: 15,
marginBottom: 10,
},
richContainer: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignSelf: 'center',
alignItems: 'center',
marginBottom: 15,
},
image: {
// width: 9,
// height: 12,
},
bottomText: {
fontSize: 17,
fontWeight: 'bold',
textAlign: 'center',
},
bottomTextUp: {
color: '#D0021B',
},
bottomTextDown: {
color: '#86BF4A',
},
smallText: {
fontSize: 12,
textAlign: 'center',
color: '#444444',
},
});