Skip to content

Commit

Permalink
try of bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
himelbrand committed Jul 21, 2019
1 parent 596c385 commit 80485fa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
18 changes: 17 additions & 1 deletion Example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class App extends Component {
v6: 0,
v7: 0,
v8: 0,
value1: 1
}
this.amount = 0
}
Expand All @@ -43,7 +44,22 @@ export default class App extends Component {
<Text style={styles.welcome}>
Numeric Input Examples
</Text>

<NumericInput
value={this.state.value1}
onChange={value1 => { this.setState({ value1 }); console.log(this.state.value1); }}
onLimitReached={(isMin, msg) => console.log(isMin, msg)}
totalWidth={80}
totalHeight={30}
iconSize={10}
step={1}
minValue={0}
valueType="real"
rounded editable={false}
textColor="#B0228C"
iconStyle={{ color: "white" }}
rightButtonBackgroundColor="#18c2ef"
leftButtonBackgroundColor="#ff8080"
/>
<NumericInput
// initValue={this.state.v1}
value={this.state.v1}
Expand Down
3 changes: 1 addition & 2 deletions NumericInput/NumericInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ export default class NumericInput extends Component {
if (this.props.minValue === null || (value - this.props.step > this.props.minValue)) {
value = (value - this.props.step).toFixed(12)
value = this.props.valueType === 'real' ? parseFloat(value) : parseInt(value)
this.setState({ value, stringValue: value.toString() })
} else if (this.props.minValue !== null) {
this.props.onLimitReached(false, 'Reached Minimum Value!')
value = this.props.minValue
this.setState({ value, stringValue: value.toString() })
}
if (value !== this.props.value)
this.props.onChange && this.props.onChange(Number(value))
this.setState({ value, stringValue: value.toString() })
}
isLegalValue = (value, mReal, mInt) => value === '' || (((this.props.valueType === 'real' && mReal(value)) || (this.props.valueType !== 'real' && mInt(value))) && (this.props.maxValue === null || (parseFloat(value) <= this.props.maxValue)) && (this.props.minValue === null || (parseFloat(value) >= this.props.minValue)))

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-numeric-input",
"version": "1.8.1",
"version": "1.8.2",
"description": "a stylish numeric input for react native",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 80485fa

Please sign in to comment.