Replace action button footer in remaining symptom views
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { View, BackHandler, ScrollView } from 'react-native'
|
import { View, BackHandler } from 'react-native'
|
||||||
import Header from './components/header'
|
import Header from './components/header'
|
||||||
import Menu from './components/menu'
|
import Menu from './components/menu'
|
||||||
import Home from './components/home'
|
import Home from './components/home'
|
||||||
@@ -9,11 +9,11 @@ import symptomViews from './components/cycle-day/symptoms'
|
|||||||
import Chart from './components/chart/chart'
|
import Chart from './components/chart/chart'
|
||||||
import Settings from './components/settings'
|
import Settings from './components/settings'
|
||||||
import Stats from './components/stats'
|
import Stats from './components/stats'
|
||||||
|
import styles from './styles'
|
||||||
|
|
||||||
// this is until react native fixes this bugg, see
|
// this is until react native fixes this bugg, see
|
||||||
// https://github.com/facebook/react-native/issues/18868#issuecomment-382671739
|
// https://github.com/facebook/react-native/issues/18868#issuecomment-382671739
|
||||||
import { YellowBox } from 'react-native'
|
import { YellowBox } from 'react-native'
|
||||||
import ActionButtonFooter from './components/cycle-day/symptoms/action-button-footer';
|
|
||||||
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated'])
|
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated'])
|
||||||
|
|
||||||
const isSymptomView = name => Object.keys(symptomViews).indexOf(name) > -1
|
const isSymptomView = name => Object.keys(symptomViews).indexOf(name) > -1
|
||||||
@@ -46,38 +46,22 @@ export default class App extends Component {
|
|||||||
this.setState({currentPage: pageName, currentProps: props})
|
this.setState({currentPage: pageName, currentProps: props})
|
||||||
}
|
}
|
||||||
|
|
||||||
setActionButtonState(actionButtonInfo) {
|
|
||||||
this.setState({actionButtonInfo})
|
|
||||||
}
|
|
||||||
|
|
||||||
unsetActionButtonState() {
|
|
||||||
this.setState({actionButtonInfo: null})
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const page = {
|
const page = {
|
||||||
Home, Calendar, CycleDay, Chart, Settings, Stats, ...symptomViews
|
Home, Calendar, CycleDay, Chart, Settings, Stats, ...symptomViews
|
||||||
}[this.state.currentPage]
|
}[this.state.currentPage]
|
||||||
return (
|
return (
|
||||||
<View style={{height: '100%', justifyContent: 'space-between' }}>
|
<View style={styles.menuOnBottom}>
|
||||||
<View>
|
|
||||||
{this.state.currentPage != 'CycleDay' && <Header title={this.state.currentPage}/>}
|
{this.state.currentPage != 'CycleDay' && <Header title={this.state.currentPage} />}
|
||||||
<ScrollView>
|
|
||||||
{React.createElement(page, {
|
{React.createElement(page, {
|
||||||
navigate: this.navigate.bind(this),
|
navigate: this.navigate.bind(this),
|
||||||
setActionButtonState: this.setActionButtonState.bind(this),
|
...this.state.currentProps
|
||||||
unsetActionButtonState: this.unsetActionButtonState.bind(this),
|
})}
|
||||||
...this.state.currentProps
|
|
||||||
})}
|
{!isSymptomView(this.state.currentPage) &&
|
||||||
</ScrollView>
|
<Menu navigate={this.navigate.bind(this)} />
|
||||||
</View>
|
|
||||||
{isSymptomView(this.state.currentPage) && this.state.actionButtonInfo ?
|
|
||||||
<ActionButtonFooter
|
|
||||||
{...this.state.actionButtonInfo}
|
|
||||||
navigate={this.navigate.bind(this)}
|
|
||||||
/>
|
|
||||||
:
|
|
||||||
<Menu navigate={this.navigate.bind(this)}/>
|
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import RadioForm from 'react-native-simple-radio-button'
|
|||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
import { saveSymptom } from '../../../db'
|
import { saveSymptom } from '../../../db'
|
||||||
import { bleeding as labels } from '../labels/labels'
|
import { bleeding as labels } from '../labels/labels'
|
||||||
|
import ActionButtonFooter from './action-button-footer'
|
||||||
|
|
||||||
export default class Bleeding extends Component {
|
export default class Bleeding extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -32,8 +33,8 @@ export default class Bleeding extends Component {
|
|||||||
{ label: labels[3], value: 3 },
|
{ label: labels[3], value: 3 },
|
||||||
]
|
]
|
||||||
return (
|
return (
|
||||||
<View>
|
<View style={styles.menuOnBottom}>
|
||||||
<View style={styles.symptomEditView}>
|
<View>
|
||||||
<Text style={styles.symptomDayView}>Bleeding</Text>
|
<Text style={styles.symptomDayView}>Bleeding</Text>
|
||||||
<View style={styles.radioButtonRow}>
|
<View style={styles.radioButtonRow}>
|
||||||
<RadioForm
|
<RadioForm
|
||||||
@@ -57,21 +58,18 @@ export default class Bleeding extends Component {
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.actionButtonRow}>
|
<ActionButtonFooter
|
||||||
{this.makeActionButtons(
|
symptom='bleeding'
|
||||||
{
|
cycleDay={this.props.cycleDay}
|
||||||
symptom: 'bleeding',
|
saveAction={() => {
|
||||||
cycleDay: this.cycleDay,
|
saveSymptom('bleeding', this.props.cycleDay, {
|
||||||
saveAction: () => {
|
value: this.state.currentValue,
|
||||||
saveSymptom('bleeding', this.cycleDay, {
|
exclude: this.state.exclude
|
||||||
value: this.state.currentValue,
|
})
|
||||||
exclude: this.state.exclude
|
}}
|
||||||
})
|
saveDisabled={this.state.currentValue === -1}
|
||||||
},
|
navigate={this.props.navigate}
|
||||||
saveDisabled: this.state.currentValue === -1
|
/>
|
||||||
}
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
cervixFirmness as firmnessLabels,
|
cervixFirmness as firmnessLabels,
|
||||||
cervixPosition as positionLabels
|
cervixPosition as positionLabels
|
||||||
} from '../labels/labels'
|
} from '../labels/labels'
|
||||||
|
import ActionButtonFooter from './action-button-footer'
|
||||||
|
|
||||||
export default class Cervix extends Component {
|
export default class Cervix extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -45,76 +46,75 @@ export default class Cervix extends Component {
|
|||||||
const cervixPositionRadioProps = [
|
const cervixPositionRadioProps = [
|
||||||
{label: positionLabels[0], value: 0 },
|
{label: positionLabels[0], value: 0 },
|
||||||
{label: positionLabels[1], value: 1 },
|
{label: positionLabels[1], value: 1 },
|
||||||
{label: positionLabels[2], value: 2 }
|
{ label: positionLabels[2], value: 2 }
|
||||||
]
|
]
|
||||||
return(
|
return (
|
||||||
<View style={ styles.symptomEditView }>
|
<View style={styles.menuOnBottom}>
|
||||||
<Text style={styles.symptomDayView}>Cervix</Text>
|
<View>
|
||||||
<Text style={styles.symptomDayView}>Opening</Text>
|
<Text style={styles.symptomDayView}>Cervix</Text>
|
||||||
<View style={styles.radioButtonRow}>
|
<Text style={styles.symptomDayView}>Opening</Text>
|
||||||
<RadioForm
|
<View style={styles.radioButtonRow}>
|
||||||
radio_props={cervixOpeningRadioProps}
|
<RadioForm
|
||||||
initial={this.state.opening}
|
radio_props={cervixOpeningRadioProps}
|
||||||
formHorizontal={true}
|
initial={this.state.opening}
|
||||||
labelHorizontal={false}
|
formHorizontal={true}
|
||||||
labelStyle={styles.radioButton}
|
labelHorizontal={false}
|
||||||
onPress={(itemValue) => {
|
labelStyle={styles.radioButton}
|
||||||
this.setState({opening: itemValue})
|
onPress={(itemValue) => {
|
||||||
}}
|
this.setState({ opening: itemValue })
|
||||||
/>
|
}}
|
||||||
</View>
|
/>
|
||||||
<Text style={styles.symptomDayView}>Firmness</Text>
|
</View>
|
||||||
<View style={styles.radioButtonRow}>
|
<Text style={styles.symptomDayView}>Firmness</Text>
|
||||||
<RadioForm
|
<View style={styles.radioButtonRow}>
|
||||||
radio_props={cervixFirmnessRadioProps}
|
<RadioForm
|
||||||
initial={this.state.firmness}
|
radio_props={cervixFirmnessRadioProps}
|
||||||
formHorizontal={true}
|
initial={this.state.firmness}
|
||||||
labelHorizontal={false}
|
formHorizontal={true}
|
||||||
labelStyle={styles.radioButton}
|
labelHorizontal={false}
|
||||||
onPress={(itemValue) => {
|
labelStyle={styles.radioButton}
|
||||||
this.setState({firmness: itemValue})
|
onPress={(itemValue) => {
|
||||||
}}
|
this.setState({ firmness: itemValue })
|
||||||
/>
|
}}
|
||||||
</View>
|
/>
|
||||||
<Text style={styles.symptomDayView}>Position</Text>
|
</View>
|
||||||
<View style={styles.radioButtonRow}>
|
<Text style={styles.symptomDayView}>Position</Text>
|
||||||
<RadioForm
|
<View style={styles.radioButtonRow}>
|
||||||
radio_props={cervixPositionRadioProps}
|
<RadioForm
|
||||||
initial={this.state.position}
|
radio_props={cervixPositionRadioProps}
|
||||||
formHorizontal={true}
|
initial={this.state.position}
|
||||||
labelHorizontal={false}
|
formHorizontal={true}
|
||||||
labelStyle={styles.radioButton}
|
labelHorizontal={false}
|
||||||
onPress={(itemValue) => {
|
labelStyle={styles.radioButton}
|
||||||
this.setState({position: itemValue})
|
onPress={(itemValue) => {
|
||||||
}}
|
this.setState({ position: itemValue })
|
||||||
/>
|
}}
|
||||||
</View>
|
/>
|
||||||
<View style={styles.symptomViewRowInline}>
|
</View>
|
||||||
<Text style={styles.symptomDayView}>Exclude</Text>
|
<View style={styles.symptomViewRowInline}>
|
||||||
<Switch
|
<Text style={styles.symptomDayView}>Exclude</Text>
|
||||||
onValueChange={(val) => {
|
<Switch
|
||||||
this.setState({ exclude: val })
|
onValueChange={(val) => {
|
||||||
}}
|
this.setState({ exclude: val })
|
||||||
value={this.state.exclude}
|
}}
|
||||||
/>
|
value={this.state.exclude}
|
||||||
</View>
|
/>
|
||||||
<View style={styles.actionButtonRow}>
|
</View>
|
||||||
{this.makeActionButtons(
|
|
||||||
{
|
|
||||||
symptom: 'cervix',
|
|
||||||
cycleDay: this.cycleDay,
|
|
||||||
saveAction: () => {
|
|
||||||
saveSymptom('cervix', this.cycleDay, {
|
|
||||||
opening: this.state.opening,
|
|
||||||
firmness: this.state.firmness,
|
|
||||||
position: this.state.position,
|
|
||||||
exclude: this.state.exclude
|
|
||||||
})
|
|
||||||
},
|
|
||||||
saveDisabled: this.state.opening === -1 || this.state.firmness === -1
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
|
<ActionButtonFooter
|
||||||
|
symptom='cervix'
|
||||||
|
cycleDay={this.cycleDay}
|
||||||
|
saveAction={() => {
|
||||||
|
saveSymptom('cervix', this.cycleDay, {
|
||||||
|
opening: this.state.opening,
|
||||||
|
firmness: this.state.firmness,
|
||||||
|
position: this.state.position,
|
||||||
|
exclude: this.state.exclude
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
saveDisabled={this.state.opening === -1 || this.state.firmness === -1}
|
||||||
|
navigate={this.props.navigate}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import RadioForm from 'react-native-simple-radio-button'
|
|||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
import { saveSymptom } from '../../../db'
|
import { saveSymptom } from '../../../db'
|
||||||
import { intensity as labels } from '../labels/labels'
|
import { intensity as labels } from '../labels/labels'
|
||||||
|
import ActionButtonFooter from './action-button-footer'
|
||||||
|
|
||||||
export default class Desire extends Component {
|
export default class Desire extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -27,32 +28,31 @@ export default class Desire extends Component {
|
|||||||
{ label: labels[2], value: 2 }
|
{ label: labels[2], value: 2 }
|
||||||
]
|
]
|
||||||
return (
|
return (
|
||||||
<View style={styles.symptomEditView}>
|
<View style={styles.menuOnBottom}>
|
||||||
<Text style={styles.symptomDayView}>Desire</Text>
|
<View>
|
||||||
<View style={styles.radioButtonRow}>
|
<Text style={styles.symptomDayView}>Desire</Text>
|
||||||
<RadioForm
|
<View style={styles.radioButtonRow}>
|
||||||
radio_props={desireRadioProps}
|
<RadioForm
|
||||||
initial={this.state.currentValue}
|
radio_props={desireRadioProps}
|
||||||
formHorizontal={true}
|
initial={this.state.currentValue}
|
||||||
labelHorizontal={false}
|
formHorizontal={true}
|
||||||
labelStyle={styles.radioButton}
|
labelHorizontal={false}
|
||||||
onPress={(itemValue) => {
|
labelStyle={styles.radioButton}
|
||||||
this.setState({ currentValue: itemValue })
|
onPress={(itemValue) => {
|
||||||
}}
|
this.setState({ currentValue: itemValue })
|
||||||
/>
|
}}
|
||||||
</View>
|
/>
|
||||||
<View style={styles.actionButtonRow}>
|
</View>
|
||||||
{this.makeActionButtons(
|
|
||||||
{
|
|
||||||
symptom: 'desire',
|
|
||||||
cycleDay: this.cycleDay,
|
|
||||||
saveAction: () => {
|
|
||||||
saveSymptom('desire', this.cycleDay, { value: this.state.currentValue })
|
|
||||||
},
|
|
||||||
saveDisabled: this.state.currentValue === -1
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
|
<ActionButtonFooter
|
||||||
|
symptom='desire'
|
||||||
|
cycleDay={this.cycleDay}
|
||||||
|
saveAction={() => {
|
||||||
|
saveSymptom('desire', this.cycleDay, { value: this.state.currentValue })
|
||||||
|
}}
|
||||||
|
saveDisabled={this.state.currentValue === -1}
|
||||||
|
navigate={this.props.navigate}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
mucusTexture as textureLabels
|
mucusTexture as textureLabels
|
||||||
} from '../labels/labels'
|
} from '../labels/labels'
|
||||||
import computeSensiplanValue from '../../../lib/sensiplan-mucus'
|
import computeSensiplanValue from '../../../lib/sensiplan-mucus'
|
||||||
|
import ActionButtonFooter from './action-button-footer'
|
||||||
|
|
||||||
|
|
||||||
export default class Mucus extends Component {
|
export default class Mucus extends Component {
|
||||||
@@ -31,78 +32,74 @@ export default class Mucus extends Component {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
/* eslint-enable react/no-direct-mutation-state */
|
/* eslint-enable react/no-direct-mutation-state */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const mucusFeelingRadioProps = [
|
const mucusFeelingRadioProps = [
|
||||||
{label: feelingLabels[0], value: 0 },
|
{ label: feelingLabels[0], value: 0 },
|
||||||
{label: feelingLabels[1], value: 1 },
|
{ label: feelingLabels[1], value: 1 },
|
||||||
{label: feelingLabels[2], value: 2 },
|
{ label: feelingLabels[2], value: 2 },
|
||||||
{label: feelingLabels[3], value: 3 }
|
{ label: feelingLabels[3], value: 3 }
|
||||||
]
|
]
|
||||||
const mucusTextureRadioProps = [
|
const mucusTextureRadioProps = [
|
||||||
{label: textureLabels[0], value: 0 },
|
{ label: textureLabels[0], value: 0 },
|
||||||
{label: textureLabels[1], value: 1 },
|
{ label: textureLabels[1], value: 1 },
|
||||||
{label: textureLabels[2], value: 2 }
|
{ label: textureLabels[2], value: 2 }
|
||||||
]
|
]
|
||||||
return(
|
return (
|
||||||
<View style={ styles.symptomEditView }>
|
<View style={styles.menuOnBottom}>
|
||||||
<Text style={styles.symptomDayView}>Mucus</Text>
|
<View>
|
||||||
<Text style={styles.symptomDayView}>Feeling</Text>
|
<Text style={styles.symptomDayView}>Mucus</Text>
|
||||||
<View style={styles.radioButtonRow}>
|
<Text style={styles.symptomDayView}>Feeling</Text>
|
||||||
<RadioForm
|
<View style={styles.radioButtonRow}>
|
||||||
radio_props={mucusFeelingRadioProps}
|
<RadioForm
|
||||||
initial={this.state.feeling}
|
radio_props={mucusFeelingRadioProps}
|
||||||
formHorizontal={true}
|
initial={this.state.feeling}
|
||||||
labelHorizontal={false}
|
formHorizontal={true}
|
||||||
labelStyle={styles.radioButton}
|
labelHorizontal={false}
|
||||||
onPress={(itemValue) => {
|
labelStyle={styles.radioButton}
|
||||||
this.setState({feeling: itemValue })
|
onPress={(itemValue) => {
|
||||||
}}
|
this.setState({ feeling: itemValue })
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<Text style={styles.symptomDayView}>Texture</Text>
|
||||||
|
<View style={styles.radioButtonRow}>
|
||||||
|
<RadioForm
|
||||||
|
radio_props={mucusTextureRadioProps}
|
||||||
|
initial={this.state.texture}
|
||||||
|
formHorizontal={true}
|
||||||
|
labelHorizontal={false}
|
||||||
|
labelStyle={styles.radioButton}
|
||||||
|
onPress={(itemValue) => {
|
||||||
|
this.setState({ texture: itemValue })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>Exclude</Text>
|
||||||
|
<Switch
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({ exclude: val })
|
||||||
|
}}
|
||||||
|
value={this.state.exclude}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.symptomDayView}>Texture</Text>
|
<ActionButtonFooter
|
||||||
<View style={styles.radioButtonRow}>
|
symptom='mucus'
|
||||||
<RadioForm
|
cycleDay={this.cycleDay}
|
||||||
radio_props={mucusTextureRadioProps}
|
saveAction={() => {
|
||||||
initial={this.state.texture}
|
saveSymptom('mucus', this.cycleDay, {
|
||||||
formHorizontal={true}
|
feeling: this.state.feeling,
|
||||||
labelHorizontal={false}
|
texture: this.state.texture,
|
||||||
labelStyle={styles.radioButton}
|
value: computeSensiplanValue(this.state.feeling, this.state.texture),
|
||||||
onPress={(itemValue) => {
|
exclude: this.state.exclude
|
||||||
this.setState({texture: itemValue })
|
})
|
||||||
}}
|
}}
|
||||||
/>
|
saveDisabled={this.state.feeling === -1 || this.state.texture === -1}
|
||||||
</View>
|
navigate={this.props.navigate}
|
||||||
<View style={styles.symptomViewRowInline}>
|
/>
|
||||||
<Text style={styles.symptomDayView}>Exclude</Text>
|
|
||||||
<Switch
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({ exclude: val })
|
|
||||||
}}
|
|
||||||
value={this.state.exclude}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<View style={styles.actionButtonRow}>
|
|
||||||
{this.makeActionButtons(
|
|
||||||
{
|
|
||||||
symptom: 'mucus',
|
|
||||||
cycleDay: this.cycleDay,
|
|
||||||
saveAction: () => {
|
|
||||||
saveSymptom('mucus', this.cycleDay, {
|
|
||||||
feeling: this.state.feeling,
|
|
||||||
texture: this.state.texture,
|
|
||||||
value: computeSensiplanValue(this.state.feeling, this.state.texture),
|
|
||||||
exclude: this.state.exclude
|
|
||||||
})
|
|
||||||
},
|
|
||||||
saveDisabled: this.state.feeling === -1 || this.state.texture === -1
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
|
|
||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
import { saveSymptom } from '../../../db'
|
import { saveSymptom } from '../../../db'
|
||||||
|
import ActionButtonFooter from './action-button-footer'
|
||||||
|
|
||||||
export default class Temp extends Component {
|
export default class Temp extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -22,7 +23,7 @@ export default class Temp extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={styles.symptomEditView}>
|
<View style={styles.menuOnBottom}>
|
||||||
<View style={styles.symptomViewRow}>
|
<View style={styles.symptomViewRow}>
|
||||||
<Text style={styles.symptomDayView}>Note</Text>
|
<Text style={styles.symptomDayView}>Note</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
@@ -34,19 +35,18 @@ export default class Temp extends Component {
|
|||||||
value={this.state.currentValue}
|
value={this.state.currentValue}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.actionButtonRow}>
|
<ActionButtonFooter
|
||||||
{this.makeActionButtons({
|
symptom='note'
|
||||||
symptom: 'note',
|
cycleDay={this.cycleDay}
|
||||||
cycleDay: this.cycleDay,
|
saveAction={() => {
|
||||||
saveAction: () => {
|
saveSymptom('note', this.cycleDay, {
|
||||||
saveSymptom('note', this.cycleDay, {
|
value: this.state.currentValue
|
||||||
value: this.state.currentValue
|
})
|
||||||
})
|
}}
|
||||||
},
|
saveDisabled={!this.state.currentValue}
|
||||||
saveDisabled: !this.state.currentValue
|
navigate={this.props.navigate}
|
||||||
})}
|
/>
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
sexActivity as activityLabels,
|
sexActivity as activityLabels,
|
||||||
contraceptives as contraceptiveLabels
|
contraceptives as contraceptiveLabels
|
||||||
} from '../labels/labels'
|
} from '../labels/labels'
|
||||||
|
import ActionButtonFooter from './action-button-footer'
|
||||||
|
|
||||||
export default class Sex extends Component {
|
export default class Sex extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -30,127 +31,126 @@ export default class Sex extends Component {
|
|||||||
render() {
|
render() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.symptomEditView}>
|
<View style={styles.menuOnBottom}>
|
||||||
<Text style={styles.symptomDayView}>SEX</Text>
|
<View>
|
||||||
<View style={styles.symptomViewRowInline}>
|
<Text style={styles.symptomDayView}>SEX</Text>
|
||||||
<Text style={styles.symptomDayView}>{activityLabels.solo}</Text>
|
<View style={styles.symptomViewRowInline}>
|
||||||
<CheckBox
|
<Text style={styles.symptomDayView}>{activityLabels.solo}</Text>
|
||||||
value={this.state.solo}
|
<CheckBox
|
||||||
onValueChange={(val) => {
|
value={this.state.solo}
|
||||||
this.setState({solo: val})
|
onValueChange={(val) => {
|
||||||
}}
|
this.setState({ solo: val })
|
||||||
/>
|
}}
|
||||||
<Text style={styles.symptomDayView}>{activityLabels.partner}</Text>
|
/>
|
||||||
<CheckBox
|
<Text style={styles.symptomDayView}>{activityLabels.partner}</Text>
|
||||||
value={this.state.partner}
|
<CheckBox
|
||||||
onValueChange={(val) => {
|
value={this.state.partner}
|
||||||
this.setState({partner: val})
|
onValueChange={(val) => {
|
||||||
}}
|
this.setState({ partner: val })
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<Text style={styles.symptomDayView}>CONTRACEPTIVES</Text>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>
|
||||||
|
{contraceptiveLabels.condom}
|
||||||
|
</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.condom}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({ condom: val })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Text style={styles.symptomDayView}>
|
||||||
|
{contraceptiveLabels.pill}
|
||||||
|
</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.pill}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({ pill: val })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>
|
||||||
|
{contraceptiveLabels.iud}
|
||||||
|
</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.iud}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({ iud: val })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Text style={styles.symptomDayView}>
|
||||||
|
{contraceptiveLabels.patch}
|
||||||
|
</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.patch}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({ patch: val })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>
|
||||||
|
{contraceptiveLabels.ring}
|
||||||
|
</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.ring}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({ ring: val })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Text style={styles.symptomDayView}>
|
||||||
|
{contraceptiveLabels.implant}
|
||||||
|
</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.implant}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({ implant: val })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>
|
||||||
|
{contraceptiveLabels.other}
|
||||||
|
</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.other}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({
|
||||||
|
other: val,
|
||||||
|
focusTextArea: true
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
{this.state.other &&
|
||||||
|
<TextInput
|
||||||
|
autoFocus={this.state.focusTextArea}
|
||||||
|
multiline={true}
|
||||||
|
placeholder="Enter"
|
||||||
|
value={this.state.note}
|
||||||
|
onChangeText={(val) => {
|
||||||
|
this.setState({ note: val })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.symptomDayView}>CONTRACEPTIVES</Text>
|
<ActionButtonFooter
|
||||||
<View style={styles.symptomViewRowInline}>
|
symptom='sex'
|
||||||
<Text style={styles.symptomDayView}>
|
cycleDay={this.cycleDay}
|
||||||
{contraceptiveLabels.condom}
|
saveAction={() => {
|
||||||
</Text>
|
const copyOfState = Object.assign({}, this.state)
|
||||||
<CheckBox
|
if (!copyOfState.other) {
|
||||||
value={this.state.condom}
|
copyOfState.note = null
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({condom: val})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{contraceptiveLabels.pill}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.pill}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({pill: val})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={styles.symptomViewRowInline}>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{contraceptiveLabels.iud}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.iud}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({iud: val})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{contraceptiveLabels.patch}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.patch}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({patch: val})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={styles.symptomViewRowInline}>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{contraceptiveLabels.ring}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.ring}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({ring: val})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{contraceptiveLabels.implant}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.implant}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({implant: val})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={styles.symptomViewRowInline}>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{contraceptiveLabels.other}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.other}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({
|
|
||||||
other: val,
|
|
||||||
focusTextArea: true
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
{ this.state.other &&
|
|
||||||
<TextInput
|
|
||||||
autoFocus={this.state.focusTextArea}
|
|
||||||
multiline={true}
|
|
||||||
placeholder="Enter"
|
|
||||||
value={this.state.note}
|
|
||||||
onChangeText={(val) => {
|
|
||||||
this.setState({note: val})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
<View style={styles.actionButtonRow}>
|
|
||||||
{this.props.makeActionButtons(
|
|
||||||
{
|
|
||||||
symptom: 'sex',
|
|
||||||
cycleDay: this.cycleDay,
|
|
||||||
saveAction: () => {
|
|
||||||
const copyOfState = Object.assign({}, this.state)
|
|
||||||
if (!copyOfState.other) {
|
|
||||||
copyOfState.note = null
|
|
||||||
}
|
|
||||||
saveSymptom('sex', this.cycleDay, copyOfState)
|
|
||||||
},
|
|
||||||
saveDisabled: Object.values(this.state).every(value => !value)
|
|
||||||
}
|
}
|
||||||
)}
|
saveSymptom('sex', this.cycleDay, copyOfState)
|
||||||
</View>
|
}}
|
||||||
|
saveDisabled={Object.values(this.state).every(value => !value)}
|
||||||
|
navigate={this.props.navigate}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ 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 ActionButtonFooter from './action-button-footer'
|
||||||
|
|
||||||
const MINUTES = ChronoUnit.MINUTES
|
const MINUTES = ChronoUnit.MINUTES
|
||||||
|
|
||||||
@@ -37,72 +38,70 @@ export default class Temp extends Component {
|
|||||||
time: this.time || LocalTime.now().truncatedTo(MINUTES).toString(),
|
time: this.time || LocalTime.now().truncatedTo(MINUTES).toString(),
|
||||||
isTimePickerVisible: false
|
isTimePickerVisible: false
|
||||||
}
|
}
|
||||||
|
|
||||||
props.setActionButtonState({
|
|
||||||
symptom : 'temperature',
|
|
||||||
cycleDay: props.cycleDay,
|
|
||||||
saveAction: () => {
|
|
||||||
const dataToSave = {
|
|
||||||
value: Number(this.state.currentValue),
|
|
||||||
exclude: this.state.exclude,
|
|
||||||
time: this.state.time
|
|
||||||
}
|
|
||||||
saveSymptom('temperature', props.cycleDay, dataToSave)
|
|
||||||
},
|
|
||||||
saveDisabled: this.state.currentValue === '' || isInvalidTime(this.state.time)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
this.props.unsetActionButtonState()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={styles.symptomEditView}>
|
<View style={styles.menuOnBottom}>
|
||||||
<View style={styles.symptomViewRowInline}>
|
<View>
|
||||||
<Text style={styles.symptomDayView}>Temperature (°C)</Text>
|
<View style={styles.symptomViewRowInline}>
|
||||||
<TextInput
|
<Text style={styles.symptomDayView}>Temperature (°C)</Text>
|
||||||
style={styles.temperatureTextInput}
|
<TextInput
|
||||||
placeholder="Enter"
|
style={styles.temperatureTextInput}
|
||||||
onChangeText={(val) => {
|
placeholder="Enter"
|
||||||
this.setState({ currentValue: val })
|
onChangeText={(val) => {
|
||||||
|
this.setState({ currentValue: val })
|
||||||
|
}}
|
||||||
|
keyboardType='numeric'
|
||||||
|
value={this.state.currentValue}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>Time</Text>
|
||||||
|
<TextInput
|
||||||
|
style={styles.temperatureTextInput}
|
||||||
|
onFocus={() => {
|
||||||
|
Keyboard.dismiss()
|
||||||
|
this.setState({ isTimePickerVisible: true })
|
||||||
|
}}
|
||||||
|
value={this.state.time}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<DateTimePicker
|
||||||
|
mode="time"
|
||||||
|
isVisible={this.state.isTimePickerVisible}
|
||||||
|
onConfirm={jsDate => {
|
||||||
|
this.setState({
|
||||||
|
time: `${jsDate.getHours()}:${jsDate.getMinutes()}`,
|
||||||
|
isTimePickerVisible: false
|
||||||
|
})
|
||||||
}}
|
}}
|
||||||
keyboardType='numeric'
|
onCancel={() => this.setState({ isTimePickerVisible: false })}
|
||||||
value={this.state.currentValue}
|
|
||||||
/>
|
/>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>Exclude</Text>
|
||||||
|
<Switch
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({ exclude: val })
|
||||||
|
}}
|
||||||
|
value={this.state.exclude}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.symptomViewRowInline}>
|
<ActionButtonFooter
|
||||||
<Text style={styles.symptomDayView}>Time</Text>
|
symptom='temperature'
|
||||||
<TextInput
|
cycleDay={this.cycleDay}
|
||||||
style={styles.temperatureTextInput}
|
saveAction={() => {
|
||||||
onFocus={() => {
|
const dataToSave = {
|
||||||
Keyboard.dismiss()
|
value: Number(this.state.currentValue),
|
||||||
this.setState({ isTimePickerVisible: true })
|
exclude: this.state.exclude,
|
||||||
}}
|
time: this.state.time
|
||||||
value={this.state.time}
|
}
|
||||||
/>
|
saveSymptom('temperature', this.props.cycleDay, dataToSave)
|
||||||
</View>
|
|
||||||
<DateTimePicker
|
|
||||||
mode="time"
|
|
||||||
isVisible={this.state.isTimePickerVisible}
|
|
||||||
onConfirm={jsDate => {
|
|
||||||
this.setState({
|
|
||||||
time: `${jsDate.getHours()}:${jsDate.getMinutes()}`,
|
|
||||||
isTimePickerVisible: false
|
|
||||||
})
|
|
||||||
}}
|
}}
|
||||||
onCancel={() => this.setState({ isTimePickerVisible: false })}
|
saveDisabled={this.state.currentValue === '' || isInvalidTime(this.state.time)}
|
||||||
|
navigate={this.props.navigate}
|
||||||
/>
|
/>
|
||||||
<View style={styles.symptomViewRowInline}>
|
|
||||||
<Text style={styles.symptomDayView}>Exclude</Text>
|
|
||||||
<Switch
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({ exclude: val })
|
|
||||||
}}
|
|
||||||
value={this.state.exclude}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
ScrollView
|
ScrollView
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import { LocalDate, ChronoUnit } from 'js-joda'
|
import { LocalDate, ChronoUnit } from 'js-joda'
|
||||||
import Header from './header'
|
|
||||||
import styles from '../styles/index'
|
import styles from '../styles/index'
|
||||||
import cycleModule from '../lib/cycle'
|
import cycleModule from '../lib/cycle'
|
||||||
import getCycleInfo from '../lib/cycle-length'
|
import getCycleInfo from '../lib/cycle-length'
|
||||||
|
|||||||
@@ -83,6 +83,10 @@ export default StyleSheet.create({
|
|||||||
symptomDataText: {
|
symptomDataText: {
|
||||||
fontSize: 12
|
fontSize: 12
|
||||||
},
|
},
|
||||||
|
menuOnBottom: {
|
||||||
|
flex: 1,
|
||||||
|
justifyContent: 'space-between'
|
||||||
|
},
|
||||||
symptomEditRow: {
|
symptomEditRow: {
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
marginBottom: 10,
|
marginBottom: 10,
|
||||||
|
|||||||
Reference in New Issue
Block a user