Make symptom section component

This commit is contained in:
Julia Friesel
2018-09-01 21:17:54 +02:00
parent 4d8a4a79fd
commit 98fbacf9f8
4 changed files with 85 additions and 50 deletions
+12 -11
View File
@@ -9,7 +9,7 @@ import { saveSymptom } from '../../../db'
import { bleeding as labels } from '../labels/labels' import { bleeding as labels } from '../labels/labels'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import SelectTabGroup from '../select-tab-group' import SelectTabGroup from '../select-tab-group'
import { SymptomSectionHeader, AppText } from '../../app-text' import SymptomSection from './symptom-section'
export default class Bleeding extends Component { export default class Bleeding extends Component {
constructor(props) { constructor(props) {
@@ -36,27 +36,28 @@ export default class Bleeding extends Component {
return ( return (
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View> <SymptomSection
<SymptomSectionHeader>Heaviness</SymptomSectionHeader> header="Heaviness"
<AppText>How heavy is the bleeding?</AppText> explainer="How heavy is the bleeding?"
>
<SelectTabGroup <SelectTabGroup
buttons={bleedingRadioProps} buttons={bleedingRadioProps}
active={this.state.currentValue} active={this.state.currentValue}
onSelect={val => this.setState({ currentValue: val })} onSelect={val => this.setState({ currentValue: val })}
/> />
<SymptomSectionHeader>Exclude</SymptomSectionHeader> </SymptomSection>
<View flexDirection={'row'}> <SymptomSection
<View flex={1}> header="Exclude"
<AppText>{"You can exclude this value if it's not menstrual bleeding"}</AppText> explainer="You can exclude this value if it's not menstrual bleeding"
</View> inlineExplainer={true}
>
<Switch <Switch
onValueChange={(val) => { onValueChange={(val) => {
this.setState({ exclude: val }) this.setState({ exclude: val })
}} }}
value={this.state.exclude} value={this.state.exclude}
/> />
</View> </SymptomSection>
</View>
</ScrollView> </ScrollView>
<ActionButtonFooter <ActionButtonFooter
symptom='bleeding' symptom='bleeding'
+22 -10
View File
@@ -9,7 +9,7 @@ import { saveSymptom } from '../../../db'
import { cervix as labels } from '../labels/labels' import { cervix as labels } from '../labels/labels'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import SelectTabGroup from '../select-tab-group' import SelectTabGroup from '../select-tab-group'
import { SymptomSectionHeader, AppText } from '../../app-text' import SymptomSection from './symptom-section'
export default class Cervix extends Component { export default class Cervix extends Component {
constructor(props) { constructor(props) {
@@ -48,36 +48,48 @@ export default class Cervix extends Component {
return ( return (
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<SymptomSectionHeader>Opening</SymptomSectionHeader> <SymptomSection
<AppText>{labels.opening.explainer}</AppText> header="Opening"
explainer={labels.opening.explainer}
>
<SelectTabGroup <SelectTabGroup
buttons={cervixOpeningRadioProps} buttons={cervixOpeningRadioProps}
active={this.state.opening} active={this.state.opening}
onSelect={val => this.setState({ opening: val })} onSelect={val => this.setState({ opening: val })}
/> />
<SymptomSectionHeader>Firmness</SymptomSectionHeader> </SymptomSection>
<AppText>{labels.firmness.explainer}</AppText> <SymptomSection
header="Firmness"
explainer={labels.firmness.explainer}
>
<SelectTabGroup <SelectTabGroup
buttons={cervixFirmnessRadioProps} buttons={cervixFirmnessRadioProps}
active={this.state.firmness} active={this.state.firmness}
onSelect={val => this.setState({ firmness: val })} onSelect={val => this.setState({ firmness: val })}
/> />
<SymptomSectionHeader>Position</SymptomSectionHeader> </SymptomSection>
<AppText>{labels.position.explainer}</AppText> <SymptomSection
header="Position"
explainer={labels.position.explainer}
>
<SelectTabGroup <SelectTabGroup
buttons={cervixPositionRadioProps} buttons={cervixPositionRadioProps}
active={this.state.position} active={this.state.position}
onSelect={val => this.setState({ position: val })} onSelect={val => this.setState({ position: val })}
/> />
<View style={styles.symptomViewRowInline}> </SymptomSection>
<SymptomSectionHeader>Exclude</SymptomSectionHeader> <SymptomSection
header="Exclude"
explainer="You can exclude this value if you don't want to use it for fertility detection"
inlineExplainer={true}
>
<Switch <Switch
onValueChange={(val) => { onValueChange={(val) => {
this.setState({ exclude: val }) this.setState({ exclude: val })
}} }}
value={this.state.exclude} value={this.state.exclude}
/> />
</View> </SymptomSection>
</ScrollView> </ScrollView>
<ActionButtonFooter <ActionButtonFooter
symptom='cervix' symptom='cervix'
+6 -3
View File
@@ -8,7 +8,7 @@ import { saveSymptom } from '../../../db'
import { intensity, desire } from '../labels/labels' import { intensity, desire } from '../labels/labels'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import SelectTabGroup from '../select-tab-group' import SelectTabGroup from '../select-tab-group'
import { SymptomSectionHeader, AppText } from '../../app-text'; import SymptomSection from './symptom-section'
export default class Desire extends Component { export default class Desire extends Component {
constructor(props) { constructor(props) {
@@ -31,13 +31,16 @@ export default class Desire extends Component {
return ( return (
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<SymptomSectionHeader>{desire.header}</SymptomSectionHeader> <SymptomSection
<AppText>{desire.explainer}</AppText> header={desire.header}
explainer={desire.explainer}
>
<SelectTabGroup <SelectTabGroup
buttons={desireRadioProps} buttons={desireRadioProps}
acitve={this.state.currentValue} acitve={this.state.currentValue}
onSelect={val => this.setState({ currentValue: val })} onSelect={val => this.setState({ currentValue: val })}
/> />
</SymptomSection>
</ScrollView> </ScrollView>
<ActionButtonFooter <ActionButtonFooter
symptom='desire' symptom='desire'
@@ -0,0 +1,19 @@
import React, { Component } from 'react'
import { View } from 'react-native'
import { SymptomSectionHeader, AppText } from '../../app-text'
export default class SymptomSection extends Component {
render() {
return (
<View>
<SymptomSectionHeader>{this.props.header}</SymptomSectionHeader>
<View flexDirection={this.props.inlineExplainer ? 'row' : 'column'}>
<View flex={1}>
<AppText>{this.props.explainer}</AppText>
</View>
{this.props.children}
</View>
</View>
)
}
}