Merge branch 'adding-cervix-symptom' into 'master'
Adding cervix symptom See merge request bloodyhealth/drip!31
This commit is contained in:
@@ -10,6 +10,9 @@ import {
|
|||||||
mucusFeeling as feelingLabels,
|
mucusFeeling as feelingLabels,
|
||||||
mucusTexture as textureLabels,
|
mucusTexture as textureLabels,
|
||||||
mucusNFP as computeSensiplanMucusLabels,
|
mucusNFP as computeSensiplanMucusLabels,
|
||||||
|
cervixOpening as openingLabels,
|
||||||
|
cervixFirmness as firmnessLabels,
|
||||||
|
cervixPosition as positionLabels
|
||||||
} from './labels/labels'
|
} from './labels/labels'
|
||||||
import cycleDayModule from '../../lib/get-cycle-day-number'
|
import cycleDayModule from '../../lib/get-cycle-day-number'
|
||||||
import { bleedingDaysSortedByDate } from '../../db'
|
import { bleedingDaysSortedByDate } from '../../db'
|
||||||
@@ -41,36 +44,53 @@ export default class DayView extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const bleedingValue = this.cycleDay.bleeding && this.cycleDay.bleeding.value
|
|
||||||
let bleedingLabel
|
let bleedingLabel
|
||||||
if (typeof bleedingValue === 'number') {
|
if (this.cycleDay.bleeding) {
|
||||||
bleedingLabel = `${bleedingLabels[bleedingValue]}`
|
const bleeding = this.cycleDay.bleeding
|
||||||
if (this.cycleDay.bleeding.exclude) bleedingLabel = "( " + bleedingLabel + " )"
|
if (typeof bleeding === 'number') {
|
||||||
|
bleedingLabel = `${bleedingLabels[bleeding]}`
|
||||||
|
if (bleeding.exclude) bleedingLabel = "( " + bleedingLabel + " )"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
bleedingLabel = 'edit'
|
bleedingLabel = 'edit'
|
||||||
}
|
}
|
||||||
const temperatureValue = this.cycleDay.temperature && this.cycleDay.temperature.value
|
|
||||||
let temperatureLabel
|
let temperatureLabel
|
||||||
if (typeof temperatureValue === 'number') {
|
if (this.cycleDay.temperature) {
|
||||||
temperatureLabel = `${temperatureValue} °C - ${this.cycleDay.temperature.time}`
|
const temperature = this.cycleDay.temperature
|
||||||
if (this.cycleDay.temperature.exclude) {
|
if (typeof temperature === 'number') {
|
||||||
temperatureLabel = "( " + temperatureLabel + " )"
|
temperatureLabel = `${temperature} °C - ${temperature.time}`
|
||||||
|
if (temperature.exclude) {
|
||||||
|
temperatureLabel = "( " + temperatureLabel + " )"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
temperatureLabel = 'edit'
|
temperatureLabel = 'edit'
|
||||||
}
|
}
|
||||||
|
|
||||||
const mucusFeelingValue = this.cycleDay.mucus && this.cycleDay.mucus.feeling
|
|
||||||
const mucusTextureValue = this.cycleDay.mucus && this.cycleDay.mucus.texture
|
|
||||||
const mucusComputedValue = this.cycleDay.mucus && this.cycleDay.mucus.computedNfp
|
|
||||||
let mucusLabel
|
let mucusLabel
|
||||||
if (typeof mucusFeelingValue === 'number' && typeof mucusTextureValue === 'number') {
|
if (this.cycleDay.mucus) {
|
||||||
mucusLabel = `${feelingLabels[mucusFeelingValue]} + ${textureLabels[mucusTextureValue]} ( ${computeSensiplanMucusLabels[mucusComputedValue]} )`
|
const mucus = this.cycleDay.mucus
|
||||||
if (this.cycleDay.mucus.exclude) mucusLabel = "( " + mucusLabel + " )"
|
if (typeof mucus.feeling === 'number' && typeof mucus.texture === 'number') {
|
||||||
|
mucusLabel = `${feelingLabels[mucus.feeling]} + ${textureLabels[mucus.texture]} ( ${computeSensiplanMucusLabels[mucus.computedNfp]} )`
|
||||||
|
if (mucus.exclude) mucusLabel = "( " + mucusLabel + " )"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mucusLabel = 'edit'
|
mucusLabel = 'edit'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let cervixLabel
|
||||||
|
if (this.cycleDay.cervix) {
|
||||||
|
const cervix = this.cycleDay.cervix
|
||||||
|
if (cervix.opening > -1 && cervix.firmness > -1) {
|
||||||
|
cervixLabel = `${openingLabels[cervix.opening]} + ${firmnessLabels[cervix.firmness]}`
|
||||||
|
if (cervix.position > -1) cervixLabel += `+ ${positionLabels[cervix.position]}`
|
||||||
|
if (cervix.exclude) cervixLabel = "( " + cervixLabel + " )"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cervixLabel = 'edit'
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.symptomEditView}>
|
<View style={styles.symptomEditView}>
|
||||||
<View style={styles.symptomViewRowInline}>
|
<View style={styles.symptomViewRowInline}>
|
||||||
@@ -100,6 +120,15 @@ export default class DayView extends Component {
|
|||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>Cervix</Text>
|
||||||
|
<View style={ styles.symptomEditButton }>
|
||||||
|
<Button
|
||||||
|
onPress={() => this.showView('cervixEditView')}
|
||||||
|
title={cervixLabel}>
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
</View >
|
</View >
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import BleedingEditView from './symptoms/bleeding'
|
|||||||
import TemperatureEditView from './symptoms/temperature'
|
import TemperatureEditView from './symptoms/temperature'
|
||||||
import MucusEditView from './symptoms/mucus'
|
import MucusEditView from './symptoms/mucus'
|
||||||
import { formatDateForViewHeader } from './labels/format'
|
import { formatDateForViewHeader } from './labels/format'
|
||||||
|
import CervixEditView from './symptoms/cervix'
|
||||||
import styles from '../../styles'
|
import styles from '../../styles'
|
||||||
import actionButtonModule from './action-buttons'
|
import actionButtonModule from './action-buttons'
|
||||||
|
|
||||||
@@ -48,7 +49,8 @@ export default class Day extends Component {
|
|||||||
{ dayView: <DayView cycleDay={this.cycleDay} showView={this.showView} />,
|
{ dayView: <DayView cycleDay={this.cycleDay} showView={this.showView} />,
|
||||||
bleedingEditView: <BleedingEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>,
|
bleedingEditView: <BleedingEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>,
|
||||||
temperatureEditView: <TemperatureEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>,
|
temperatureEditView: <TemperatureEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>,
|
||||||
mucusEditView: <MucusEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>
|
mucusEditView: <MucusEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>,
|
||||||
|
cervixEditView: <CervixEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons} />
|
||||||
}[this.state.visibleComponent]
|
}[this.state.visibleComponent]
|
||||||
}
|
}
|
||||||
</View >
|
</View >
|
||||||
|
|||||||
@@ -2,10 +2,16 @@ const bleeding = ['spotting', 'light', 'medium', 'heavy']
|
|||||||
const mucusFeeling = ['dry', 'nothing', 'wet', 'slippery']
|
const mucusFeeling = ['dry', 'nothing', 'wet', 'slippery']
|
||||||
const mucusTexture = ['nothing', 'creamy', 'egg white']
|
const mucusTexture = ['nothing', 'creamy', 'egg white']
|
||||||
const mucusNFP = ['t', 'Ø', 'f', 'S', '+S']
|
const mucusNFP = ['t', 'Ø', 'f', 'S', '+S']
|
||||||
|
const cervixOpening = ['closed', 'medium', 'open']
|
||||||
|
const cervixFirmness = ['hard', 'soft']
|
||||||
|
const cervixPosition = ['low', 'medium', 'high']
|
||||||
|
|
||||||
export {
|
export {
|
||||||
bleeding,
|
bleeding,
|
||||||
mucusFeeling,
|
mucusFeeling,
|
||||||
mucusTexture,
|
mucusTexture,
|
||||||
mucusNFP
|
mucusNFP,
|
||||||
|
cervixOpening,
|
||||||
|
cervixFirmness,
|
||||||
|
cervixPosition
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
import React, { Component } from 'react'
|
||||||
|
import {
|
||||||
|
View,
|
||||||
|
Text,
|
||||||
|
Switch
|
||||||
|
} from 'react-native'
|
||||||
|
import RadioForm from 'react-native-simple-radio-button'
|
||||||
|
import styles from '../../../styles'
|
||||||
|
import { saveSymptom } from '../../../db'
|
||||||
|
import {
|
||||||
|
cervixOpening as openingLabels,
|
||||||
|
cervixFirmness as firmnessLabels,
|
||||||
|
cervixPosition as positionLabels
|
||||||
|
} from '../labels/labels'
|
||||||
|
|
||||||
|
export default class Cervix extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
this.cycleDay = props.cycleDay
|
||||||
|
this.makeActionButtons = props.makeActionButtons
|
||||||
|
this.state = {
|
||||||
|
exclude: this.cycleDay.cervix ? this.cycleDay.cervix.exclude : false
|
||||||
|
};
|
||||||
|
|
||||||
|
/* eslint-disable react/no-direct-mutation-state */
|
||||||
|
['opening', 'firmness', 'position'].forEach(label => {
|
||||||
|
this.state[label] = this.cycleDay.cervix && this.cycleDay.cervix[label]
|
||||||
|
if (typeof this.state[label] !== 'number') {
|
||||||
|
this.state[label] = -1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
/* eslint-enable react/no-direct-mutation-state */
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const cervixOpeningRadioProps = [
|
||||||
|
{label: openingLabels[0], value: 0},
|
||||||
|
{label: openingLabels[1], value: 1},
|
||||||
|
{label: openingLabels[2], value: 2}
|
||||||
|
]
|
||||||
|
const cervixFirmnessRadioProps = [
|
||||||
|
{label: firmnessLabels[0], value: 0 },
|
||||||
|
{label: firmnessLabels[1], value: 1 }
|
||||||
|
]
|
||||||
|
const cervixPositionRadioProps = [
|
||||||
|
{label: positionLabels[0], value: 0 },
|
||||||
|
{label: positionLabels[1], value: 1 },
|
||||||
|
{label: positionLabels[2], value: 2 }
|
||||||
|
]
|
||||||
|
return(
|
||||||
|
<View style={ styles.symptomEditView }>
|
||||||
|
<Text style={styles.symptomDayView}>Cervix</Text>
|
||||||
|
<Text style={styles.symptomDayView}>Opening</Text>
|
||||||
|
<View style={styles.radioButtonRow}>
|
||||||
|
<RadioForm
|
||||||
|
radio_props={cervixOpeningRadioProps}
|
||||||
|
initial={this.state.opening}
|
||||||
|
formHorizontal={true}
|
||||||
|
labelHorizontal={false}
|
||||||
|
labelStyle={styles.radioButton}
|
||||||
|
onPress={(itemValue) => {
|
||||||
|
this.setState({opening: itemValue})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<Text style={styles.symptomDayView}>Firmness</Text>
|
||||||
|
<View style={styles.radioButtonRow}>
|
||||||
|
<RadioForm
|
||||||
|
radio_props={cervixFirmnessRadioProps}
|
||||||
|
initial={this.state.firmness}
|
||||||
|
formHorizontal={true}
|
||||||
|
labelHorizontal={false}
|
||||||
|
labelStyle={styles.radioButton}
|
||||||
|
onPress={(itemValue) => {
|
||||||
|
this.setState({firmness: itemValue})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<Text style={styles.symptomDayView}>Position</Text>
|
||||||
|
<View style={styles.radioButtonRow}>
|
||||||
|
<RadioForm
|
||||||
|
radio_props={cervixPositionRadioProps}
|
||||||
|
initial={this.state.position}
|
||||||
|
formHorizontal={true}
|
||||||
|
labelHorizontal={false}
|
||||||
|
labelStyle={styles.radioButton}
|
||||||
|
onPress={(itemValue) => {
|
||||||
|
this.setState({position: 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 style={styles.actionButtonRow}>
|
||||||
|
{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>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,17 +21,17 @@ export default class Mucus extends Component {
|
|||||||
this.makeActionButtons = props.makeActionButtons
|
this.makeActionButtons = props.makeActionButtons
|
||||||
this.state = {
|
this.state = {
|
||||||
exclude: this.cycleDay.mucus ? this.cycleDay.mucus.exclude : false
|
exclude: this.cycleDay.mucus ? this.cycleDay.mucus.exclude : false
|
||||||
}
|
};
|
||||||
|
|
||||||
this.state.currentFeelingValue = this.cycleDay.mucus && this.cycleDay.mucus.feeling
|
/* eslint-disable react/no-direct-mutation-state */
|
||||||
if (typeof this.state.currentFeelingValue !== 'number') {
|
['feeling', 'texture'].forEach(label => {
|
||||||
this.state.currentFeelingValue = -1
|
this.state[label] = this.cycleDay.mucus && this.cycleDay.mucus[label]
|
||||||
}
|
if (typeof this.state[label] !== 'number') {
|
||||||
|
this.state[label] = -1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
/* eslint-enable react/no-direct-mutation-state */
|
||||||
|
|
||||||
this.state.currentTextureValue = this.cycleDay.mucus && this.cycleDay.mucus.texture
|
|
||||||
if (typeof this.state.currentTextureValue !== 'number') {
|
|
||||||
this.state.currentTextureValue = -1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -53,12 +53,12 @@ export default class Mucus extends Component {
|
|||||||
<View style={styles.radioButtonRow}>
|
<View style={styles.radioButtonRow}>
|
||||||
<RadioForm
|
<RadioForm
|
||||||
radio_props={mucusFeelingRadioProps}
|
radio_props={mucusFeelingRadioProps}
|
||||||
initial={this.state.currentFeelingValue}
|
initial={this.state.feeling}
|
||||||
formHorizontal={true}
|
formHorizontal={true}
|
||||||
labelHorizontal={false}
|
labelHorizontal={false}
|
||||||
labelStyle={styles.radioButton}
|
labelStyle={styles.radioButton}
|
||||||
onPress={(itemValue) => {
|
onPress={(itemValue) => {
|
||||||
this.setState({ currentFeelingValue: itemValue })
|
this.setState({feeling: itemValue })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
@@ -66,12 +66,12 @@ export default class Mucus extends Component {
|
|||||||
<View style={styles.radioButtonRow}>
|
<View style={styles.radioButtonRow}>
|
||||||
<RadioForm
|
<RadioForm
|
||||||
radio_props={mucusTextureRadioProps}
|
radio_props={mucusTextureRadioProps}
|
||||||
initial={this.state.currentTextureValue}
|
initial={this.state.texture}
|
||||||
formHorizontal={true}
|
formHorizontal={true}
|
||||||
labelHorizontal={false}
|
labelHorizontal={false}
|
||||||
labelStyle={styles.radioButton}
|
labelStyle={styles.radioButton}
|
||||||
onPress={(itemValue) => {
|
onPress={(itemValue) => {
|
||||||
this.setState({ currentTextureValue: itemValue })
|
this.setState({texture: itemValue })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
@@ -92,13 +92,13 @@ export default class Mucus extends Component {
|
|||||||
cycleDay: this.cycleDay,
|
cycleDay: this.cycleDay,
|
||||||
saveAction: () => {
|
saveAction: () => {
|
||||||
saveSymptom('mucus', this.cycleDay, {
|
saveSymptom('mucus', this.cycleDay, {
|
||||||
feeling: this.state.currentFeelingValue,
|
feeling: this.state.feeling,
|
||||||
texture: this.state.currentTextureValue,
|
texture: this.state.texture,
|
||||||
computedNfp: computeSensiplanValue(this.state.currentFeelingValue, this.state.currentTextureValue),
|
computedNfp: computeSensiplanValue(this.state.feeling, this.state.texture),
|
||||||
exclude: this.state.exclude
|
exclude: this.state.exclude
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
saveDisabled: this.state.currentFeelingValue === -1 || this.state.currentTextureValue === -1
|
saveDisabled: this.state.feeling === -1 || this.state.texture === -1
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -32,6 +32,16 @@ const MucusSchema = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CervixSchema = {
|
||||||
|
name: 'Cervix',
|
||||||
|
properties: {
|
||||||
|
opening: 'int',
|
||||||
|
firmness: 'int',
|
||||||
|
position: {type: 'int', optional: true },
|
||||||
|
exclude: 'bool'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const CycleDaySchema = {
|
const CycleDaySchema = {
|
||||||
name: 'CycleDay',
|
name: 'CycleDay',
|
||||||
primaryKey: 'date',
|
primaryKey: 'date',
|
||||||
@@ -48,6 +58,10 @@ const CycleDaySchema = {
|
|||||||
mucus: {
|
mucus: {
|
||||||
type: 'Mucus',
|
type: 'Mucus',
|
||||||
optional: true
|
optional: true
|
||||||
|
},
|
||||||
|
cervix: {
|
||||||
|
type: 'Cervix',
|
||||||
|
optional: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,7 +71,8 @@ const db = new Realm({
|
|||||||
CycleDaySchema,
|
CycleDaySchema,
|
||||||
TemperatureSchema,
|
TemperatureSchema,
|
||||||
BleedingSchema,
|
BleedingSchema,
|
||||||
MucusSchema
|
MucusSchema,
|
||||||
|
CervixSchema
|
||||||
],
|
],
|
||||||
// we only want this in dev mode
|
// we only want this in dev mode
|
||||||
deleteRealmIfMigrationNeeded: true
|
deleteRealmIfMigrationNeeded: true
|
||||||
|
|||||||
Reference in New Issue
Block a user