Use time picker for time field

This commit is contained in:
Julia Friesel
2018-07-19 18:27:46 +02:00
parent 8afbaa485c
commit 44c31b197e
3 changed files with 69 additions and 5 deletions
+19 -5
View File
@@ -3,8 +3,10 @@ import {
View, View,
Text, Text,
TextInput, TextInput,
Switch Switch,
Keyboard
} from 'react-native' } from 'react-native'
import DateTimePicker from 'react-native-modal-datetime-picker-nevo'
import { getPreviousTemperature, saveSymptom } from '../../../db' import { getPreviousTemperature, saveSymptom } from '../../../db'
import styles from '../../../styles' import styles from '../../../styles'
@@ -30,7 +32,8 @@ export default class Temp extends Component {
this.state = { this.state = {
currentValue: initialValue, currentValue: initialValue,
exclude: temp ? temp.exclude : false, exclude: temp ? temp.exclude : false,
time: this.time || LocalTime.now().truncatedTo(ChronoUnit.MINUTES).toString() time: this.time || LocalTime.now().truncatedTo(ChronoUnit.MINUTES).toString(),
isTimePickerVisible: false
} }
} }
@@ -54,13 +57,24 @@ export default class Temp extends Component {
<Text style={styles.symptomDayView}>Time</Text> <Text style={styles.symptomDayView}>Time</Text>
<TextInput <TextInput
style={styles.temperatureTextInput} style={styles.temperatureTextInput}
onChangeText={(val) => { onFocus={() => {
this.setState({ time: val }) Keyboard.dismiss()
this.setState({isTimePickerVisible: true})
}} }}
keyboardType='numeric'
value={this.state.time} value={this.state.time}
/> />
</View> </View>
<DateTimePicker
mode="time"
isVisible={this.state.isTimePickerVisible}
onConfirm={jsDate => {
this.setState({
time: `${jsDate.getHours()}:${jsDate.getMinutes()}`,
isTimePickerVisible: false
})
}}
onCancel={() => this.setState({isTimePickerVisible: false})}
/>
<View style={styles.symptomViewRowInline}> <View style={styles.symptomViewRowInline}>
<Text style={styles.symptomDayView}>Exclude</Text> <Text style={styles.symptomDayView}>Exclude</Text>
<Switch <Switch
+49
View File
@@ -6250,6 +6250,14 @@
"yargs": "^9.0.0" "yargs": "^9.0.0"
} }
}, },
"react-native-animatable": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/react-native-animatable/-/react-native-animatable-1.3.0.tgz",
"integrity": "sha512-GGYEYvderfzPZcPnw7xov4nlRmi9d6oqcIzx0fGkUUsMshOQEtq5IEzFp3np0uTB9n8/gZIZcdbUPggVlVydMg==",
"requires": {
"prop-types": "^15.5.10"
}
},
"react-native-calendars": { "react-native-calendars": {
"version": "1.19.3", "version": "1.19.3",
"resolved": "https://registry.npmjs.org/react-native-calendars/-/react-native-calendars-1.19.3.tgz", "resolved": "https://registry.npmjs.org/react-native-calendars/-/react-native-calendars-1.19.3.tgz",
@@ -6282,6 +6290,47 @@
"react-native-drawer-layout": "1.3.2" "react-native-drawer-layout": "1.3.2"
} }
}, },
"react-native-modal": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/react-native-modal/-/react-native-modal-3.1.0.tgz",
"integrity": "sha512-DsF4r8ScW0y+bn+7ThzBLP4az/hsi+e9ge79vExkjpw6uNFwNWQPY21BRE4uyip7PpsqEDSyvVb8GH3UXZIYcA==",
"requires": {
"prop-types": "15.5.10",
"react-native-animatable": "^1.2.3"
},
"dependencies": {
"prop-types": {
"version": "15.5.10",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.5.10.tgz",
"integrity": "sha1-J5ffwxJhguOpXj37suiT3ddFYVQ=",
"requires": {
"fbjs": "^0.8.9",
"loose-envify": "^1.3.1"
}
}
}
},
"react-native-modal-datetime-picker-nevo": {
"version": "4.11.0",
"resolved": "https://registry.npmjs.org/react-native-modal-datetime-picker-nevo/-/react-native-modal-datetime-picker-nevo-4.11.0.tgz",
"integrity": "sha512-nDUlHyUoRHO+fzt0cc2g+a8kYx+RZQZnjVY01jDIspAbRGTJuCt9x+LjTvhuDQpoXEJYvBEw1W7dz9mn3tNsoQ==",
"requires": {
"moment": "^2.19.0",
"prop-types": "15.5.10",
"react-native-modal": "3.1.0"
},
"dependencies": {
"prop-types": {
"version": "15.5.10",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.5.10.tgz",
"integrity": "sha1-J5ffwxJhguOpXj37suiT3ddFYVQ=",
"requires": {
"fbjs": "^0.8.9",
"loose-envify": "^1.3.1"
}
}
}
},
"react-native-safe-area-view": { "react-native-safe-area-view": {
"version": "0.8.0", "version": "0.8.0",
"resolved": "https://registry.npmjs.org/react-native-safe-area-view/-/react-native-safe-area-view-0.8.0.tgz", "resolved": "https://registry.npmjs.org/react-native-safe-area-view/-/react-native-safe-area-view-0.8.0.tgz",
+1
View File
@@ -21,6 +21,7 @@
"react": "16.3.1", "react": "16.3.1",
"react-native": "0.55.4", "react-native": "0.55.4",
"react-native-calendars": "^1.19.3", "react-native-calendars": "^1.19.3",
"react-native-modal-datetime-picker-nevo": "^4.11.0",
"react-native-simple-radio-button": "^2.7.1", "react-native-simple-radio-button": "^2.7.1",
"react-native-svg": "^6.3.1", "react-native-svg": "^6.3.1",
"react-navigation": "^2.0.4", "react-navigation": "^2.0.4",