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

New options to change the increment and decrement characters and provide text suffix. #6

Open
wants to merge 3 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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -52,6 +52,9 @@ btnFontSize | custom fontSize of buttons in the Spinner | number | 14 |
buttonTextColor | custom color of the button in the Spinner | string | 'white' |
width | custom width of the Spinner | number | 90 |
height | custom height of the Spinner | number | 30 |
decChar | custom character to use for the decrement button | string | '-' |
incChar | custom character to use for the increment button | string | '+' |
suffix | suffix string added after the number. For example F for Farenheit | string | '' |

## Screenshot

16 changes: 11 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -24,7 +24,10 @@ var Spinner = React.createClass({
buttonTextColor: PropTypes.string,
disabled: PropTypes.bool,
width: PropTypes.number,
height: PropTypes.number
height: PropTypes.number,
incChar: PropTypes.string,
decChar: PropTypes.string,
suffix: PropTypes.string
},

getDefaultProps () {
@@ -41,7 +44,10 @@ var Spinner = React.createClass({
buttonTextColor: 'white',
disabled: false,
width: 90,
height: 30
height: 30,
incChar: '+',
decChar: '-',
suffix: ''
}
},

@@ -117,12 +123,12 @@ var Spinner = React.createClass({
{ height: this.props.height } ]}
onPress={this._decrease}>
<Text style={[styles.btnText,
{ color: this.props.buttonTextColor, fontSize: this.props.btnFontSize }]}>-</Text>
{ color: this.props.buttonTextColor, fontSize: this.props.btnFontSize }]}>{this.props.decChar}</Text>
</TouchableOpacity>
<View style={[styles.num,
{ borderColor: this.props.showBorder ? this.props.color : 'transparent', backgroundColor: this.props.numBgColor, height: this.props.height
}]}>
<Text style={[styles.numText, {color: this.props.numColor, fontSize: this.props.fontSize}]}>{this.state.num}</Text>
<Text style={[styles.numText, {color: this.props.numColor, fontSize: this.props.fontSize}]}>{this.state.num}{this.props.suffix}</Text>
</View>
<TouchableOpacity
style={[styles.btn,
@@ -132,7 +138,7 @@ var Spinner = React.createClass({
onPress={this._increase}>
<Text style={[styles.btnText,
{ color: this.props.buttonTextColor, fontSize: this.props.btnFontSize
}]}>+</Text>
}]}>{this.props.incChar}</Text>
</TouchableOpacity>
</View>
)