-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathTrendPickerItem.js
117 lines (106 loc) · 3.86 KB
/
TrendPickerItem.js
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
110
111
112
113
114
115
116
117
import React, {Component} from 'react';
import {
View, Text, TouchableHighlight, StyleSheet
} from 'react-native';
import styles, {screenWidth} from "../../style"
import * as Constant from "../../style/constant"
import I18n from '../../style/i18n'
import ModalDropdown from '../common/ModalDropdown';
import PropTypes from 'prop-types';
import Icon from 'react-native-vector-icons/Ionicons'
/**
* 趋势数据过滤Item
*/
class TrendPickerItem extends Component {
constructor(props) {
super(props);
this.state = {
icon:'md-arrow-dropdown'
}
}
componentDidMount() {
}
componentWillUnmount() {
}
render() {
return (
<View style={styles.flexDirectionRow}>
<ModalDropdown
style={this.props.style}
adjustFrame={this.props.adjustFrame}
textStyle={this.props.textStyle}
dropdownStyle={this.props.dropdownStyle}
options={this.props.options}
onSelect={(rowID, rowData) => {
this.props.onSelect && this.props.onSelect(rowID, rowData);
return true
}}
defaultIndex={this.props.defaultIndex}
defaultValue={this.props.defaultValue}
onDropdownWillShow={()=>{
this.setState({
icon:'md-arrow-dropup'
})
}}
onDropdownWillHide={()=>{
this.setState({
icon:'md-arrow-dropdown'
})
}}
renderRow={this.renderRow.bind(this)}
renderSeparator={(sectionID, rowID, adjacentRowHighlighted) => this.renderSeparator(sectionID, rowID, adjacentRowHighlighted)}
/>
<View style={[{
backgroundColor: Constant.transparentColor,
position: "absolute",
left: screenWidth / 3,
right: 0,
top: 0,
bottom: 0,
}, styles.centerV]}>
<Icon name={this.state.icon} size={20} color={Constant.mainTextColor}/>
</View>
</View>
);
}
renderRow(rowData, rowID, highlighted) {
let evenRow = rowID % 2;
return (
<TouchableHighlight underlayColor='cornflowerblue'>
<View
style={[{
flexDirection: 'row',
flex: 1,
paddingHorizontal: Constant.normalMarginEdge,
height: this.props.itemHeight,
}, {backgroundColor: Constant.white}, styles.centerH]}>
<Text style={[styles.middleText, {
marginHorizontal: 4,
textAlignVertical: 'center',
}, highlighted && {color: Constant.selectedColor}, styles.centered]}>
{I18n(rowData.name)}
</Text>
</View>
</TouchableHighlight>
);
}
renderSeparator(sectionID, rowID, adjacentRowHighlighted) {
if (rowID === this.props.options.length - 1) return;
let key = `spr_${rowID}`;
return (
<View style={{height: StyleSheet.hairlineWidth, backgroundColor: Constant.lineColor,}}
key={key}/>
);
}
}
TrendPickerItem.propTypes = {
itemHeight: PropTypes.number,
defaultIndex: PropTypes.number,
defaultValue: PropTypes.string,
options: PropTypes.array,
dropdownStyle: PropTypes.any,
textStyle: PropTypes.any,
adjustFrame: PropTypes.any,
onSelect: PropTypes.func,
};
export default TrendPickerItem