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 ( SEX {activityLabels.solo} { this.setState({solo: val}) }} /> {activityLabels.partner} { this.setState({partner: val}) }} /> CONTRACEPTIVES {contraceptiveLabels.condom} { this.setState({condom: val}) }} /> {contraceptiveLabels.pill} { this.setState({pill: val}) }} /> {contraceptiveLabels.iud} { this.setState({iud: val}) }} /> {contraceptiveLabels.patch} { this.setState({patch: val}) }} /> {contraceptiveLabels.ring} { this.setState({ring: val}) }} /> {contraceptiveLabels.implant} { this.setState({implant: val}) }} /> {contraceptiveLabels.other} { this.setState({ other: val, focusTextArea: true }) }} /> { this.state.other && { this.setState({note: val}) }} /> } {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) } )} ) } }