diff --git a/components/cycle-day/cycle-day-overview.js b/components/cycle-day/cycle-day-overview.js index baccc50..0c9b9d7 100644 --- a/components/cycle-day/cycle-day-overview.js +++ b/components/cycle-day/cycle-day-overview.js @@ -20,7 +20,9 @@ import { cervixOpening as openingLabels, cervixFirmness as firmnessLabels, cervixPosition as positionLabels, - intensity as intensityLabels + intensity as intensityLabels, + pain as painLabels, + sex as sexLabels } from './labels/labels' export default class CycleDayOverView extends Component { @@ -101,6 +103,11 @@ export default class CycleDayOverView extends Component { onPress={() => this.navigate('NoteEditView')} data={getLabel('note', cycleDay.note)} /> + this.navigate('PainEditView')} + data={getLabel('pain', cycleDay.pain)} + /> {/* this is just to make the last row adhere to the grid (and) because there are no pseudo properties in RN */} @@ -163,15 +170,42 @@ function getLabel(symptomName, symptom) { } }, sex: sex => { - const sexLabel = [] - if ( sex.solo || sex.partner ) { - sexLabel.push('activity') + let sexLabel = [] + if (sex && Object.values(sex).some(val => val)){ + Object.keys(sex).forEach(key => { + if(sex[key] && key !== 'other' && key !== 'note') { + sexLabel.push(sexLabels[key]) + } + if(key === 'other' && sex.other) { + let label = sexLabels[key] + if(sex.note) { + label = `${label} (${sex.note})` + } + sexLabel.push(label) + } + }) + sexLabel = sexLabel.join(', ') } - if (sex.condom || sex.pill || sex.iud || - sex.patch || sex.ring || sex.implant || sex.other) { - sexLabel.push('contraceptive') + return sexLabel + }, + pain: pain => { + let painLabel = [] + if (pain && Object.values(pain).some(val => val)){ + Object.keys(pain).forEach(key => { + if(pain[key] && key !== 'other' && key !== 'note') { + painLabel.push(painLabels[key]) + } + if(key === 'other' && pain.other) { + let label = painLabels[key] + if(pain.note) { + label = `${label} (${pain.note})` + } + painLabel.push(label) + } + }) + painLabel = painLabel.join(', ') } - return sexLabel.join(', ') + return painLabel } } @@ -223,4 +257,4 @@ class FillerBoxes extends Component { } return fillerBoxes } -} \ No newline at end of file +} diff --git a/components/cycle-day/labels/labels.js b/components/cycle-day/labels/labels.js index 6650e33..90faf28 100644 --- a/components/cycle-day/labels/labels.js +++ b/components/cycle-day/labels/labels.js @@ -6,11 +6,9 @@ export const cervixOpening = ['closed', 'medium', 'open'] export const cervixFirmness = ['hard', 'soft'] export const cervixPosition = ['low', 'medium', 'high'] export const intensity = ['low', 'medium', 'high'] -export const sexActivity = { +export const sex = { solo: 'Solo', - partner: 'Partner' -} -export const contraceptives = { + partner: 'Partner', condom: 'Condom', pill: 'Pill', iud: 'IUD', @@ -20,6 +18,18 @@ export const contraceptives = { other: 'Other' } +export const pain = { + cramps: 'Cramps', + ovulationPain: 'Ovulation pain', + headache: 'Headache', + backache: 'Backache', + nausea: 'Nausea', + tenderBreasts: 'Tender breasts', + migraine: 'Migraine', + other: 'Other', + note: 'Note' +} + export const fertilityStatus = { fertile: 'fertile', infertile: 'infertile', diff --git a/components/cycle-day/symptoms/index.js b/components/cycle-day/symptoms/index.js index 12622b7..014e9fe 100644 --- a/components/cycle-day/symptoms/index.js +++ b/components/cycle-day/symptoms/index.js @@ -5,6 +5,7 @@ import CervixEditView from './cervix' import NoteEditView from './note' import DesireEditView from './desire' import SexEditView from './sex' +import PainEditView from './pain' export default { BleedingEditView, @@ -13,5 +14,6 @@ export default { CervixEditView, NoteEditView, DesireEditView, - SexEditView -} \ No newline at end of file + SexEditView, + PainEditView +} diff --git a/components/cycle-day/symptoms/note.js b/components/cycle-day/symptoms/note.js index 6bf0cb6..3e36441 100644 --- a/components/cycle-day/symptoms/note.js +++ b/components/cycle-day/symptoms/note.js @@ -9,7 +9,7 @@ import styles from '../../../styles' import { saveSymptom } from '../../../db' import ActionButtonFooter from './action-button-footer' -export default class Temp extends Component { +export default class Note extends Component { constructor(props) { super(props) this.cycleDay = props.cycleDay @@ -27,6 +27,7 @@ export default class Temp extends Component { { @@ -50,4 +51,4 @@ export default class Temp extends Component { ) } -} \ No newline at end of file +} diff --git a/components/cycle-day/symptoms/pain.js b/components/cycle-day/symptoms/pain.js new file mode 100644 index 0000000..6365065 --- /dev/null +++ b/components/cycle-day/symptoms/pain.js @@ -0,0 +1,144 @@ +import React, { Component } from 'react' +import { + CheckBox, + ScrollView, + Text, + TextInput, + View +} from 'react-native' +import styles from '../../../styles' +import { saveSymptom } from '../../../db' +import { + pain as painLabels +} from '../labels/labels' +import ActionButtonFooter from './action-button-footer' + +export default class Pain extends Component { + constructor(props) { + super(props) + this.cycleDay = props.cycleDay + this.state = {} + if (this.cycleDay.pain !== null ) { + Object.assign(this.state, this.cycleDay.pain) + if (this.cycleDay.pain && this.cycleDay.pain.note) { + this.state.other = true + } + } + } + + render() { + return ( + + + + + {painLabels.cramps} + { + this.setState({cramps: val}) + }} + /> + + {painLabels.ovulationPain} + + { + this.setState({ovulationPain: val}) + }} + /> + + + + {painLabels.headache} + + { + this.setState({headache: val}) + }} + /> + + {painLabels.backache} + + { + this.setState({backache: val}) + }} + /> + + + + {painLabels.nausea} + + { + this.setState({nausea: val}) + }} + /> + + {painLabels.tenderBreasts} + + { + this.setState({tenderBreasts: val}) + }} + /> + + + + {painLabels.migraine} + + { + this.setState({migraine: val}) + }} + /> + + {painLabels.other} + + { + this.setState({ + other: val, + focusTextArea: true + }) + }} + /> + + { this.state.other && + { + this.setState({note: val}) + }} + /> + } + + + { + const copyOfState = Object.assign({}, this.state) + if (!copyOfState.other) { + copyOfState.note = null + } + saveSymptom('pain', this.cycleDay, copyOfState) + }} + saveDisabled={Object.values(this.state).every(value => !value)} + navigate={this.props.navigate} + /> + + ) + } +} diff --git a/components/cycle-day/symptoms/sex.js b/components/cycle-day/symptoms/sex.js index 2ca06ef..f90db21 100644 --- a/components/cycle-day/symptoms/sex.js +++ b/components/cycle-day/symptoms/sex.js @@ -8,10 +8,7 @@ import { } from 'react-native' import styles from '../../../styles' import { saveSymptom } from '../../../db' -import { - sexActivity as activityLabels, - contraceptives as contraceptiveLabels -} from '../labels/labels' +import { sex as sexLabels } from '../labels/labels' import ActionButtonFooter from './action-button-footer' export default class Sex extends Component { @@ -36,14 +33,16 @@ export default class Sex extends Component { - {activityLabels.solo} + {sexLabels.solo} { this.setState({ solo: val }) }} /> - {activityLabels.partner} + + {sexLabels.partner} + { @@ -54,7 +53,7 @@ export default class Sex extends Component { CONTRACEPTIVES - {contraceptiveLabels.condom} + {sexLabels.condom} - {contraceptiveLabels.pill} + {sexLabels.pill} - {contraceptiveLabels.iud} + {sexLabels.iud} - {contraceptiveLabels.patch} + {sexLabels.patch} - {contraceptiveLabels.ring} + {sexLabels.ring} - {contraceptiveLabels.implant} + {sexLabels.implant} - {contraceptiveLabels.other} + {sexLabels.other} ) } -} \ No newline at end of file +} diff --git a/components/labels.js b/components/labels.js index 5f32eb5..c4c9cba 100644 --- a/components/labels.js +++ b/components/labels.js @@ -63,7 +63,8 @@ export const headerTitles = { CervixEditView: 'Cervix', NoteEditView: 'Note', DesireEditView: 'Desire', - SexEditView: 'Sex' + SexEditView: 'Sex', + PainEditView: 'Pain' } export const stats = { diff --git a/db/index.js b/db/index.js index be82049..1845674 100644 --- a/db/index.js +++ b/db/index.js @@ -80,6 +80,21 @@ const SexSchema = { } } +const PainSchema = { + name: 'Pain', + properties: { + cramps: { type: 'bool', optional: true }, + ovulationPain: { type: 'bool', optional: true }, + headache: { type: 'bool', optional: true }, + backache: { type: 'bool', optional: true }, + nausea: { type: 'bool', optional: true }, + tenderBreasts: { type: 'bool', optional: true }, + migraine: { type: 'bool', optional: true }, + other: { type: 'bool', optional: true }, + note: { type: 'string', optional: true } + } +} + const CycleDaySchema = { name: 'CycleDay', primaryKey: 'date', @@ -112,6 +127,10 @@ const CycleDaySchema = { sex: { type: 'Sex', optional: true + }, + pain: { + type: 'Pain', + optional: true } } } @@ -125,7 +144,8 @@ const realmConfig = { CervixSchema, NoteSchema, DesireSchema, - SexSchema + SexSchema, + PainSchema ], // we only want this in dev mode deleteRealmIfMigrationNeeded: true