LatestHeader.js
2.67 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
'use strict';
import React, {Component} from 'react';
import ReactNative from 'react-native';
const {
View,
Text,
StyleSheet,
Dimensions,
TouchableOpacity,
} = ReactNative;
export default class LatestHeader extends Component {
constructor(props) {
super(props);
}
render() {
let {dataSource, selectIndex} = this.props
dataSource = dataSource.toJS();
if (dataSource.length == 0) {
return null;
}
return(
<View style={styles.container}>
<View style={styles.content}>
{
dataSource.map((item ,index) =>{
let last = !(index == dataSource.length-1);
let selected = index == selectIndex;
let kColor = selected ? '#444444' : '#b0b0b0';
let kWidth = width/dataSource.length;
return (
<TouchableOpacity
activeOpacity={1}
onPress={()=>{
this.props.onPressItem&&this.props.onPressItem(item, index)
}}
key={index}
>
<View style={styles.item}>
<Text style={[styles.text,{width:kWidth, color:kColor}]}> {item.name} </Text>
{
last ? <View style={styles.line}/> : null
}
</View>
</TouchableOpacity>
)
})
}
</View>
<View style={styles.bottom}>
</View>
</View>
)
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flexDirection: 'column',
width,
backgroundColor: 'white',
height: 45,
},
content: {
flexDirection: 'row',
width
},
item: {
flexDirection: 'row',
backgroundColor: 'white',
height: 45
},
text: {
fontSize: 15,
color: '#b0b0b0',
textAlign: 'center',
paddingTop: 15
},
bottom: {
height: 0.5,
backgroundColor: '#e5e5e5',
width
},
line: {
width: 0.5,
height: 20,
backgroundColor: '#e0e0e0',
alignSelf: 'center',
}
});