Putting all the labels of selected pain keys in the cycle day overview

This commit is contained in:
Bl00dyMarie
2018-08-24 17:18:01 +02:00
parent e68b8f5460
commit ad9997f73b
5 changed files with 547 additions and 640 deletions
File diff suppressed because one or more lines are too long
+16 -9
View File
@@ -20,7 +20,8 @@ import {
cervixOpening as openingLabels, cervixOpening as openingLabels,
cervixFirmness as firmnessLabels, cervixFirmness as firmnessLabels,
cervixPosition as positionLabels, cervixPosition as positionLabels,
intensity as intensityLabels intensity as intensityLabels,
pain as painLabels
} from './labels/labels' } from './labels/labels'
export default class CycleDayOverView extends Component { export default class CycleDayOverView extends Component {
@@ -138,7 +139,10 @@ function getLabel(symptomName, symptom) {
cervix: cervix => { cervix: cervix => {
let cervixLabel = [] let cervixLabel = []
if (cervix.opening > -1 && cervix.firmness > -1) { if (cervix.opening > -1 && cervix.firmness > -1) {
cervixLabel.push(openingLabels[cervix.opening], firmnessLabels[cervix.firmness]) cervixLabel.push(
openingLabels[cervix.opening],
firmnessLabels[cervix.firmness]
)
if (cervix.position > -1) { if (cervix.position > -1) {
cervixLabel.push(positionLabels[cervix.position]) cervixLabel.push(positionLabels[cervix.position])
} }
@@ -168,14 +172,17 @@ function getLabel(symptomName, symptom) {
return sexLabel.join(', ') return sexLabel.join(', ')
}, },
pain: pain => { pain: pain => {
let painLabel = '' let painLabel = []
if (pain.cramps || pain.ovulationPain || pain.headache || if (pain && Object.values(pain).some(val => val)){
pain.backache || pain.nausea || pain.tenderBreasts || Object.keys(pain).forEach(key => {
pain.migraine || pain.other if(pain[key]) {
) { painLabel.push(painLabels[key])
painLabel += 'Pain'
} }
return painLabel ? painLabel : 'edit' })
painLabel = painLabel.join(', ')
if (pain.exclude) painLabel = `(${painLabel})`
}
return painLabel
} }
} }
+27 -16
View File
@@ -3,13 +3,15 @@ import {
CheckBox, CheckBox,
Text, Text,
TextInput, TextInput,
View View,
ScrollView
} from 'react-native' } from 'react-native'
import styles from '../../../styles' import styles from '../../../styles'
import { saveSymptom } from '../../../db' import { saveSymptom } from '../../../db'
import { import {
pain as painLabels pain as painLabels
} from '../labels/labels' } from '../labels/labels'
import ActionButtonFooter from './action-button-footer'
export default class Pain extends Component { export default class Pain extends Component {
constructor(props) { constructor(props) {
@@ -18,15 +20,20 @@ export default class Pain extends Component {
this.state = {} this.state = {}
if (this.cycleDay.pain !== null ) { if (this.cycleDay.pain !== null ) {
Object.assign(this.state, this.cycleDay.pain) Object.assign(this.state, this.cycleDay.pain)
if (this.cycleDay.pain && this.cycleDay.pain.note) {
this.state.other = true
}
} }
} }
render() { render() {
return ( return (
<View style={styles.symptomEditView}> <View style={{ flex: 1 }}>
<Text style={styles.symptomDayView}>PAIN</Text> <ScrollView>
<View>
<View style={styles.symptomViewRowInline}> <View style={styles.symptomViewRowInline}>
<Text style={styles.symptomDayView}>PAIN</Text>
<Text style={styles.symptomDayView}>{painLabels.cramps}</Text> <Text style={styles.symptomDayView}>{painLabels.cramps}</Text>
<CheckBox <CheckBox
value={this.state.cramps} value={this.state.cramps}
@@ -34,7 +41,9 @@ export default class Pain extends Component {
this.setState({cramps: val}) this.setState({cramps: val})
}} }}
/> />
<Text style={styles.symptomDayView}>{painLabels.ovulationPain}</Text> <Text style={styles.symptomDayView}>
{painLabels.ovulationPain}
</Text>
<CheckBox <CheckBox
value={this.state.ovulationPain} value={this.state.ovulationPain}
onValueChange={(val) => { onValueChange={(val) => {
@@ -118,19 +127,21 @@ export default class Pain extends Component {
/> />
} }
</View> </View>
<View style={styles.actionButtonRow}>
{this.props.makeActionButtons(
{
symptom: 'pain',
cycleDay: this.cycleDay,
saveAction: () => {
const copyOfState = Object.assign({}, this.state)
saveSymptom('pain', this.cycleDay, copyOfState)
},
saveDisabled: Object.values(this.state).every(value => !value)
}
)}
</View> </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> </View>
) )
} }
+3 -1
View File
@@ -43,7 +43,9 @@ export default class Sex extends Component {
this.setState({ solo: val }) this.setState({ solo: val })
}} }}
/> />
<Text style={styles.symptomDayView}>{activityLabels.partner}</Text> <Text style={styles.symptomDayView}>
{activityLabels.partner}
</Text>
<CheckBox <CheckBox
value={this.state.partner} value={this.state.partner}
onValueChange={(val) => { onValueChange={(val) => {
+78 -78
View File
@@ -3721,8 +3721,8 @@
"integrity": "sha512-z8H8/diyk76B7q5wg+Ud0+CqzcAF3mBBI/bA5ne5zrRUUIvNkJY//D3BqyH571KuAC4Nr7Rw7CjWX4r0y9DvNg==", "integrity": "sha512-z8H8/diyk76B7q5wg+Ud0+CqzcAF3mBBI/bA5ne5zrRUUIvNkJY//D3BqyH571KuAC4Nr7Rw7CjWX4r0y9DvNg==",
"optional": true, "optional": true,
"requires": { "requires": {
"nan": "2.10.0", "nan": "^2.9.2",
"node-pre-gyp": "0.10.0" "node-pre-gyp": "^0.10.0"
}, },
"dependencies": { "dependencies": {
"abbrev": { "abbrev": {
@@ -3744,8 +3744,8 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"delegates": "1.0.0", "delegates": "^1.0.0",
"readable-stream": "2.3.6" "readable-stream": "^2.0.6"
} }
}, },
"balanced-match": { "balanced-match": {
@@ -3758,7 +3758,7 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"balanced-match": "1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
} }
}, },
@@ -3815,7 +3815,7 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"minipass": "2.2.4" "minipass": "^2.2.1"
} }
}, },
"fs.realpath": { "fs.realpath": {
@@ -3828,14 +3828,14 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"aproba": "1.2.0", "aproba": "^1.0.3",
"console-control-strings": "1.1.0", "console-control-strings": "^1.0.0",
"has-unicode": "2.0.1", "has-unicode": "^2.0.0",
"object-assign": "4.1.1", "object-assign": "^4.1.0",
"signal-exit": "3.0.2", "signal-exit": "^3.0.0",
"string-width": "1.0.2", "string-width": "^1.0.1",
"strip-ansi": "3.0.1", "strip-ansi": "^3.0.1",
"wide-align": "1.1.2" "wide-align": "^1.1.0"
} }
}, },
"glob": { "glob": {
@@ -3843,12 +3843,12 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"fs.realpath": "1.0.0", "fs.realpath": "^1.0.0",
"inflight": "1.0.6", "inflight": "^1.0.4",
"inherits": "2.0.3", "inherits": "2",
"minimatch": "3.0.4", "minimatch": "^3.0.4",
"once": "1.4.0", "once": "^1.3.0",
"path-is-absolute": "1.0.1" "path-is-absolute": "^1.0.0"
} }
}, },
"has-unicode": { "has-unicode": {
@@ -3861,7 +3861,7 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"safer-buffer": "2.1.2" "safer-buffer": "^2.1.0"
} }
}, },
"ignore-walk": { "ignore-walk": {
@@ -3869,7 +3869,7 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"minimatch": "3.0.4" "minimatch": "^3.0.4"
} }
}, },
"inflight": { "inflight": {
@@ -3877,8 +3877,8 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"once": "1.4.0", "once": "^1.3.0",
"wrappy": "1.0.2" "wrappy": "1"
} }
}, },
"inherits": { "inherits": {
@@ -3896,7 +3896,7 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"number-is-nan": "1.0.1" "number-is-nan": "^1.0.0"
} }
}, },
"isarray": { "isarray": {
@@ -3909,7 +3909,7 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"brace-expansion": "1.1.11" "brace-expansion": "^1.1.7"
} }
}, },
"minimist": { "minimist": {
@@ -3922,8 +3922,8 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"safe-buffer": "5.1.1", "safe-buffer": "^5.1.1",
"yallist": "3.0.2" "yallist": "^3.0.0"
} }
}, },
"minizlib": { "minizlib": {
@@ -3931,7 +3931,7 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"minipass": "2.2.4" "minipass": "^2.2.1"
} }
}, },
"mkdirp": { "mkdirp": {
@@ -3952,9 +3952,9 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"debug": "2.6.9", "debug": "^2.1.2",
"iconv-lite": "0.4.21", "iconv-lite": "^0.4.4",
"sax": "1.2.4" "sax": "^1.2.4"
} }
}, },
"node-pre-gyp": { "node-pre-gyp": {
@@ -3962,16 +3962,16 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"detect-libc": "1.0.3", "detect-libc": "^1.0.2",
"mkdirp": "0.5.1", "mkdirp": "^0.5.1",
"needle": "2.2.0", "needle": "^2.2.0",
"nopt": "4.0.1", "nopt": "^4.0.1",
"npm-packlist": "1.1.10", "npm-packlist": "^1.1.6",
"npmlog": "4.1.2", "npmlog": "^4.0.2",
"rc": "1.2.7", "rc": "^1.1.7",
"rimraf": "2.6.2", "rimraf": "^2.6.1",
"semver": "5.5.0", "semver": "^5.3.0",
"tar": "4.4.1" "tar": "^4"
} }
}, },
"nopt": { "nopt": {
@@ -3979,8 +3979,8 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"abbrev": "1.1.1", "abbrev": "1",
"osenv": "0.1.5" "osenv": "^0.1.4"
} }
}, },
"npm-bundled": { "npm-bundled": {
@@ -3993,8 +3993,8 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"ignore-walk": "3.0.1", "ignore-walk": "^3.0.1",
"npm-bundled": "1.0.3" "npm-bundled": "^1.0.1"
} }
}, },
"npmlog": { "npmlog": {
@@ -4002,10 +4002,10 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"are-we-there-yet": "1.1.4", "are-we-there-yet": "~1.1.2",
"console-control-strings": "1.1.0", "console-control-strings": "~1.1.0",
"gauge": "2.7.4", "gauge": "~2.7.3",
"set-blocking": "2.0.0" "set-blocking": "~2.0.0"
} }
}, },
"number-is-nan": { "number-is-nan": {
@@ -4023,7 +4023,7 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"wrappy": "1.0.2" "wrappy": "1"
} }
}, },
"os-homedir": { "os-homedir": {
@@ -4041,8 +4041,8 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"os-homedir": "1.0.2", "os-homedir": "^1.0.0",
"os-tmpdir": "1.0.2" "os-tmpdir": "^1.0.0"
} }
}, },
"path-is-absolute": { "path-is-absolute": {
@@ -4060,10 +4060,10 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"deep-extend": "0.5.1", "deep-extend": "^0.5.1",
"ini": "1.3.5", "ini": "~1.3.0",
"minimist": "1.2.0", "minimist": "^1.2.0",
"strip-json-comments": "2.0.1" "strip-json-comments": "~2.0.1"
}, },
"dependencies": { "dependencies": {
"minimist": { "minimist": {
@@ -4078,13 +4078,13 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"core-util-is": "1.0.2", "core-util-is": "~1.0.0",
"inherits": "2.0.3", "inherits": "~2.0.3",
"isarray": "1.0.0", "isarray": "~1.0.0",
"process-nextick-args": "2.0.0", "process-nextick-args": "~2.0.0",
"safe-buffer": "5.1.1", "safe-buffer": "~5.1.1",
"string_decoder": "1.1.1", "string_decoder": "~1.1.1",
"util-deprecate": "1.0.2" "util-deprecate": "~1.0.1"
} }
}, },
"rimraf": { "rimraf": {
@@ -4092,7 +4092,7 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"glob": "7.1.2" "glob": "^7.0.5"
} }
}, },
"safe-buffer": { "safe-buffer": {
@@ -4129,9 +4129,9 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"code-point-at": "1.1.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "1.0.0", "is-fullwidth-code-point": "^1.0.0",
"strip-ansi": "3.0.1" "strip-ansi": "^3.0.0"
} }
}, },
"string_decoder": { "string_decoder": {
@@ -4139,14 +4139,14 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"safe-buffer": "5.1.1" "safe-buffer": "~5.1.0"
} }
}, },
"strip-ansi": { "strip-ansi": {
"version": "3.0.1", "version": "3.0.1",
"bundled": true, "bundled": true,
"requires": { "requires": {
"ansi-regex": "2.1.1" "ansi-regex": "^2.0.0"
} }
}, },
"strip-json-comments": { "strip-json-comments": {
@@ -4159,13 +4159,13 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"chownr": "1.0.1", "chownr": "^1.0.1",
"fs-minipass": "1.2.5", "fs-minipass": "^1.2.5",
"minipass": "2.2.4", "minipass": "^2.2.4",
"minizlib": "1.1.0", "minizlib": "^1.1.0",
"mkdirp": "0.5.1", "mkdirp": "^0.5.0",
"safe-buffer": "5.1.1", "safe-buffer": "^5.1.1",
"yallist": "3.0.2" "yallist": "^3.0.2"
} }
}, },
"util-deprecate": { "util-deprecate": {
@@ -4178,7 +4178,7 @@
"bundled": true, "bundled": true,
"optional": true, "optional": true,
"requires": { "requires": {
"string-width": "1.0.2" "string-width": "^1.0.2"
} }
}, },
"wrappy": { "wrappy": {