Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add props size for radio dot and style for radio & item, #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions lib/radioButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export default class RadioButton extends Component{

getRadioDotStyle(){
return {
height: this.context.size / 2,
width: this.context.size / 2,
borderRadius: this.context.size / 4,
height: this.props.dotSize ? this.props.dotSize : this.context.size / 2,
width: this.props.dotSize ? this.props.dotSize : this.context.size / 2,
borderRadius: this.props.dotBorderSize ? this.props.dotBorderSize : this.context.size / 4,
backgroundColor: this.props.color || this.props.activeColor,
}
}
Expand All @@ -50,10 +50,10 @@ export default class RadioButton extends Component{
onPress={() => this.context.onSelect(this.props.index, this.props.value)}
>
<View style={[styles.container, this.props.style, this.props.isSelected?{backgroundColor: this.context.highlightColor}:null]}>
<View style={[styles.radio, this.getRadioStyle()]}>
<View style={[styles.radio, this.getRadioStyle(), this.props.radioStyle]}>
{this.isSelected()}
</View>
<View style={styles.item}>
<View style={[styles.item, this.props.itemStyle]}>
{children}
</View>
</View>
Expand All @@ -68,7 +68,11 @@ RadioButton.contextTypes = {
size: PropTypes.number.isRequired,
thickness: PropTypes.number.isRequired,
color: PropTypes.string.isRequired,
highlightColor: PropTypes.string
highlightColor: PropTypes.string,
dotSize: PropTypes.number,
dotBorderSize: PropTypes.number,
radioStyle: PropTypes.object,
itemStyle: PropTypes.object
}

let styles = StyleSheet.create({
Expand Down