From 083e55eee8a6ee05854a2e95298baec6d2012b3f Mon Sep 17 00:00:00 2001 From: Julia Friesel Date: Sat, 1 Sep 2018 20:11:31 +0200 Subject: [PATCH] Apply select tab group to pain edit view --- components/cycle-day/cycle-day-overview.js | 10 +- components/cycle-day/symptoms/pain.js | 128 +++++++-------------- components/cycle-day/symptoms/sex.js | 18 +-- 3 files changed, 55 insertions(+), 101 deletions(-) diff --git a/components/cycle-day/cycle-day-overview.js b/components/cycle-day/cycle-day-overview.js index 21e0df8..9a058ee 100644 --- a/components/cycle-day/cycle-day-overview.js +++ b/components/cycle-day/cycle-day-overview.js @@ -98,16 +98,16 @@ export default class CycleDayOverView extends Component { data={getLabel('sex', cycleDay.sex)} disabled={dateInFuture} /> - this.navigate('NoteEditView')} - data={getLabel('note', cycleDay.note)} - /> this.navigate('PainEditView')} data={getLabel('pain', cycleDay.pain)} /> + this.navigate('NoteEditView')} + data={getLabel('note', cycleDay.note)} + /> {/* this is just to make the last row adhere to the grid (and) because there are no pseudo properties in RN */} diff --git a/components/cycle-day/symptoms/pain.js b/components/cycle-day/symptoms/pain.js index 6365065..18f80e4 100644 --- a/components/cycle-day/symptoms/pain.js +++ b/components/cycle-day/symptoms/pain.js @@ -1,17 +1,39 @@ 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 { pain as labels } from '../labels/labels' import ActionButtonFooter from './action-button-footer' +import SelectBoxGroup from '../select-box-group' + +const boxes = [{ + label: labels.cramps, + stateKey: 'cramps' +}, { + label: labels.ovulationPain, + stateKey: 'ovulationPain' +}, { + label: labels.headache, + stateKey: 'headache' +}, { + label: labels.backache, + stateKey: 'backache' +}, { + label: labels.nausea, + stateKey: 'nausea' +}, { + label: labels.tenderBreasts, + stateKey: 'tenderBreasts' +}, { + label: labels.migraine, + stateKey: 'migraine' +}, { + label: labels.other, + stateKey: 'other' +}] export default class Pain extends Component { constructor(props) { @@ -26,92 +48,24 @@ export default class Pain extends Component { } } + toggleState = (key) => { + const curr = this.state[key] + this.setState({[key]: !curr}) + if (key === 'other' && !curr) { + this.setState({focusTextArea: true}) + } + } + render() { return ( - - {painLabels.cramps} - { - this.setState({cramps: val}) - }} - /> - - {painLabels.ovulationPain} - - { - this.setState({ovulationPain: val}) - }} - /> - - - - {painLabels.headache} - - { - this.setState({headache: val}) - }} - /> - - {painLabels.backache} - - { - this.setState({backache: val}) - }} - /> - - - - {painLabels.nausea} - - { - this.setState({nausea: val}) - }} - /> - - {painLabels.tenderBreasts} - - { - this.setState({tenderBreasts: val}) - }} - /> - - - - {painLabels.migraine} - - { - this.setState({migraine: val}) - }} - /> - - {painLabels.other} - - { - this.setState({ - other: val, - focusTextArea: true - }) - }} - /> - + { this.state.other &&