-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathCommonInputBar.js
87 lines (74 loc) · 2.46 KB
/
CommonInputBar.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
import React, {Component} from 'react';
import {
View, Text, TouchableOpacity, ScrollView
} from 'react-native';
import PropTypes from 'prop-types';
import styles from "../../style/index"
import * as Constant from "../../style/constant"
import IconC from 'react-native-vector-icons/Octicons'
import IconC2 from 'react-native-vector-icons/MaterialCommunityIcons'
/**
* 通用输入框的快捷按键
*/
class CommonInputBar extends Component {
constructor(props) {
super(props);
this.renderItem = this.renderItem.bind(this);
}
componentDidMount() {
}
componentWillUnmount() {
}
renderItem(data) {
let iconColor = data.iconColor ? data.iconColor : Constant.primaryColor;
let icon = <View/>;
switch (data.iconType) {
case 1:
icon = <IconC name={(data.icon) ? data.icon : "bell"}
backgroundColor={Constant.transparentColor}
color={(data.icon) ? iconColor : Constant.transparentColor}
size={data.iconSize}/>;
break;
case 2:
icon = <IconC2 name={(data.icon) ? data.icon : "bell"}
backgroundColor={Constant.transparentColor}
color={(data.icon) ? iconColor : Constant.transparentColor}
size={data.iconSize}/>;
break;
}
return (
<TouchableOpacity style={[{height: 40, width: 40}, styles.centerH, data.itemStyle]}
onPress={() => {
data.itemClick && data.itemClick(data);
}}
key={data.icon}>
{icon}
</TouchableOpacity>
)
}
render() {
let {dataList, rootStyles} = this.props;
let items = [];
dataList.forEach((data) => {
items.push(this.renderItem(data))
});
return (
<View style={[{height: 40}, this.props.rootStyles]}>
<ScrollView
horizontal={true}>
{items}
</ScrollView>
</View>
)
}
}
CommonInputBar.propTypes = {
dataList: PropTypes.array,
rootStyles: PropTypes.any,
inputView: PropTypes.any,
};
CommonInputBar.defaultProps = {
dataList: [],
rootStyles: {}
};
export default CommonInputBar