diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml new file mode 100644 index 0000000000000000000000000000000000000000..2f5e5f86f3e4bf505b5fa75194a22fb8da092afa --- /dev/null +++ b/android/app/src/main/res/values/colors.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <!-- color for the app bar and other primary UI elements --> + <color name="colorPrimary">#ff7e5f</color> + + <!-- a darker variant of the primary color, used for + the status bar (on Android 5.0+) and contextual app bars --> + <color name="colorPrimaryDark">#c74e34</color> + + <!-- a secondary color for controls like checkboxes and text fields --> + <color name="colorAccent">#351c4d</color> +</resources> \ No newline at end of file diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index 319eb0ca100b5aae62b669a5f375ec234aabe351..553627547dbff979337a41fe1b6a93433ba2887f 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -3,6 +3,7 @@ <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> + <item name="colorAccent">@color/colorAccent</item> </style> </resources> diff --git a/components/cycle-day/cycle-day-overview.js b/components/cycle-day/cycle-day-overview.js index 9d38dee94c0a7b66dc076d6c16b41f0ba1ea7a41..21e0df880db33ebb01d5a9fcb5fab77a6778bada 100644 --- a/components/cycle-day/cycle-day-overview.js +++ b/components/cycle-day/cycle-day-overview.js @@ -19,7 +19,9 @@ import { cervixOpening as openingLabels, cervixFirmness as firmnessLabels, cervixPosition as positionLabels, - intensity as intensityLabels + intensity as intensityLabels, + pain as painLabels, + sex as sexLabels } from './labels/labels' import { AppText } from '../app-text' @@ -101,6 +103,11 @@ export default class CycleDayOverView extends Component { onPress={() => this.navigate('NoteEditView')} data={getLabel('note', cycleDay.note)} /> + <SymptomBox + title='Pain' + onPress={() => this.navigate('PainEditView')} + data={getLabel('pain', cycleDay.pain)} + /> {/* this is just to make the last row adhere to the grid (and) because there are no pseudo properties in RN */} <FillerBoxes /> @@ -163,15 +170,42 @@ function getLabel(symptomName, symptom) { } }, sex: sex => { - const sexLabel = [] - if ( sex.solo || sex.partner ) { - sexLabel.push('activity') + let sexLabel = [] + if (sex && Object.values(sex).some(val => val)){ + Object.keys(sex).forEach(key => { + if(sex[key] && key !== 'other' && key !== 'note') { + sexLabel.push(sexLabels[key]) + } + if(key === 'other' && sex.other) { + let label = sexLabels[key] + if(sex.note) { + label = `${label} (${sex.note})` + } + sexLabel.push(label) + } + }) + sexLabel = sexLabel.join(', ') } - if (sex.condom || sex.pill || sex.iud || - sex.patch || sex.ring || sex.implant || sex.other) { - sexLabel.push('contraceptive') + return sexLabel + }, + pain: pain => { + let painLabel = [] + if (pain && Object.values(pain).some(val => val)){ + Object.keys(pain).forEach(key => { + if(pain[key] && key !== 'other' && key !== 'note') { + painLabel.push(painLabels[key]) + } + if(key === 'other' && pain.other) { + let label = painLabels[key] + if(pain.note) { + label = `${label} (${pain.note})` + } + painLabel.push(label) + } + }) + painLabel = painLabel.join(', ') } - return sexLabel.join(', ') + return painLabel } } @@ -223,4 +257,4 @@ class FillerBoxes extends Component { } return fillerBoxes } -} \ No newline at end of file +} diff --git a/components/cycle-day/labels/labels.js b/components/cycle-day/labels/labels.js index 6650e335efde0c62ad1e55ba181dd230e0db7e2f..90faf28acf603e0bea205e253323be41c48bc0f0 100644 --- a/components/cycle-day/labels/labels.js +++ b/components/cycle-day/labels/labels.js @@ -6,11 +6,9 @@ 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 = { +export const sex = { solo: 'Solo', - partner: 'Partner' -} -export const contraceptives = { + partner: 'Partner', condom: 'Condom', pill: 'Pill', iud: 'IUD', @@ -20,6 +18,18 @@ export const contraceptives = { other: 'Other' } +export const pain = { + cramps: 'Cramps', + ovulationPain: 'Ovulation pain', + headache: 'Headache', + backache: 'Backache', + nausea: 'Nausea', + tenderBreasts: 'Tender breasts', + migraine: 'Migraine', + other: 'Other', + note: 'Note' +} + export const fertilityStatus = { fertile: 'fertile', infertile: 'infertile', diff --git a/components/cycle-day/symptoms/index.js b/components/cycle-day/symptoms/index.js index 12622b73c88b75d29edba5def57ee217b355d28e..014e9fe5dc4fa8aff3e83cf9ca275be1dfbd73ed 100644 --- a/components/cycle-day/symptoms/index.js +++ b/components/cycle-day/symptoms/index.js @@ -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 -} \ No newline at end of file + SexEditView, + PainEditView +} diff --git a/components/cycle-day/symptoms/note.js b/components/cycle-day/symptoms/note.js index ffbb543fdd651a8938b044bee5d37d12eb0b6940..d43c5fe83be9c2c1aec882170fdacd08534cca7d 100644 --- a/components/cycle-day/symptoms/note.js +++ b/components/cycle-day/symptoms/note.js @@ -9,7 +9,7 @@ import styles from '../../../styles' import { saveSymptom } from '../../../db' import ActionButtonFooter from './action-button-footer' -export default class Temp extends Component { +export default class Note extends Component { constructor(props) { super(props) this.cycleDay = props.cycleDay @@ -27,6 +27,7 @@ export default class Temp extends Component { <ScrollView style={styles.page}> <View style={styles.symptomViewRow}> <TextInput + autoFocus={!this.state.currentValue} multiline={true} placeholder="Enter" onChangeText={(val) => { @@ -50,4 +51,4 @@ export default class Temp extends Component { </View> ) } -} \ No newline at end of file +} diff --git a/components/cycle-day/symptoms/pain.js b/components/cycle-day/symptoms/pain.js new file mode 100644 index 0000000000000000000000000000000000000000..6365065329cc36c18a41f970fdc34ddeb664d620 --- /dev/null +++ b/components/cycle-day/symptoms/pain.js @@ -0,0 +1,144 @@ +import React, { Component } from 'react' +import { + CheckBox, + ScrollView, + Text, + TextInput, + View +} from 'react-native' +import styles from '../../../styles' +import { saveSymptom } from '../../../db' +import { + pain as painLabels +} from '../labels/labels' +import ActionButtonFooter from './action-button-footer' + +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) + if (this.cycleDay.pain && this.cycleDay.pain.note) { + this.state.other = true + } + } + } + + render() { + return ( + <View style={{ flex: 1 }}> + <ScrollView> + <View> + <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}) + }} + /> + <Text style={styles.symptomDayView}> + {painLabels.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> + </ScrollView> + <ActionButtonFooter + symptom='pain' + cycleDay={this.cycleDay} + saveAction={() => { + const copyOfState = Object.assign({}, this.state) + if (!copyOfState.other) { + copyOfState.note = null + } + saveSymptom('pain', this.cycleDay, copyOfState) + }} + saveDisabled={Object.values(this.state).every(value => !value)} + navigate={this.props.navigate} + /> + </View> + ) + } +} diff --git a/components/cycle-day/symptoms/sex.js b/components/cycle-day/symptoms/sex.js index 0019eb4b9f7d11821d5f18d7efe7578a4fd73b0c..0d2febb80736fda65d153b5a312ed5c6427224cc 100644 --- a/components/cycle-day/symptoms/sex.js +++ b/components/cycle-day/symptoms/sex.js @@ -6,10 +6,7 @@ import { } from 'react-native' import styles from '../../../styles' import { saveSymptom } from '../../../db' -import { - sexActivity as activityLabels, - contraceptives as contraceptiveLabels -} from '../labels/labels' +import { sex as sexLabels } from '../labels/labels' import ActionButtonFooter from './action-button-footer' import SelectBoxGroup from '../select-box-group' import { SymptomSectionHeader } from '../../app-text' diff --git a/components/labels.js b/components/labels.js index 5f32eb54ff7739ee80ae6da8c1eb9a93ace326d7..c4c9cba75ad18957e1ba4dce0ffb609f9cfc389a 100644 --- a/components/labels.js +++ b/components/labels.js @@ -63,7 +63,8 @@ export const headerTitles = { CervixEditView: 'Cervix', NoteEditView: 'Note', DesireEditView: 'Desire', - SexEditView: 'Sex' + SexEditView: 'Sex', + PainEditView: 'Pain' } export const stats = { diff --git a/db/index.js b/db/index.js index be82049d86962e32a63de9806e029c6ceb6f42cb..184567418143141b300a57fb638d542df26d2e2a 100644 --- a/db/index.js +++ b/db/index.js @@ -80,6 +80,21 @@ 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 }, + migraine: { type: 'bool', optional: true }, + other: { type: 'bool', optional: true }, + note: { type: 'string', optional: true } + } +} + const CycleDaySchema = { name: 'CycleDay', primaryKey: 'date', @@ -112,6 +127,10 @@ const CycleDaySchema = { sex: { type: 'Sex', optional: true + }, + pain: { + type: 'Pain', + optional: true } } } @@ -125,7 +144,8 @@ const realmConfig = { CervixSchema, NoteSchema, DesireSchema, - SexSchema + SexSchema, + PainSchema ], // we only want this in dev mode deleteRealmIfMigrationNeeded: true