1- /**
1+ /**
22 * react-native-check-box
33 * Checkbox component for react native, it works on iOS and Android
44 * https://github.com/crazycodeboy/react-native-check-box
@@ -29,6 +29,8 @@ export default class CheckBox extends Component {
2929 ...View . propTypes ,
3030 leftText : React . PropTypes . string ,
3131 leftTextView : React . PropTypes . element ,
32+ rightText : React . PropTypes . string ,
33+ rightTextView : React . PropTypes . string ,
3234 checkedImage : React . PropTypes . element ,
3335 unCheckedImage : React . PropTypes . element ,
3436 onClick : React . PropTypes . func . isRequired ,
@@ -46,6 +48,13 @@ export default class CheckBox extends Component {
4648 < Text style = { styles . leftText } > { this . props . leftText } </ Text >
4749 )
4850 }
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+ }
4958
5059 _renderImage ( ) {
5160 if ( this . state . isChecked ) {
@@ -80,6 +89,7 @@ export default class CheckBox extends Component {
8089 < View style = { styles . container } >
8190 { this . _renderLeft ( ) }
8291 { this . _renderImage ( ) }
92+ { this . _renderRight ( ) }
8393 </ View >
8494 </ TouchableHighlight >
8595 )
@@ -89,10 +99,12 @@ const styles = StyleSheet.create({
8999 container : {
90100 flexDirection : 'row' ,
91101 alignItems : 'center'
92- // backgroundColor:'gray'
93102 } ,
94103 leftText : {
95104 flex : 1 ,
96- // backgroundColor:'red',
105+ } ,
106+ rightText : {
107+ flex : 1 ,
108+ marginLeft : 10
97109 }
98- } )
110+ } )
0 commit comments