Skip to content

Commit

Permalink
Merge pull request #3 from risuiar/master
Browse files Browse the repository at this point in the history
add ability to add own styles to left and right texts.
  • Loading branch information
crazycodeboy authored Nov 9, 2016
2 parents 8fc88e2 + 24e3fd9 commit b530984
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export default class CheckBox extends Component {
leftText: React.PropTypes.string,
leftTextView: React.PropTypes.element,
rightText: React.PropTypes.string,
leftTextStyle: React.PropTypes.object,
rightTextView: React.PropTypes.string,
rightTextStyle: React.PropTypes.object,
checkedImage: React.PropTypes.element,
unCheckedImage: React.PropTypes.element,
onClick: React.PropTypes.func.isRequired,
Expand All @@ -39,20 +41,22 @@ export default class CheckBox extends Component {
}
static defaultProps = {
isChecked: false,
leftTextStyle: {},
rightTextStyle: {}
}

_renderLeft() {
if (this.props.leftTextView)return this.props.leftTextView;
if (!this.props.leftText)return null;
return (
<Text style={styles.leftText}>{this.props.leftText}</Text>
<Text style={[styles.leftText, this.props.leftTextStyle]}>{this.props.leftText}</Text>
)
}
_renderRight() {
if (this.props.rightTextView)return this.props.rightTextView;
if (!this.props.rightText)return null;
return (
<Text style={styles.rightText}>{this.props.rightText}</Text>
<Text style={[styles.rightText, this.props.rightTextStyle]}>{this.props.rightText}</Text>
)
}

Expand Down

0 comments on commit b530984

Please sign in to comment.