Skip to content

Commit b530984

Browse files
authored
Merge pull request #3 from risuiar/master
add ability to add own styles to left and right texts.
2 parents 8fc88e2 + 24e3fd9 commit b530984

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export default class CheckBox extends Component {
3030
leftText: React.PropTypes.string,
3131
leftTextView: React.PropTypes.element,
3232
rightText: React.PropTypes.string,
33+
leftTextStyle: React.PropTypes.object,
3334
rightTextView: React.PropTypes.string,
35+
rightTextStyle: React.PropTypes.object,
3436
checkedImage: React.PropTypes.element,
3537
unCheckedImage: React.PropTypes.element,
3638
onClick: React.PropTypes.func.isRequired,
@@ -39,20 +41,22 @@ export default class CheckBox extends Component {
3941
}
4042
static defaultProps = {
4143
isChecked: false,
44+
leftTextStyle: {},
45+
rightTextStyle: {}
4246
}
4347

4448
_renderLeft() {
4549
if (this.props.leftTextView)return this.props.leftTextView;
4650
if (!this.props.leftText)return null;
4751
return (
48-
<Text style={styles.leftText}>{this.props.leftText}</Text>
52+
<Text style={[styles.leftText, this.props.leftTextStyle]}>{this.props.leftText}</Text>
4953
)
5054
}
5155
_renderRight() {
5256
if (this.props.rightTextView)return this.props.rightTextView;
5357
if (!this.props.rightText)return null;
5458
return (
55-
<Text style={styles.rightText}>{this.props.rightText}</Text>
59+
<Text style={[styles.rightText, this.props.rightTextStyle]}>{this.props.rightText}</Text>
5660
)
5761
}
5862

0 commit comments

Comments
 (0)