1
- /**
1
+ /**
2
2
* react-native-check-box
3
3
* Checkbox component for react native, it works on iOS and Android
4
4
* https://github.com/crazycodeboy/react-native-check-box
@@ -29,6 +29,8 @@ export default class CheckBox extends Component {
29
29
...View . propTypes ,
30
30
leftText : React . PropTypes . string ,
31
31
leftTextView : React . PropTypes . element ,
32
+ rightText : React . PropTypes . string ,
33
+ rightTextView : React . PropTypes . string ,
32
34
checkedImage : React . PropTypes . element ,
33
35
unCheckedImage : React . PropTypes . element ,
34
36
onClick : React . PropTypes . func . isRequired ,
@@ -46,6 +48,13 @@ export default class CheckBox extends Component {
46
48
< Text style = { styles . leftText } > { this . props . leftText } </ Text >
47
49
)
48
50
}
51
+ _renderRight ( ) {
52
+ if ( this . props . rightTextView ) return this . props . rightTextView ;
53
+ if ( ! this . props . rightText ) return null ;
54
+ return (
55
+ < Text style = { styles . rightText } > { this . props . rightText } </ Text >
56
+ )
57
+ }
49
58
50
59
_renderImage ( ) {
51
60
if ( this . state . isChecked ) {
@@ -80,6 +89,7 @@ export default class CheckBox extends Component {
80
89
< View style = { styles . container } >
81
90
{ this . _renderLeft ( ) }
82
91
{ this . _renderImage ( ) }
92
+ { this . _renderRight ( ) }
83
93
</ View >
84
94
</ TouchableHighlight >
85
95
)
@@ -89,10 +99,12 @@ const styles = StyleSheet.create({
89
99
container : {
90
100
flexDirection : 'row' ,
91
101
alignItems : 'center'
92
- // backgroundColor:'gray'
93
102
} ,
94
103
leftText : {
95
104
flex : 1 ,
96
- // backgroundColor:'red',
105
+ } ,
106
+ rightText : {
107
+ flex : 1 ,
108
+ marginLeft : 10
97
109
}
98
- } )
110
+ } )
0 commit comments