Add explainer to temperature

This commit is contained in:
Julia Friesel
2018-09-01 23:33:41 +02:00
parent 023feb452e
commit 6fa18d70fe
6 changed files with 65 additions and 37 deletions
+8 -1
View File
@@ -73,7 +73,14 @@ export const fertilityStatus = {
export const temperature = { export const temperature = {
outOfRangeWarning: 'This temperature value is out of the current range for the temperature chart. You can change the range in the settings.', outOfRangeWarning: 'This temperature value is out of the current range for the temperature chart. You can change the range in the settings.',
outOfAbsoluteRangeWarning: 'This temperature value is too high or low to be shown on the temperature chart.', outOfAbsoluteRangeWarning: 'This temperature value is too high or low to be shown on the temperature chart.',
saveAnyway: 'Save anyway' saveAnyway: 'Save anyway',
temperature: {
explainer: 'Take your temperature right after waking up, before getting out of bed'
},
note: {
explainer: 'Is there anything that could have influenced this value, such as bad sleep or alcohol consumption?'
},
excludeExplainer: "You can exclude this value if you don't want to use it for fertility detection"
} }
export const noteExplainer = "Anything you want to add for the day?" export const noteExplainer = "Anything you want to add for the day?"
+1 -1
View File
@@ -49,7 +49,7 @@ export default class Bleeding extends Component {
<SymptomSection <SymptomSection
header="Exclude" header="Exclude"
explainer="You can exclude this value if it's not menstrual bleeding" explainer="You can exclude this value if it's not menstrual bleeding"
inlineExplainer={true} inline={true}
> >
<Switch <Switch
onValueChange={(val) => { onValueChange={(val) => {
+1 -1
View File
@@ -81,7 +81,7 @@ export default class Cervix extends Component {
<SymptomSection <SymptomSection
header="Exclude" header="Exclude"
explainer="You can exclude this value if you don't want to use it for fertility detection" explainer="You can exclude this value if you don't want to use it for fertility detection"
inlineExplainer={true} inline={true}
> >
<Switch <Switch
onValueChange={(val) => { onValueChange={(val) => {
+1 -1
View File
@@ -70,7 +70,7 @@ export default class Mucus extends Component {
<SymptomSection <SymptomSection
header="Exclude" header="Exclude"
explainer={labels.excludeExplainer} explainer={labels.excludeExplainer}
inlineExplainer={true} inline={true}
> >
<Switch <Switch
onValueChange={(val) => { onValueChange={(val) => {
@@ -4,14 +4,25 @@ import { SymptomSectionHeader, AppText } from '../../app-text'
export default class SymptomSection extends Component { export default class SymptomSection extends Component {
render() { render() {
const p = this.props
let placeHeadingInline
if (!p.explainer && p.inline) {
placeHeadingInline = {
flexDirection: 'row',
alignItems: "center"
}
}
return ( return (
<View> <View style={placeHeadingInline}>
<SymptomSectionHeader>{this.props.header}</SymptomSectionHeader> <SymptomSectionHeader flex={1}>{p.header}</SymptomSectionHeader>
<View flexDirection={this.props.inlineExplainer ? 'row' : 'column'}> <View
flexDirection={p.inline ? 'row' : 'column'}
flex={1}
>
<View flex={1}> <View flex={1}>
<AppText>{this.props.explainer}</AppText> <AppText>{p.explainer}</AppText>
</View> </View>
{this.props.children} {p.children}
</View> </View>
</View> </View>
) )
+38 -28
View File
@@ -12,12 +12,13 @@ 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'
import { LocalTime, ChronoUnit } from 'js-joda' import { LocalTime, ChronoUnit } from 'js-joda'
import { temperature as tempLabels } from '../labels/labels' import { temperature as labels } from '../labels/labels'
import { scaleObservable } from '../../../local-storage' import { scaleObservable } from '../../../local-storage'
import { shared } from '../../labels' import { shared } from '../../labels'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import config from '../../../config' import config from '../../../config'
import { SymptomSectionHeader } from '../../app-text' import { SymptomSectionHeader } from '../../app-text'
import SymptomSection from './symptom-section'
const minutes = ChronoUnit.MINUTES const minutes = ChronoUnit.MINUTES
@@ -72,9 +73,9 @@ export default class Temp extends Component {
const scale = scaleObservable.value const scale = scaleObservable.value
let warningMsg let warningMsg
if (value < absolute.min || value > absolute.max) { if (value < absolute.min || value > absolute.max) {
warningMsg = tempLabels.outOfAbsoluteRangeWarning warningMsg = labels.outOfAbsoluteRangeWarning
} else if (value < scale.min || value > scale.max) { } else if (value < scale.min || value > scale.max) {
warningMsg = tempLabels.outOfRangeWarning warningMsg = labels.outOfRangeWarning
} }
if (warningMsg) { if (warningMsg) {
@@ -98,16 +99,21 @@ export default class Temp extends Component {
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View> <View>
<View style={styles.symptomViewRowInline}> <SymptomSection
<SymptomSectionHeader>Temperature (°C)</SymptomSectionHeader> header="Temperature (°C)"
explainer={labels.temperature.explainer}
inline={true}
>
<TempInput <TempInput
value={this.state.temperature} value={this.state.temperature}
setState={(val) => this.setState(val)} setState={(val) => this.setState(val)}
isSuggestion={this.state.isSuggestion} isSuggestion={this.state.isSuggestion}
/> />
</View> </SymptomSection>
<View style={styles.symptomViewRowInline}> <SymptomSection
<SymptomSectionHeader>Time</SymptomSectionHeader> header="Time"
inline={true}
>
<TextInput <TextInput
style={styles.temperatureTextInput} style={styles.temperatureTextInput}
onFocus={() => { onFocus={() => {
@@ -116,40 +122,44 @@ export default class Temp extends Component {
}} }}
value={this.state.time} value={this.state.time}
/> />
</View> <DateTimePicker
<DateTimePicker mode="time"
mode="time" isVisible={this.state.isTimePickerVisible}
isVisible={this.state.isTimePickerVisible} onConfirm={jsDate => {
onConfirm={jsDate => { this.setState({
this.setState({ time: `${jsDate.getHours()}:${jsDate.getMinutes()}`,
time: `${jsDate.getHours()}:${jsDate.getMinutes()}`, isTimePickerVisible: false
isTimePickerVisible: false })
}) }}
}} onCancel={() => this.setState({ isTimePickerVisible: false })}
onCancel={() => this.setState({ isTimePickerVisible: false })} />
/> </SymptomSection>
<SymptomSectionHeader>Note</SymptomSectionHeader> <SymptomSection
<View> header="Note"
explainer={labels.note.explainer}
>
<TextInput <TextInput
style={styles.temperatureTextInput}
multiline={true} multiline={true}
autoFocus={this.state.focusTextArea} autoFocus={this.state.focusTextArea}
placeholder="enter" placeholder="Enter"
value={this.state.note} value={this.state.note}
onChangeText={(val) => { onChangeText={(val) => {
this.setState({ note: val }) this.setState({ note: val })
}} }}
/> />
</View> </SymptomSection>
<View style={styles.symptomViewRowInline}> <SymptomSection
<SymptomSectionHeader>Exlude</SymptomSectionHeader> header="Exclude"
explainer={labels.excludeExplainer}
inline={true}
>
<Switch <Switch
onValueChange={(val) => { onValueChange={(val) => {
this.setState({ exclude: val }) this.setState({ exclude: val })
}} }}
value={this.state.exclude} value={this.state.exclude}
/> />
</View> </SymptomSection>
</View> </View>
</ScrollView> </ScrollView>
<ActionButtonFooter <ActionButtonFooter