Adding pain with 7 boolean values to track
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -94,6 +94,10 @@ export default class CycleDayOverView extends Component {
|
|||||||
onPress={() => this.navigate('SexEditView')}
|
onPress={() => this.navigate('SexEditView')}
|
||||||
data={getLabel('sex', cycleDay.sex)}
|
data={getLabel('sex', cycleDay.sex)}
|
||||||
/>
|
/>
|
||||||
|
<SymptomBox
|
||||||
|
title='Pain'
|
||||||
|
onPress={() => this.navigate('PainEditView')}
|
||||||
|
/>
|
||||||
{/* this is just to make the last row adhere to the grid
|
{/* this is just to make the last row adhere to the grid
|
||||||
(and) because there are no pseudo properties in RN */}
|
(and) because there are no pseudo properties in RN */}
|
||||||
<FillerBoxes />
|
<FillerBoxes />
|
||||||
@@ -162,6 +166,16 @@ function getLabel(symptomName, symptom) {
|
|||||||
sexLabel.push('contraceptive')
|
sexLabel.push('contraceptive')
|
||||||
}
|
}
|
||||||
return sexLabel.join(', ')
|
return sexLabel.join(', ')
|
||||||
|
},
|
||||||
|
pain: pain => {
|
||||||
|
let painLabel = ''
|
||||||
|
if (pain.cramps || pain.ovulationPain || pain.headache ||
|
||||||
|
pain.backache || pain.nausea || pain.tenderBreasts ||
|
||||||
|
pain.migraine
|
||||||
|
) {
|
||||||
|
painLabel += 'Pain'
|
||||||
|
}
|
||||||
|
return painLabel ? painLabel : 'edit'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,4 +227,4 @@ class FillerBoxes extends Component {
|
|||||||
}
|
}
|
||||||
return fillerBoxes
|
return fillerBoxes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,16 @@ export const contraceptives = {
|
|||||||
other: 'Other'
|
other: 'Other'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const pain = {
|
||||||
|
cramps: 'Cramps',
|
||||||
|
ovulationPain: 'Ovulation pain',
|
||||||
|
headache: 'Headache',
|
||||||
|
backache: 'Backache',
|
||||||
|
nausea: 'Nausea',
|
||||||
|
tenderBreasts: 'Tender breasts',
|
||||||
|
migraine: 'Migraine'
|
||||||
|
}
|
||||||
|
|
||||||
export const fertilityStatus = {
|
export const fertilityStatus = {
|
||||||
fertile: 'fertile',
|
fertile: 'fertile',
|
||||||
infertile: 'infertile',
|
infertile: 'infertile',
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import CervixEditView from './cervix'
|
|||||||
import NoteEditView from './note'
|
import NoteEditView from './note'
|
||||||
import DesireEditView from './desire'
|
import DesireEditView from './desire'
|
||||||
import SexEditView from './sex'
|
import SexEditView from './sex'
|
||||||
|
import PainEditView from './pain'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
BleedingEditView,
|
BleedingEditView,
|
||||||
@@ -13,5 +14,6 @@ export default {
|
|||||||
CervixEditView,
|
CervixEditView,
|
||||||
NoteEditView,
|
NoteEditView,
|
||||||
DesireEditView,
|
DesireEditView,
|
||||||
SexEditView
|
SexEditView,
|
||||||
}
|
PainEditView
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
import React, { Component } from 'react'
|
||||||
|
import {
|
||||||
|
CheckBox,
|
||||||
|
Text,
|
||||||
|
View
|
||||||
|
} from 'react-native'
|
||||||
|
import styles from '../../../styles'
|
||||||
|
import { saveSymptom } from '../../../db'
|
||||||
|
import {
|
||||||
|
pain as painLabels
|
||||||
|
} from '../labels/labels'
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.symptomEditView}>
|
||||||
|
<Text style={styles.symptomDayView}>PAIN</Text>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>{painLabels.cramps}</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.cramps}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({cramps: val})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Text style={styles.symptomDayView}>{painLabels.ovulationPain}</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.ovulationPain}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({ovulationPain: val})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>
|
||||||
|
{painLabels.headache}
|
||||||
|
</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.headache}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({headache: val})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Text style={styles.symptomDayView}>
|
||||||
|
{painLabels.backache}
|
||||||
|
</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.backache}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({backache: val})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>
|
||||||
|
{painLabels.nausea}
|
||||||
|
</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.nausea}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({nausea: val})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Text style={styles.symptomDayView}>
|
||||||
|
{painLabels.tenderBreasts}
|
||||||
|
</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.tenderBreasts}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({tenderBreasts: val})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>
|
||||||
|
{painLabels.migraine}
|
||||||
|
</Text>
|
||||||
|
<CheckBox
|
||||||
|
value={this.state.migraine}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({migraine: val})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.actionButtonRow}>
|
||||||
|
{this.props.makeActionButtons(
|
||||||
|
{
|
||||||
|
symptom: 'pain',
|
||||||
|
cycleDay: this.cycleDay,
|
||||||
|
saveAction: () => {
|
||||||
|
const copyOfState = Object.assign({}, this.state)
|
||||||
|
saveSymptom('pain', this.cycleDay, copyOfState)
|
||||||
|
},
|
||||||
|
saveDisabled: Object.values(this.state).every(value => !value)
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
-1
@@ -76,6 +76,18 @@ 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 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const CycleDaySchema = {
|
const CycleDaySchema = {
|
||||||
name: 'CycleDay',
|
name: 'CycleDay',
|
||||||
primaryKey: 'date',
|
primaryKey: 'date',
|
||||||
@@ -108,6 +120,10 @@ const CycleDaySchema = {
|
|||||||
sex: {
|
sex: {
|
||||||
type: 'Sex',
|
type: 'Sex',
|
||||||
optional: true
|
optional: true
|
||||||
|
},
|
||||||
|
pain: {
|
||||||
|
type: 'Pain',
|
||||||
|
optional: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,7 +137,8 @@ const realmConfig = {
|
|||||||
CervixSchema,
|
CervixSchema,
|
||||||
NoteSchema,
|
NoteSchema,
|
||||||
DesireSchema,
|
DesireSchema,
|
||||||
SexSchema
|
SexSchema,
|
||||||
|
PainSchema
|
||||||
],
|
],
|
||||||
// we only want this in dev mode
|
// we only want this in dev mode
|
||||||
deleteRealmIfMigrationNeeded: true
|
deleteRealmIfMigrationNeeded: true
|
||||||
|
|||||||
Generated
+349
-349
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user