Adding pain with 7 boolean values to track

This commit is contained in:
Bl00dyMarie
2018-08-17 14:14:51 +02:00
parent b09137772c
commit 30752a05c2
7 changed files with 1261 additions and 353 deletions
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')}
data={getLabel('sex', cycleDay.sex)}
/>
<SymptomBox
title='Pain'
onPress={() => this.navigate('PainEditView')}
/>
{/* this is just to make the last row adhere to the grid
(and) because there are no pseudo properties in RN */}
<FillerBoxes />
@@ -162,6 +166,16 @@ function getLabel(symptomName, symptom) {
sexLabel.push('contraceptive')
}
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'
}
}
+10
View File
@@ -20,6 +20,16 @@ export const contraceptives = {
other: 'Other'
}
export const pain = {
cramps: 'Cramps',
ovulationPain: 'Ovulation pain',
headache: 'Headache',
backache: 'Backache',
nausea: 'Nausea',
tenderBreasts: 'Tender breasts',
migraine: 'Migraine'
}
export const fertilityStatus = {
fertile: 'fertile',
infertile: 'infertile',
+3 -1
View File
@@ -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
SexEditView,
PainEditView
}
+111
View File
@@ -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
View File
@@ -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 = {
name: 'CycleDay',
primaryKey: 'date',
@@ -108,6 +120,10 @@ const CycleDaySchema = {
sex: {
type: 'Sex',
optional: true
},
pain: {
type: 'Pain',
optional: true
}
}
}
@@ -121,7 +137,8 @@ const realmConfig = {
CervixSchema,
NoteSchema,
DesireSchema,
SexSchema
SexSchema,
PainSchema
],
// we only want this in dev mode
deleteRealmIfMigrationNeeded: true
+349 -349
View File
File diff suppressed because it is too large Load Diff