diff --git a/components/cycle-day/cycle-day-overview.js b/components/cycle-day/cycle-day-overview.js
index 5218864..f51392f 100644
--- a/components/cycle-day/cycle-day-overview.js
+++ b/components/cycle-day/cycle-day-overview.js
@@ -93,6 +93,15 @@ export default class DayView extends Component {
+
+ Desire
+
+
+
+
)
}
@@ -137,9 +146,15 @@ function getLabel(symptomName, symptom) {
},
note: note => {
return note.value.slice(0, 12) + '...'
+ },
+ desire: desire => {
+ if (typeof desire.value === 'number') {
+ const desireLabel = `${positionLabels[desire.value]}`
+ return desireLabel
+ }
}
}
if (!symptom) return 'edit'
return labels[symptomName](symptom) || 'edit'
-}
\ No newline at end of file
+}
diff --git a/components/cycle-day/index.js b/components/cycle-day/index.js
index fa8aedf..7017583 100644
--- a/components/cycle-day/index.js
+++ b/components/cycle-day/index.js
@@ -12,6 +12,7 @@ import TemperatureEditView from './symptoms/temperature'
import MucusEditView from './symptoms/mucus'
import CervixEditView from './symptoms/cervix'
import NoteEditView from './symptoms/note'
+import DesireEditView from './symptoms/desire'
import { formatDateForViewHeader } from './labels/format'
import styles from '../../styles'
import actionButtonModule from './action-buttons'
@@ -61,7 +62,8 @@ export default class Day extends Component {
temperatureEditView: ,
mucusEditView: ,
cervixEditView: ,
- noteEditView:
+ noteEditView: ,
+ desireEditView:
}[this.state.visibleComponent]
}
diff --git a/components/cycle-day/symptoms/desire.js b/components/cycle-day/symptoms/desire.js
new file mode 100644
index 0000000..9fdd99b
--- /dev/null
+++ b/components/cycle-day/symptoms/desire.js
@@ -0,0 +1,59 @@
+import React, { Component } from 'react'
+import {
+ View,
+ Text
+} from 'react-native'
+import RadioForm from 'react-native-simple-radio-button'
+import styles from '../../../styles'
+import { saveSymptom } from '../../../db'
+import { positionOrIntensity as labels } from '../labels/labels'
+
+export default class Desire extends Component {
+ constructor(props) {
+ super(props)
+ this.cycleDay = props.cycleDay
+ this.makeActionButtons = props.makeActionButtons
+ let desireValue = this.cycleDay.desire && this.cycleDay.desire.value
+ if (!(typeof desireValue === 'number')) {
+ desireValue = -1
+ }
+ this.state = { currentValue: desireValue }
+ }
+
+ render() {
+ const desireRadioProps = [
+ { label: labels[0], value: 0 },
+ { label: labels[1], value: 1 },
+ { label: labels[2], value: 2 }
+ ]
+ return (
+
+ Desire
+
+ {
+ this.setState({ currentValue: itemValue })
+ }}
+ />
+
+
+ {this.makeActionButtons(
+ {
+ symptom: 'desire',
+ cycleDay: this.cycleDay,
+ saveAction: () => {
+ saveSymptom('desire', this.cycleDay, { value: this.state.currentValue })
+ },
+ saveDisabled: this.state.currentValue === -1
+ }
+ )}
+
+
+ )
+ }
+}
diff --git a/db/index.js b/db/index.js
index 80dc08e..8dadf1c 100644
--- a/db/index.js
+++ b/db/index.js
@@ -53,6 +53,13 @@ const NoteSchema = {
}
}
+const DesireSchema = {
+ name: 'Desire',
+ properties: {
+ value: 'int'
+ }
+}
+
const CycleDaySchema = {
name: 'CycleDay',
primaryKey: 'date',
@@ -77,6 +84,10 @@ const CycleDaySchema = {
note: {
type: 'Note',
optional: true
+ },
+ desire: {
+ type: 'Desire',
+ optional: true
}
}
}
@@ -88,7 +99,8 @@ const realmConfig = {
BleedingSchema,
MucusSchema,
CervixSchema,
- NoteSchema
+ NoteSchema,
+ DesireSchema
],
// we only want this in dev mode
deleteRealmIfMigrationNeeded: true