diff --git a/components/bleeding.js b/components/bleeding.js deleted file mode 100644 index 5fc625062e2b1ac88a5af122095b3cbb38f464ce..0000000000000000000000000000000000000000 --- a/components/bleeding.js +++ /dev/null @@ -1,102 +0,0 @@ -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/action-buttons.js b/components/cycle-day/action-buttons.js index 00085523344d66b1dd03fdd2a251529c4e65cd4c..eb33201da2f48ec182974bf2d1f1f7a03b21ab8d 100644 --- a/components/cycle-day/action-buttons.js +++ b/components/cycle-day/action-buttons.js @@ -24,7 +24,7 @@ export default function (showView) { saveAction() showView('dayView') }, - disabled: saveDisabled + disabledCondition: saveDisabled } ] diff --git a/components/cycle-day/cycle-day-overview.js b/components/cycle-day/cycle-day-overview.js index 1212e1342135cd9466fe4a7ae99b4d20d029dc57..13d43a45b53099c21ca81d08a749678b002353dc 100644 --- a/components/cycle-day/cycle-day-overview.js +++ b/components/cycle-day/cycle-day-overview.js @@ -10,9 +10,9 @@ import { mucusFeeling as feelingLabels, mucusTexture as textureLabels, mucusNFP as computeSensiplanMucusLabels, -} from '../labels/labels' -import cycleDayModule from '../lib/get-cycle-day-number' -import { bleedingDaysSortedByDate } from '../db' +} from './labels/labels' +import cycleDayModule from '../../lib/get-cycle-day-number' +import { bleedingDaysSortedByDate } from '../../db' const getCycleDayNumber = cycleDayModule() @@ -91,11 +91,9 @@ export default class DayView extends Component { </Button> </View> </View> - <View style={ styles.itemsInRowSeparatedView }> - <View style={{flex: 1}}> - <Text style={styles.symptomDayView}>Mucus</Text> - </View> - <View style={ styles.singleButtonView }> + <View style={ styles.symptomViewRowInline }> + <Text style={styles.symptomDayView}>Mucus</Text> + <View style={ styles.symptomEditButton }> <Button onPress={() => this.showView('mucusEditView')} title={mucusLabel}> diff --git a/components/cycle-day/index.js b/components/cycle-day/index.js index 3d634664ba0e70f603d836d3c2de6980a1accea0..d0fac81e970fc3558e9323244127a810517a3728 100644 --- a/components/cycle-day/index.js +++ b/components/cycle-day/index.js @@ -45,9 +45,9 @@ export default class Day extends Component { <View> { { dayView: <DayView cycleDay={this.cycleDay} showView={this.showView} />, - bleedingEditView: <BleedingEditView cycleDay={this.cycleDay} showView={this.showView}/>, - temperatureEditView: <TemperatureEditView cycleDay={this.cycleDay} showView={this.showView}/>, - mucusEditView: <MucusEditView cycleDay={this.cycleDay} showView={this.showView}/> + bleedingEditView: <BleedingEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>, + temperatureEditView: <TemperatureEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>, + mucusEditView: <MucusEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/> }[this.state.visibleComponent] } </View > diff --git a/components/cycle-day/symptoms/mucus.js b/components/cycle-day/symptoms/mucus.js index 38489cf805ac3d333f1d7faa3576d02aa38d1f1b..f94a656f1fe09aeaba113fdc19e4697ed3048878 100644 --- a/components/cycle-day/symptoms/mucus.js +++ b/components/cycle-day/symptoms/mucus.js @@ -1,7 +1,6 @@ import React, { Component } from 'react' import { View, - Button, Text, Switch } from 'react-native' @@ -12,24 +11,26 @@ import { mucusFeeling as feelingLabels, mucusTexture as textureLabels } from '../labels/labels' +import computeSensiplanValue from '../../../lib/sensiplan-mucus' + export default class Mucus extends Component { constructor(props) { super(props) this.cycleDay = props.cycleDay - this.showView = props.showView - - this.currentFeelingValue = this.cycleDay.mucus && this.cycleDay.mucus.feeling - if (typeof this.currentFeelingValue !== 'number') { - this.currentFeelingValue = -1 + this.makeActionButtons = props.makeActionButtons + this.state = { + exclude: this.cycleDay.mucus ? this.cycleDay.mucus.exclude : false } - this.currentTextureValue = this.cycleDay.mucus && this.cycleDay.mucus.texture - if (typeof this.currentTextureValue !== 'number') { - this.currentTextureValue = -1 + this.state.currentFeelingValue = this.cycleDay.mucus && this.cycleDay.mucus.feeling + if (typeof this.state.currentFeelingValue !== 'number') { + this.state.currentFeelingValue = -1 } - this.state = { - exclude: this.cycleDay.mucus ? this.cycleDay.mucus.exclude : false + + this.state.currentTextureValue = this.cycleDay.mucus && this.cycleDay.mucus.texture + if (typeof this.state.currentTextureValue !== 'number') { + this.state.currentTextureValue = -1 } } @@ -52,12 +53,12 @@ export default class Mucus extends Component { <View style={styles.radioButtonRow}> <RadioForm radio_props={mucusFeelingRadioProps} - initial={this.state.currentValue} + initial={this.state.currentFeelingValue} formHorizontal={true} labelHorizontal={false} labelStyle={styles.radioButton} onPress={(itemValue) => { - this.currentFeelingValue = itemValue + this.setState({ currentFeelingValue: itemValue }) }} /> </View> @@ -65,12 +66,12 @@ export default class Mucus extends Component { <View style={styles.radioButtonRow}> <RadioForm radio_props={mucusTextureRadioProps} - initial={this.currentTextureValue} + initial={this.state.currentTextureValue} formHorizontal={true} labelHorizontal={false} labelStyle={styles.radioButton} onPress={(itemValue) => { - this.currentTextureValue = itemValue + this.setState({ currentTextureValue: itemValue }) }} /> </View> @@ -91,8 +92,9 @@ export default class Mucus extends Component { cycleDay: this.cycleDay, saveAction: () => { saveSymptom('mucus', this.cycleDay, { - feeling: this.currentFeelingValue, - texture: this.currentTextureValue, + feeling: this.state.currentFeelingValue, + texture: this.state.currentTextureValue, + computedNfp: computeSensiplanValue(this.state.currentFeelingValue, this.state.currentTextureValue), exclude: this.state.exclude }) }, diff --git a/components/mucus.js b/components/mucus.js deleted file mode 100644 index c1d47df09cdf60a547d6efc8be50750adf41af55..0000000000000000000000000000000000000000 --- a/components/mucus.js +++ /dev/null @@ -1,157 +0,0 @@ -import React, { Component } from 'react' -import { - View, - Button, - Text, - Switch -} from 'react-native' -import RadioForm from 'react-native-simple-radio-button' -import { saveMucus } from '../db' -import styles from '../styles/index' -import { - mucusFeeling as feelingLabels, - mucusTexture as textureLabels -} from '../labels/labels' -import computeSensiplanValue from '../lib/sensiplan-mucus' - -export default class Mucus extends Component { - constructor(props) { - super(props) - this.cycleDay = props.cycleDay - this.showView = props.showView - - let currentFeelingValue = this.cycleDay.mucus && this.cycleDay.mucus.feeling - if (typeof currentFeelingValue !== 'number') { - currentFeelingValue = -1 - } - let currentTextureValue = this.cycleDay.mucus && this.cycleDay.mucus.texture - if (typeof currentTextureValue !== 'number') { - currentTextureValue = -1 - } - - this.state = { - currentFeelingValue, - currentTextureValue, - computeSensiplanValue, - exclude: this.cycleDay.mucus ? this.cycleDay.mucus.exclude : false - } - - } - - render() { - const mucusFeelingRadioProps = [ - {label: feelingLabels[0], value: 0 }, - {label: feelingLabels[1], value: 1 }, - {label: feelingLabels[2], value: 2 }, - {label: feelingLabels[3], value: 3 } - ] - const mucusTextureRadioProps = [ - {label: textureLabels[0], value: 0 }, - {label: textureLabels[1], value: 1 }, - {label: textureLabels[2], value: 2 } - ] - return( - <View style={ styles.symptomEditView }> - <View style={ styles.symptomEditSplitSymptomsAndLastRowButtons }> - <View style={ styles.symptomEditListedSymptomView }> - - <View style={{flex: 1}}> - <Text style={styles.symptomDayView}>Mucus</Text> - </View> - - <View style={{flex: 1}}> - <Text style={styles.symptomDayView}>Feeling</Text> - </View> - - <View style={{flex: 1}}> - <RadioForm - radio_props={mucusFeelingRadioProps} - initial={this.state.currentFeelingValue} - formHorizontal={true} - labelHorizontal={false} - labelStyle={styles.radioButton} - onPress={(itemValue) => { - this.setState({currentFeelingValue: itemValue}) - }} - /> - </View> - - <View style={{flex: 1}}> - <Text style={styles.symptomDayView}>Color/Texture</Text> - </View> - - <View style={{flex: 1}}> - <RadioForm - radio_props={mucusTextureRadioProps} - initial={this.state.currentTextureValue} - formHorizontal={true} - labelHorizontal={false} - labelStyle={styles.radioButton} - onPress={(itemValue) => { - this.setState({currentTextureValue: 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={() => { - saveMucus(this.cycleDay) - this.showView('dayView') - }} - title="Delete"> - </Button> - </View> - - <View style={ styles.singleButtonView }> - <Button - onPress={() => { - saveMucus(this.cycleDay, { - feeling: this.state.currentFeelingValue, - texture: this.state.currentTextureValue, - computedNfp: computeSensiplanValue(this.state.currentFeelingValue, this.state.currentTextureValue), - exclude: this.state.exclude - }) - this.showView('dayView') - }} - disabled={ this.state.currentFeelingValue === -1 || this.state.currentTextureValue === -1 } - title="Save"> - </Button> - </View> - - </View> - - </View> - ) - } -}