Skip to content
Snippets Groups Projects
Commit 30839b55 authored by emelko's avatar emelko
Browse files

Adds desire as a tracking category to our app;

no exclude, no fancy nothing else, only pure desire tracking.
parent f7efadb0
No related branches found
No related tags found
No related merge requests found
...@@ -93,6 +93,15 @@ export default class DayView extends Component { ...@@ -93,6 +93,15 @@ export default class DayView extends Component {
</Button> </Button>
</View> </View>
</View> </View>
<View style={ styles.symptomViewRowInline }>
<Text style={styles.symptomDayView}>Desire</Text>
<View style={styles.symptomEditButton}>
<Button
onPress={() => this.showView('desireEditView')}
title={getLabel('desire', cycleDay.desire)}>
</Button>
</View>
</View>
</View > </View >
) )
} }
...@@ -137,9 +146,15 @@ function getLabel(symptomName, symptom) { ...@@ -137,9 +146,15 @@ function getLabel(symptomName, symptom) {
}, },
note: note => { note: note => {
return note.value.slice(0, 12) + '...' return note.value.slice(0, 12) + '...'
},
desire: desire => {
if (typeof desire.value === 'number') {
const desireLabel = `${positionLabels[desire.value]}`
return desireLabel
}
} }
} }
if (!symptom) return 'edit' if (!symptom) return 'edit'
return labels[symptomName](symptom) || 'edit' return labels[symptomName](symptom) || 'edit'
} }
\ No newline at end of file
...@@ -12,6 +12,7 @@ import TemperatureEditView from './symptoms/temperature' ...@@ -12,6 +12,7 @@ import TemperatureEditView from './symptoms/temperature'
import MucusEditView from './symptoms/mucus' import MucusEditView from './symptoms/mucus'
import CervixEditView from './symptoms/cervix' import CervixEditView from './symptoms/cervix'
import NoteEditView from './symptoms/note' import NoteEditView from './symptoms/note'
import DesireEditView from './symptoms/desire'
import { formatDateForViewHeader } from './labels/format' import { formatDateForViewHeader } from './labels/format'
import styles from '../../styles' import styles from '../../styles'
import actionButtonModule from './action-buttons' import actionButtonModule from './action-buttons'
...@@ -61,7 +62,8 @@ export default class Day extends Component { ...@@ -61,7 +62,8 @@ export default class Day extends Component {
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} />, cervixEditView: <CervixEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons} />,
noteEditView: <NoteEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons} /> noteEditView: <NoteEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons} />,
desireEditView: <DesireEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons} />
}[this.state.visibleComponent] }[this.state.visibleComponent]
} }
</View > </View >
......
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 (
<View style={styles.symptomEditView}>
<Text style={styles.symptomDayView}>Desire</Text>
<View style={styles.radioButtonRow}>
<RadioForm
radio_props={desireRadioProps}
initial={this.state.currentValue}
formHorizontal={true}
labelHorizontal={false}
labelStyle={styles.radioButton}
onPress={(itemValue) => {
this.setState({ currentValue: itemValue })
}}
/>
</View>
<View style={styles.actionButtonRow}>
{this.makeActionButtons(
{
symptom: 'desire',
cycleDay: this.cycleDay,
saveAction: () => {
saveSymptom('desire', this.cycleDay, { value: this.state.currentValue })
},
saveDisabled: this.state.currentValue === -1
}
)}
</View>
</View>
)
}
}
...@@ -53,6 +53,13 @@ const NoteSchema = { ...@@ -53,6 +53,13 @@ const NoteSchema = {
} }
} }
const DesireSchema = {
name: 'Desire',
properties: {
value: 'int'
}
}
const CycleDaySchema = { const CycleDaySchema = {
name: 'CycleDay', name: 'CycleDay',
primaryKey: 'date', primaryKey: 'date',
...@@ -77,6 +84,10 @@ const CycleDaySchema = { ...@@ -77,6 +84,10 @@ const CycleDaySchema = {
note: { note: {
type: 'Note', type: 'Note',
optional: true optional: true
},
desire: {
type: 'Desire',
optional: true
} }
} }
} }
...@@ -88,7 +99,8 @@ const realmConfig = { ...@@ -88,7 +99,8 @@ const realmConfig = {
BleedingSchema, BleedingSchema,
MucusSchema, MucusSchema,
CervixSchema, CervixSchema,
NoteSchema NoteSchema,
DesireSchema
], ],
// we only want this in dev mode // we only want this in dev mode
deleteRealmIfMigrationNeeded: true deleteRealmIfMigrationNeeded: true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment