diff --git a/NumericInput/NumericInput.js b/NumericInput/NumericInput.js index 29255483..fe3a4bf8 100644 --- a/NumericInput/NumericInput.js +++ b/NumericInput/NumericInput.js @@ -1,5 +1,5 @@ import React, { Component } from 'react' -import { View, TextInput, StyleSheet, Text } from 'react-native' +import { View, TextInput, StyleSheet, Text, Platform } from 'react-native' import Icon from 'react-native-vector-icons/Ionicons' import Button from '../Button' import PropTypes from 'prop-types' @@ -71,6 +71,7 @@ export default class NumericInput extends Component { intMatch = (value) => value && value.match(/-?\d+/) && value.match(/-?\d+/)[0] === value.match(/-?\d+/).input onChange = (value) => { + value = value.replace(",", "."); let currValue = typeof this.props.value === 'number' ? this.props.value : this.state.value if ((value.length === 1 && value === '-') || (value.length === 2 && value === '0-')) { this.setState({ stringValue: '-' }) @@ -127,10 +128,10 @@ export default class NumericInput extends Component { let legal = match && match[0] === match.input && ((this.props.maxValue === null || (parseFloat(this.state.stringValue) <= this.props.maxValue)) && (this.props.minValue === null || (parseFloat(this.state.stringValue) >= this.props.minValue))) if (!legal) { if (this.props.minValue !== null && (parseFloat(this.state.stringValue) <= this.props.minValue)) { - this.props.onLimitReached(true, 'Reached Minimum Value!') + this.props.onLimitReached(false, 'Reached Minimum Value!') } if (this.props.maxValue !== null && (parseFloat(this.state.stringValue) >= this.props.maxValue)) { - this.props.onLimitReached(false, 'Reached Maximum Value!') + this.props.onLimitReached(true, 'Reached Maximum Value!') } if (this.ref) { this.ref.blur() @@ -218,7 +219,7 @@ export default class NumericInput extends Component { if (this.props.type === 'up-down') return ( - this.ref = ref} onBlur={this.onBlur} onFocus={this.onFocus} /> + this.ref = ref} onBlur={this.onBlur} onFocus={this.onFocus} /> - this.ref = ref} onBlur={this.onBlur} onFocus={this.onFocus} /> + this.ref = ref} onBlur={this.onBlur} onFocus={this.onFocus} />