diff --git a/components/cycle-day/symptoms/temperature.js b/components/cycle-day/symptoms/temperature.js index f8d2bcb..966a227 100644 --- a/components/cycle-day/symptoms/temperature.js +++ b/components/cycle-day/symptoms/temperature.js @@ -49,48 +49,16 @@ export default class Temp extends Component { } } - checkRange = () => { - const value = Number(`${this.state.integer}.${this.state.fractional}`) - if (isNaN(value)) return - const scale = scaleObservable.value - if (value < scale.min || value > scale.max) { - Alert.alert( - shared.warning, - tempLabels.outOfRangeWarning, - ) - } - } - render() { return ( Temperature (°C) - - { - if (isNaN(Number(val))) return - this.setState({ integer: val }) - }} - keyboardType='numeric' - value={this.state.integer} - maxLength={2} - /> - . - { - if (isNaN(Number(val))) return - this.setState({ fractional: val }) - }} - keyboardType='numeric' - value={this.state.fractional} - onBlur={this.checkRange} - maxLength={2} - autoFocus={true} - /> - + this.setState(val)} + /> Time @@ -148,6 +116,58 @@ export default class Temp extends Component { } } +class TempInputPair extends Component { + render() { + return ( + + + . + + + ) + } +} +class TempInput extends Component { + checkRange = () => { + const value = Number(`${this.props.integer}.${this.props.fractional}`) + if (isNaN(value)) return + const scale = scaleObservable.value + if (value < scale.min || value > scale.max) { + Alert.alert( + shared.warning, + tempLabels.outOfRangeWarning, + ) + } + } + + render() { + return ( + { + if (isNaN(Number(val))) return + this.props.setState({ [this.props.type]: val }) + }} + keyboardType='numeric' + value={this.props[this.props.type]} + onBlur={this.checkRange} + maxLength={2} + autoFocus={this.props.type === 'fractional'} + /> + ) + } +} + function isInvalidTime(timeString) { try { LocalTime.parse(timeString)