Skip to content
Snippets Groups Projects
Commit 18c5fef5 authored by bl00dymarie's avatar bl00dymarie
Browse files

Merge branch 'implement-sex-with-fancy-checkbox' into 'master'

Implement Sex \o/:

Closes #69

See merge request bloodyhealth/drip!50
parents b998ef54 b3ace768
No related branches found
No related tags found
No related merge requests found
......@@ -98,11 +98,20 @@ export default class DayView extends Component {
<Text style={styles.symptomDayView}>Desire</Text>
<View style={styles.symptomEditButton}>
<Button
onPress={() => this.showView('desireEditView')}
onPress={() => this.showView('DesireEditView')}
title={getLabel('desire', cycleDay.desire)}>
</Button>
</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 >
)
}
......@@ -132,15 +141,22 @@ function getLabel(symptomName, symptom) {
typeof mucus.texture === '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 + " )"
return mucusLabel
}
},
cervix: cervix => {
if (cervix.opening > -1 && cervix.firmness > -1) {
let cervixLabel = `${openingLabels[cervix.opening]} + ${firmnessLabels[cervix.firmness]}`
if (cervix.position > -1) cervixLabel += `+ ${positionLabels[cervix.position]}`
let cervixLabel =
`${openingLabels[cervix.opening]} +
${firmnessLabels[cervix.firmness]}`
if (cervix.position > -1) {
cervixLabel += `+ ${positionLabels[cervix.position]}`
}
if (cervix.exclude) cervixLabel = "( " + cervixLabel + " )"
return cervixLabel
}
......@@ -153,6 +169,17 @@ function getLabel(symptomName, symptom) {
const desireLabel = `${intensityLabels[desire.value]}`
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']
export const cervixFirmness = ['hard', 'soft']
export const cervixPosition = ['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 = {
fertile: 'fertile',
......
......@@ -4,6 +4,7 @@ import MucusEditView from './mucus'
import CervixEditView from './cervix'
import NoteEditView from './note'
import DesireEditView from './desire'
import SexEditView from './sex'
export default {
BleedingEditView,
......@@ -11,5 +12,6 @@ export default {
MucusEditView,
CervixEditView,
NoteEditView,
DesireEditView
}
\ No newline at end of file
DesireEditView,
SexEditView
}
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,
focusTextArea: true
})
}}
/>
</View>
{ this.state.other &&
<TextInput
autoFocus={this.state.focusTextArea}
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 = {
}
}
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 = {
name: 'CycleDay',
primaryKey: 'date',
......@@ -88,6 +104,10 @@ const CycleDaySchema = {
desire: {
type: 'Desire',
optional: true
},
sex: {
type: 'Sex',
optional: true
}
}
}
......@@ -100,7 +120,8 @@ const realmConfig = {
MucusSchema,
CervixSchema,
NoteSchema,
DesireSchema
DesireSchema,
SexSchema
],
// we only want this in dev mode
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