Skip to content
Snippets Groups Projects
Commit a64bfbcd authored by Bl00dyMarie's avatar Bl00dyMarie
Browse files

Implement Sex \o/:

* Offers tracking sex activities and contraceptives as much as you want
* "Other" contraceptive allows to specify with text input
parent 7ea6a683
No related branches found
No related tags found
No related merge requests found
...@@ -98,11 +98,20 @@ export default class DayView extends Component { ...@@ -98,11 +98,20 @@ export default class DayView extends Component {
<Text style={styles.symptomDayView}>Desire</Text> <Text style={styles.symptomDayView}>Desire</Text>
<View style={styles.symptomEditButton}> <View style={styles.symptomEditButton}>
<Button <Button
onPress={() => this.showView('desireEditView')} onPress={() => this.showView('DesireEditView')}
title={getLabel('desire', cycleDay.desire)}> title={getLabel('desire', cycleDay.desire)}>
</Button> </Button>
</View> </View>
</View> </View>
<View style={styles.symptomViewRowInline}>
<Text style={styles.symptomDayView}>Sex</Text>
<View style={styles.symptomEditButton}>
<Button
onPress={() => this.showView('SexEditView')}
title={getLabel('sex', cycleDay.sex)}>
</Button>
</View>
</View>
</View > </View >
) )
} }
...@@ -132,15 +141,22 @@ function getLabel(symptomName, symptom) { ...@@ -132,15 +141,22 @@ function getLabel(symptomName, symptom) {
typeof mucus.texture === 'number' && typeof mucus.texture === 'number' &&
typeof mucus.value === 'number' typeof mucus.value === 'number'
) { ) {
let mucusLabel = `${feelingLabels[mucus.feeling]} + ${textureLabels[mucus.texture]} ( ${computeSensiplanMucusLabels[mucus.value]} )` let mucusLabel =
`${feelingLabels[mucus.feeling]} +
${textureLabels[mucus.texture]}
( ${computeSensiplanMucusLabels[mucus.value]} )`
if (mucus.exclude) mucusLabel = "( " + mucusLabel + " )" if (mucus.exclude) mucusLabel = "( " + mucusLabel + " )"
return mucusLabel return mucusLabel
} }
}, },
cervix: cervix => { cervix: cervix => {
if (cervix.opening > -1 && cervix.firmness > -1) { if (cervix.opening > -1 && cervix.firmness > -1) {
let cervixLabel = `${openingLabels[cervix.opening]} + ${firmnessLabels[cervix.firmness]}` let cervixLabel =
if (cervix.position > -1) cervixLabel += `+ ${positionLabels[cervix.position]}` `${openingLabels[cervix.opening]} +
${firmnessLabels[cervix.firmness]}`
if (cervix.position > -1) {
cervixLabel += `+ ${positionLabels[cervix.position]}`
}
if (cervix.exclude) cervixLabel = "( " + cervixLabel + " )" if (cervix.exclude) cervixLabel = "( " + cervixLabel + " )"
return cervixLabel return cervixLabel
} }
...@@ -153,6 +169,17 @@ function getLabel(symptomName, symptom) { ...@@ -153,6 +169,17 @@ function getLabel(symptomName, symptom) {
const desireLabel = `${intensityLabels[desire.value]}` const desireLabel = `${intensityLabels[desire.value]}`
return desireLabel return desireLabel
} }
},
sex: sex => {
let sexLabel = ''
if ( sex.solo || sex.partner ) {
sexLabel += 'Activity '
}
if (sex.condom || sex.pill || sex.iud ||
sex.patch || sex.ring || sex.implant || sex.other) {
sexLabel += 'Contraceptive'
}
return sexLabel ? sexLabel : 'edit'
} }
} }
......
...@@ -6,6 +6,19 @@ export const cervixOpening = ['closed', 'medium', 'open'] ...@@ -6,6 +6,19 @@ export const cervixOpening = ['closed', 'medium', 'open']
export const cervixFirmness = ['hard', 'soft'] export const cervixFirmness = ['hard', 'soft']
export const cervixPosition = ['low', 'medium', 'high'] export const cervixPosition = ['low', 'medium', 'high']
export const intensity = ['low', 'medium', 'high'] export const intensity = ['low', 'medium', 'high']
export const sexActivity = {
solo: 'Solo',
partner: 'Partner'
}
export const contraceptives = {
condom: 'Condom',
pill: 'Pill',
iud: 'IUD',
patch: 'Patch',
ring: 'Ring',
implant: 'Implant',
other: 'Other'
}
export const fertilityStatus = { export const fertilityStatus = {
fertile: 'fertile', fertile: 'fertile',
......
...@@ -4,6 +4,7 @@ import MucusEditView from './mucus' ...@@ -4,6 +4,7 @@ import MucusEditView from './mucus'
import CervixEditView from './cervix' import CervixEditView from './cervix'
import NoteEditView from './note' import NoteEditView from './note'
import DesireEditView from './desire' import DesireEditView from './desire'
import SexEditView from './sex'
export default { export default {
BleedingEditView, BleedingEditView,
...@@ -11,5 +12,6 @@ export default { ...@@ -11,5 +12,6 @@ export default {
MucusEditView, MucusEditView,
CervixEditView, CervixEditView,
NoteEditView, NoteEditView,
DesireEditView DesireEditView,
} SexEditView
\ No newline at end of file }
import React, { Component } from 'react'
import {
CheckBox,
Text,
TextInput,
View
} from 'react-native'
import styles from '../../../styles'
import { saveSymptom } from '../../../db'
import {
sexActivity as activityLabels,
contraceptives as contraceptiveLabels
} from '../labels/labels'
export default class Sex extends Component {
constructor(props) {
super(props)
this.cycleDay = props.cycleDay
this.state = {}
if (this.cycleDay.sex !== null ) {
Object.assign(this.state, this.cycleDay.sex)
// We make sure other is always true when there is a note,
// e.g. when import is messed up.
if (this.cycleDay.sex && this.cycleDay.sex.note) {
this.state.other = true
}
}
}
render() {
return (
<View style={styles.symptomEditView}>
<Text style={styles.symptomDayView}>SEX</Text>
<View style={styles.symptomViewRowInline}>
<Text style={styles.symptomDayView}>{activityLabels.solo}</Text>
<CheckBox
value={this.state.solo}
onValueChange={(val) => {
this.setState({solo: val})
}}
/>
<Text style={styles.symptomDayView}>{activityLabels.partner}</Text>
<CheckBox
value={this.state.partner}
onValueChange={(val) => {
this.setState({partner: val})
}}
/>
</View>
<Text style={styles.symptomDayView}>CONTRACEPTIVES</Text>
<View style={styles.symptomViewRowInline}>
<Text style={styles.symptomDayView}>
{contraceptiveLabels.condom}
</Text>
<CheckBox
value={this.state.condom}
onValueChange={(val) => {
this.setState({condom: val})
}}
/>
<Text style={styles.symptomDayView}>
{contraceptiveLabels.pill}
</Text>
<CheckBox
value={this.state.pill}
onValueChange={(val) => {
this.setState({pill: val})
}}
/>
</View>
<View style={styles.symptomViewRowInline}>
<Text style={styles.symptomDayView}>
{contraceptiveLabels.iud}
</Text>
<CheckBox
value={this.state.iud}
onValueChange={(val) => {
this.setState({iud: val})
}}
/>
<Text style={styles.symptomDayView}>
{contraceptiveLabels.patch}
</Text>
<CheckBox
value={this.state.patch}
onValueChange={(val) => {
this.setState({patch: val})
}}
/>
</View>
<View style={styles.symptomViewRowInline}>
<Text style={styles.symptomDayView}>
{contraceptiveLabels.ring}
</Text>
<CheckBox
value={this.state.ring}
onValueChange={(val) => {
this.setState({ring: val})
}}
/>
<Text style={styles.symptomDayView}>
{contraceptiveLabels.implant}
</Text>
<CheckBox
value={this.state.implant}
onValueChange={(val) => {
this.setState({implant: val})
}}
/>
</View>
<View style={styles.symptomViewRowInline}>
<Text style={styles.symptomDayView}>
{contraceptiveLabels.other}
</Text>
<CheckBox
value={this.state.other}
onValueChange={(val) => {
this.setState({other: val})
}}
/>
</View>
{ this.state.other &&
<TextInput
autoFocus={true}
multiline={true}
placeholder="Enter"
value={this.state.note}
onChangeText={(val) => {
this.setState({note: val})
}}
/>
}
<View style={styles.actionButtonRow}>
{this.props.makeActionButtons(
{
symptom: 'sex',
cycleDay: this.cycleDay,
saveAction: () => {
const copyOfState = Object.assign({}, this.state)
if (!copyOfState.other) {
copyOfState.note = null
}
saveSymptom('sex', this.cycleDay, copyOfState)
},
saveDisabled: Object.values(this.state).every(value => !value)
}
)}
</View>
</View>
)
}
}
...@@ -60,6 +60,22 @@ const DesireSchema = { ...@@ -60,6 +60,22 @@ const DesireSchema = {
} }
} }
const SexSchema = {
name: 'Sex',
properties: {
solo: { type: 'bool', optional: true },
partner: { type: 'bool', optional: true },
condom: { type: 'bool', optional: true },
pill: { type: 'bool', optional: true },
iud: { type: 'bool', optional: true },
patch: { type: 'bool', optional: true },
ring: { type: 'bool', optional: true },
implant: { type: 'bool', optional: true },
other: { type: 'bool', optional: true },
note: { type: 'string', optional: true }
}
}
const CycleDaySchema = { const CycleDaySchema = {
name: 'CycleDay', name: 'CycleDay',
primaryKey: 'date', primaryKey: 'date',
...@@ -88,6 +104,10 @@ const CycleDaySchema = { ...@@ -88,6 +104,10 @@ const CycleDaySchema = {
desire: { desire: {
type: 'Desire', type: 'Desire',
optional: true optional: true
},
sex: {
type: 'Sex',
optional: true
} }
} }
} }
...@@ -100,7 +120,8 @@ const realmConfig = { ...@@ -100,7 +120,8 @@ const realmConfig = {
MucusSchema, MucusSchema,
CervixSchema, CervixSchema,
NoteSchema, NoteSchema,
DesireSchema DesireSchema,
SexSchema
], ],
// 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