130 lines
3.8 KiB
JavaScript
130 lines
3.8 KiB
JavaScript
import React from 'react'
|
|
import {
|
|
Alert,
|
|
Switch,
|
|
ScrollView,
|
|
TouchableOpacity,
|
|
View
|
|
} from 'react-native'
|
|
import FeatherIcon from 'react-native-vector-icons/Feather'
|
|
|
|
import { cervix as labels } from '../../../i18n/en/cycle-day'
|
|
import infoLabels from '../../../i18n/en/symptom-info'
|
|
import styles, { iconStyles } from '../../../styles'
|
|
|
|
import SelectTabGroup from '../select-tab-group'
|
|
|
|
import SymptomSection from './symptom-section'
|
|
import SymptomView from './symptom-view'
|
|
|
|
export default class Cervix extends SymptomView {
|
|
constructor(props) {
|
|
super(props)
|
|
const cycleDay = props.cycleDay
|
|
this.cervix = cycleDay && cycleDay.cervix
|
|
this.state = this.cervix ? this.cervix : {}
|
|
}
|
|
|
|
symptomName = 'cervix'
|
|
|
|
showInfoBox(){
|
|
const symptomName = 'cervix'
|
|
Alert.alert(
|
|
infoLabels[symptomName].title,
|
|
infoLabels[symptomName].text
|
|
)
|
|
}
|
|
|
|
onBackButtonPress() {
|
|
const nothingEntered = ['opening', 'firmness', 'position'].every(val => typeof this.state[val] != 'number')
|
|
if (nothingEntered) {
|
|
this.deleteSymptomEntry()
|
|
return
|
|
}
|
|
|
|
this.saveSymptomEntry({
|
|
opening: this.state.opening,
|
|
firmness: this.state.firmness,
|
|
position: this.state.position,
|
|
exclude: Boolean(this.state.exclude)
|
|
})
|
|
}
|
|
|
|
renderContent() {
|
|
const cervixOpeningRadioProps = [
|
|
{ label: labels.opening.categories[0], value: 0 },
|
|
{ label: labels.opening.categories[1], value: 1 },
|
|
{ label: labels.opening.categories[2], value: 2 }
|
|
]
|
|
const cervixFirmnessRadioProps = [
|
|
{ label: labels.firmness.categories[0], value: 0 },
|
|
{ label: labels.firmness.categories[1], value: 1 }
|
|
]
|
|
const cervixPositionRadioProps = [
|
|
{ label: labels.position.categories[0], value: 0 },
|
|
{ label: labels.position.categories[1], value: 1 },
|
|
{ label: labels.position.categories[2], value: 2 }
|
|
]
|
|
// TODO saving this info for notice when leaving incomplete data
|
|
// const mandatoryNotCompleted = typeof this.state.opening != 'number' || typeof this.state.firmness != 'number'
|
|
return (
|
|
<ScrollView style={styles.page}>
|
|
<View style={{ flexDirection: 'row' }}>
|
|
<SymptomSection
|
|
header="Opening"
|
|
explainer={labels.opening.explainer}
|
|
>
|
|
<SelectTabGroup
|
|
buttons={cervixOpeningRadioProps}
|
|
active={this.state.opening}
|
|
onSelect={val => this.setState({ opening: val })}
|
|
/>
|
|
</SymptomSection>
|
|
<View style={{ flex: 1 }}></View>
|
|
<TouchableOpacity
|
|
onPress={this.showInfoBox}
|
|
style={styles.infoButton}
|
|
>
|
|
<FeatherIcon
|
|
name="info"
|
|
style={iconStyles.symptomInfo}
|
|
/>
|
|
</TouchableOpacity>
|
|
</View>
|
|
<SymptomSection
|
|
header="Firmness"
|
|
explainer={labels.firmness.explainer}
|
|
>
|
|
<SelectTabGroup
|
|
buttons={cervixFirmnessRadioProps}
|
|
active={this.state.firmness}
|
|
onSelect={val => this.setState({ firmness: val })}
|
|
/>
|
|
</SymptomSection>
|
|
<SymptomSection
|
|
header="Position"
|
|
explainer={labels.position.explainer}
|
|
>
|
|
<SelectTabGroup
|
|
buttons={cervixPositionRadioProps}
|
|
active={this.state.position}
|
|
onSelect={val => this.setState({ position: val })}
|
|
/>
|
|
</SymptomSection>
|
|
<SymptomSection
|
|
header="Exclude"
|
|
explainer="You can exclude this value if you don't want to use it for fertility detection"
|
|
inline={true}
|
|
>
|
|
<Switch
|
|
onValueChange={(val) => {
|
|
this.setState({ exclude: val })
|
|
}}
|
|
value={this.state.exclude}
|
|
/>
|
|
</SymptomSection>
|
|
</ScrollView>
|
|
)
|
|
}
|
|
}
|