-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathCommonIconButton.js
89 lines (76 loc) · 2.25 KB
/
CommonIconButton.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
/**
* Created by guoshuyu on 2017/11/10.
*/
import React, {Component} from 'react';
import {
View, Text, TouchableOpacity
} from 'react-native';
import PropTypes from 'prop-types';
import {Router, Actions, Scene} from 'react-native-router-flux';
import styles from "../../style/index"
import I18n from '../../style/i18n'
import * as Constant from '../../style/constant'
import Icon from 'react-native-vector-icons/FontAwesome'
import Icon2 from 'react-native-vector-icons/Ionicons'
import Icon3 from 'react-native-vector-icons/MaterialCommunityIcons'
/**
* 通用icon按键
*/
class CommonIconButton extends Component {
static propTypes = {
rightBtn: PropTypes.string,
needRightBtn: PropTypes.bool,
rightBtnPress: PropTypes.func
};
constructor(props) {
super(props);
}
componentDidMount() {
}
componentWillUnmount() {
}
render() {
this.local = this.props;
if (this.props.data) {
this.local = this.props.data;
}
if (!this.local || !this.local.needRightBtn) {
return <View/>
}
let icon = <View/>;
switch (this.local.iconType) {
case 3:
icon = <Icon3 name={this.local.rightBtn} size={20} color={Constant.miWhite}/>
break;
case 2:
icon = <Icon2 name={this.local.rightBtn} size={20} color={Constant.miWhite}/>
break;
case 1:
default:
icon = <Icon name={this.local.rightBtn} size={20} color={Constant.miWhite}/>
break;
}
return (
<TouchableOpacity
style={[styles.centered, {
marginRight: Constant.normalMarginEdge,
paddingLeft: 20
}]}
onPress={() => {
this.local.rightBtnPress && this.local.rightBtnPress(this.local);
}}>
{icon}
</TouchableOpacity>
)
}
}
CommonIconButton.propTypes = {
rightBtn: PropTypes.string,
iconType: PropTypes.number,
needRightBtn: PropTypes.bool,
rightBtnPress: PropTypes.func
};
CommonIconButton.defaultProps = {
iconType: 1,
};
export default CommonIconButton