From 0da3810aeb08d0d5dbc0c42a88168b86c1ea62b8 Mon Sep 17 00:00:00 2001 From: emelko <ml.kochsiek@mailbox.org> Date: Fri, 13 Jul 2018 23:01:07 +0200 Subject: [PATCH] Better naming for bleedin labels --- components/bleeding.js | 102 +++++++++++++++++++++ components/cycle-day/cycle-day-overview.js | 4 +- 2 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 components/bleeding.js diff --git a/components/bleeding.js b/components/bleeding.js new file mode 100644 index 00000000..5fc62506 --- /dev/null +++ b/components/bleeding.js @@ -0,0 +1,102 @@ +import React, { Component } from 'react' +import { + View, + Button, + Text, + Switch +} from 'react-native' +import RadioForm from 'react-native-simple-radio-button' +import styles from '../styles/index' +import { saveBleeding } from '../db' +import { bleeding as bleedingLabels } from '../labels/labels' + +export default class Bleeding extends Component { + constructor(props) { + super(props) + this.cycleDay = props.cycleDay + this.showView = props.showView + let bleedingValue = this.cycleDay.bleeding && this.cycleDay.bleeding.value + if (! (typeof bleedingValue === 'number') ){ + bleedingValue = -1 + } + this.state = { + currentValue: bleedingValue, + exclude: this.cycleDay.bleeding ? this.cycleDay.bleeding.exclude : false + } + } + + render() { + const bleedingRadioProps = [ + {label: bleedingLabels[0], value: 0 }, + {label: bleedingLabels[1], value: 1 }, + {label: bleedingLabels[2], value: 2 }, + {label: bleedingLabels[3], value: 3 }, + ] + return ( + <View style={ styles.symptomEditView }> + <View style={ styles.symptomEditSplitSymptomsAndLastRowButtons }> + <View style={ styles.symptomEditListedSymptomView }> + <View style={{flex: 1}}> + <Text style={styles.symptomDayView}>Bleeding</Text> + </View> + <View style={{flex: 1}}> + <RadioForm + radio_props={bleedingRadioProps} + initial={this.state.currentValue} + formHorizontal={true} + labelHorizontal={false} + labelStyle={styles.radioButton} + onPress={(itemValue) => { + this.setState({currentValue: itemValue}) + }} + /> + </View> + </View> + <View style={ styles.itemsInRowSeparatedView }> + <View style={ styles.singleButtonView }> + <Text style={ styles.symptomDayView }>Exclude</Text> + </View> + <View style={ styles.singleButtonView }> + <Switch + onValueChange={(val) => { + this.setState({exclude: val}) + }} + value={this.state.exclude} + /> + </View> + </View> + </View> + <View style={ styles.itemsInRowSeparatedView }> + <View style={ styles.singleButtonView }> + <Button + onPress={() => this.showView('dayView')} + title="Cancel"> + </Button> + </View> + <View style={ styles.singleButtonView }> + <Button + onPress={() => { + saveBleeding(this.cycleDay) + this.showView('dayView') + }} + title="Delete"> + </Button> + </View> + <View style={ styles.singleButtonView }> + <Button + onPress={() => { + saveBleeding(this.cycleDay, { + value: this.state.currentValue, + exclude: this.state.exclude + }) + this.showView('dayView') + }} + disabled={ this.state.currentValue === -1 } + title="Save"> + </Button> + </View> + </View> + </View> + ) + } +} diff --git a/components/cycle-day/cycle-day-overview.js b/components/cycle-day/cycle-day-overview.js index 22036530..1212e134 100644 --- a/components/cycle-day/cycle-day-overview.js +++ b/components/cycle-day/cycle-day-overview.js @@ -6,7 +6,7 @@ import { } from 'react-native' import styles from '../../styles' import { - bleeding as labels, + bleeding as bleedingLabels, mucusFeeling as feelingLabels, mucusTexture as textureLabels, mucusNFP as computeSensiplanMucusLabels, @@ -44,7 +44,7 @@ export default class DayView extends Component { const bleedingValue = this.cycleDay.bleeding && this.cycleDay.bleeding.value let bleedingLabel if (typeof bleedingValue === 'number') { - bleedingLabel = `${labels[bleedingValue]}` + bleedingLabel = `${bleedingLabels[bleedingValue]}` if (this.cycleDay.bleeding.exclude) bleedingLabel = "( " + bleedingLabel + " )" } else { bleedingLabel = 'edit' -- GitLab