diff --git a/components/app.js b/components/app.js index 178214c..fd9b61b 100644 --- a/components/app.js +++ b/components/app.js @@ -125,19 +125,12 @@ export default class App extends Component { goBack={this.handleBackButtonPress} /> } - {this.isSymptomView() && -
this.navigate(INFO_SYMPTOM_PAGE, { - symptomView: currentPage, - ...currentProps - })} - />} - + {!this.isSymptomView() && diff --git a/components/cycle-day/symptoms/bleeding.js b/components/cycle-day/symptoms/bleeding.js index 6b9c39c..9d94a03 100644 --- a/components/cycle-day/symptoms/bleeding.js +++ b/components/cycle-day/symptoms/bleeding.js @@ -1,6 +1,5 @@ import React from 'react' import { - View, Switch, ScrollView } from 'react-native' @@ -34,7 +33,7 @@ export default class Bleeding extends SymptomView { }) } - render() { + renderContent() { const bleedingRadioProps = [ { label: bleeding.labels[0], value: 0 }, { label: bleeding.labels[1], value: 1 }, @@ -42,32 +41,30 @@ export default class Bleeding extends SymptomView { { label: bleeding.labels[3], value: 3 }, ] return ( - - - - this.setState({ currentValue: val })} - /> - - - { - this.setState({ exclude: val }) - }} - value={this.state.exclude} - /> - - - + + + this.setState({ currentValue: val })} + /> + + + { + this.setState({ exclude: val }) + }} + value={this.state.exclude} + /> + + ) } } \ No newline at end of file diff --git a/components/cycle-day/symptoms/cervix.js b/components/cycle-day/symptoms/cervix.js index 285d7de..3feac91 100644 --- a/components/cycle-day/symptoms/cervix.js +++ b/components/cycle-day/symptoms/cervix.js @@ -1,6 +1,5 @@ import React from 'react' import { - View, Switch, ScrollView } from 'react-native' @@ -35,7 +34,7 @@ export default class Cervix extends SymptomView { }) } - render() { + renderContent() { const cervixOpeningRadioProps = [ { label: labels.opening.categories[0], value: 0 }, { label: labels.opening.categories[1], value: 1 }, @@ -52,52 +51,50 @@ export default class Cervix extends SymptomView { ] const mandatoryNotCompleted = typeof this.state.opening != 'number' || typeof this.state.firmness != 'number' return ( - - - - this.setState({ opening: val })} - /> - - - this.setState({ firmness: val })} - /> - - - this.setState({ position: val })} - /> - - - { - this.setState({ exclude: val }) - }} - value={this.state.exclude} - /> - - - + + + this.setState({ opening: val })} + /> + + + this.setState({ firmness: val })} + /> + + + this.setState({ position: val })} + /> + + + { + this.setState({ exclude: val }) + }} + value={this.state.exclude} + /> + + ) } } diff --git a/components/cycle-day/symptoms/desire.js b/components/cycle-day/symptoms/desire.js index 9e9636b..a619caf 100644 --- a/components/cycle-day/symptoms/desire.js +++ b/components/cycle-day/symptoms/desire.js @@ -28,27 +28,25 @@ export default class Desire extends SymptomView { this.saveSymptomEntry({ value: this.state.currentValue }) } - render() { + renderContent() { const desireRadioProps = [ { label: intensity[0], value: 0 }, { label: intensity[1], value: 1 }, { label: intensity[2], value: 2 } ] return ( - - - - this.setState({ currentValue: val })} - /> - - - + + + this.setState({ currentValue: val })} + /> + + ) } } diff --git a/components/cycle-day/symptoms/mood.js b/components/cycle-day/symptoms/mood.js index 654d2e7..a2b0a6a 100644 --- a/components/cycle-day/symptoms/mood.js +++ b/components/cycle-day/symptoms/mood.js @@ -47,19 +47,18 @@ export default class Mood extends SymptomView { } } - render() { + renderContent() { return ( - - - - - { this.state.other && + + + + { this.state.other && - } - - - + } + + ) } } diff --git a/components/cycle-day/symptoms/mucus.js b/components/cycle-day/symptoms/mucus.js index 0c33ef8..05aa1a1 100644 --- a/components/cycle-day/symptoms/mucus.js +++ b/components/cycle-day/symptoms/mucus.js @@ -38,7 +38,7 @@ export default class Mucus extends SymptomView { }) } - render() { + renderContent() { const mucusFeeling = [ { label: labels.feeling.categories[0], value: 0 }, { label: labels.feeling.categories[1], value: 1 }, @@ -52,42 +52,40 @@ export default class Mucus extends SymptomView { ] const mandatoryNotCompletedYet = typeof this.state.feeling != 'number' || typeof this.state.texture != 'number' return ( - - - - this.setState({ feeling: val })} - active={this.state.feeling} - /> - - - this.setState({ texture: val })} - active={this.state.texture} - /> - - - { - this.setState({ exclude: val }) - }} - value={this.state.exclude} - /> - - - + + + this.setState({ feeling: val })} + active={this.state.feeling} + /> + + + this.setState({ texture: val })} + active={this.state.texture} + /> + + + { + this.setState({ exclude: val }) + }} + value={this.state.exclude} + /> + + ) } } diff --git a/components/cycle-day/symptoms/note.js b/components/cycle-day/symptoms/note.js index bf435db..8cb8b75 100644 --- a/components/cycle-day/symptoms/note.js +++ b/components/cycle-day/symptoms/note.js @@ -34,25 +34,23 @@ export default class Note extends SymptomView { }) } - render() { + renderContent() { return ( - - - - { - this.setState({ currentValue: val }) - }} - value={this.state.currentValue} - /> - - - + + + { + this.setState({ currentValue: val }) + }} + value={this.state.currentValue} + /> + + ) } } diff --git a/components/cycle-day/symptoms/pain.js b/components/cycle-day/symptoms/pain.js index 4a07ee5..30ac355 100644 --- a/components/cycle-day/symptoms/pain.js +++ b/components/cycle-day/symptoms/pain.js @@ -2,7 +2,6 @@ import React from 'react' import { ScrollView, TextInput, - View } from 'react-native' import { pain as labels } from '../../../i18n/en/cycle-day' import { shared as sharedLabels } from '../../../i18n/en/labels' @@ -49,19 +48,18 @@ export default class Pain extends SymptomView { } } - render() { + renderContent() { return ( - - - - - { this.state.other && + + + + { this.state.other && - } - - - - ) + } + + ) } } diff --git a/components/cycle-day/symptoms/sex.js b/components/cycle-day/symptoms/sex.js index 8972fa3..9b195da 100644 --- a/components/cycle-day/symptoms/sex.js +++ b/components/cycle-day/symptoms/sex.js @@ -1,7 +1,6 @@ import React from 'react' import { TextInput, - View, ScrollView } from 'react-native' import styles from '../../../styles' @@ -49,32 +48,31 @@ export default class Sex extends SymptomView { } } - render() { + renderContent() { return ( - - - - - - - - + + + + + + + - {this.state.other && + {this.state.other && - } - - + } + ) } } diff --git a/components/cycle-day/symptoms/symptom-view.js b/components/cycle-day/symptoms/symptom-view.js index 987a993..9997f0c 100644 --- a/components/cycle-day/symptoms/symptom-view.js +++ b/components/cycle-day/symptoms/symptom-view.js @@ -1,11 +1,15 @@ +import React from 'react' import { Component } from 'react' -import { BackHandler } from 'react-native' +import { BackHandler, View } from 'react-native' import { saveSymptom } from '../../../db' +import Header from '../../header/symptom-view' +import { headerTitles } from '../../../i18n/en/labels' export default class SymptomView extends Component { constructor(props) { super() this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.onBackButtonPress.bind(this)) + this.globalBackhandler = props.handleBackButtonPress this.symptomName = props.symptomName this.date = props.date } @@ -21,4 +25,20 @@ export default class SymptomView extends Component { componentWillUnmount() { this.backHandler.remove() } + + render() { + return ( + +
{ + this.onBackButtonPress() + this.globalBackhandler() + }} + /> + {this.renderContent()} + + ) + } } \ No newline at end of file diff --git a/components/cycle-day/symptoms/temperature.js b/components/cycle-day/symptoms/temperature.js index ce06a3c..4e54eb8 100644 --- a/components/cycle-day/symptoms/temperature.js +++ b/components/cycle-day/symptoms/temperature.js @@ -116,13 +116,12 @@ export default class Temp extends SymptomView { this.setState({ isTimePickerVisible: true }) } - render() { + renderContent() { const inputStyle = [styles.temperatureTextInput] if (this.state.isSuggestion) { inputStyle.push(styles.temperatureTextInputSuggestion) } return ( - - ) } } diff --git a/components/header/index.js b/components/header/index.js index 9792d03..3de4034 100644 --- a/components/header/index.js +++ b/components/header/index.js @@ -3,7 +3,6 @@ import { Dimensions } from 'react-native' import CycleDayHeader from './cycle-day' import DefaultHeader from './default' import BackButtonHeader from './back-button' -import SymptomViewHeader from './symptom-view' export default function Header(p) { const middle = Dimensions.get('window').width / 2 @@ -11,11 +10,7 @@ export default function Header(p) { if (props.isCycleDayOverView) { return () - } - else if (props.isSymptomView) { - return () - } - else if (props.showBackButton) { + } else if (props.showBackButton) { return () } else { diff --git a/components/header/symptom-view.js b/components/header/symptom-view.js index 0b4e6d1..6f01113 100644 --- a/components/header/symptom-view.js +++ b/components/header/symptom-view.js @@ -2,7 +2,8 @@ import React from 'react' import { View, Text, - TouchableOpacity + TouchableOpacity, + Dimensions } from 'react-native' import styles, { iconStyles } from '../../styles' import FeatherIcon from 'react-native-vector-icons/Feather' @@ -10,11 +11,12 @@ import NavigationArrow from './navigation-arrow' import formatDate from '../helpers/format-date' export default function SymptomViewHeader(props) { + const middle = Dimensions.get('window').width / 2 return (