Newer
Older
import React, { Component } from 'react'
import {
View,
} from 'react-native'
import styles from '../../styles'
mucusFeeling as feelingLabels,
mucusTexture as textureLabels,
mucusNFP as computeSensiplanMucusLabels,
cervixOpening as openingLabels,
cervixFirmness as firmnessLabels,
cervixPosition as positionLabels,
intensity as intensityLabels
export default class DayView extends Component {
render() {
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<View style={styles.symptomBoxesView}>
<SymptomBox
title='Bleeding'
icon={require('./assets/placeholder.png')}
onPress={() => this.showView('BleedingEditView')}
data={getLabel('bleeding', cycleDay.bleeding)}
/>
<SymptomBox
title='Temperature'
icon={require('./assets/placeholder.png')}
onPress={() => this.showView('TemperatureEditView')}
data={getLabel('temperature', cycleDay.temperature)}
/>
<SymptomBox
title='Mucus'
icon={require('./assets/placeholder.png')}
onPress={() => this.showView('MucusEditView')}
data={getLabel('mucus', cycleDay.mucus)}
/>
<SymptomBox
title='Cervix'
icon={require('./assets/placeholder.png')}
onPress={() => this.showView('CervixEditView')}
data={getLabel('cervix', cycleDay.cervix)}
/>
<SymptomBox
title='Note'
icon={require('./assets/placeholder.png')}
onPress={() => this.showView('NoteEditView')}
data={getLabel('note', cycleDay.note)}
/>
<SymptomBox
title='Desire'
icon={require('./assets/placeholder.png')}
onPress={() => this.showView('DesireEditView')}
data={getLabel('desire', cycleDay.desire)}
/>
<SymptomBox
title='Sex'
icon={require('./assets/placeholder.png')}
onPress={() => this.showView('SexEditView')}
data={getLabel('sex', cycleDay.sex)}
/>
{/* this is just to make the last row adhere to the grid
(and) because there are no pseudo properties in RN */}
<FillerBoxes/>
function getLabel(symptomName, symptom) {
const labels = {
bleeding: bleeding => {
if (typeof bleeding.value === 'number') {
let bleedingLabel = `${bleedingLabels[bleeding.value]}`
if (bleeding.exclude) bleedingLabel = "( " + bleedingLabel + " )"
return bleedingLabel
}
},
temperature: temperature => {
if (typeof temperature.value === 'number') {
let temperatureLabel = `${temperature.value} °C - ${temperature.time}`
if (temperature.exclude) {
temperatureLabel = "( " + temperatureLabel + " )"
}
return temperatureLabel
}
},
mucus: mucus => {
if (
typeof mucus.feeling === 'number' &&
typeof mucus.texture === 'number' &&
typeof mucus.value === 'number'
) {
let mucusLabel =
`${feelingLabels[mucus.feeling]} +
${textureLabels[mucus.texture]}
( ${computeSensiplanMucusLabels[mucus.value]} )`
if (mucus.exclude) mucusLabel = "( " + mucusLabel + " )"
return mucusLabel
}
},
cervix: cervix => {
if (cervix.opening > -1 && cervix.firmness > -1) {
let cervixLabel =
`${openingLabels[cervix.opening]} +
${firmnessLabels[cervix.firmness]}`
if (cervix.position > -1) {
cervixLabel += `+ ${positionLabels[cervix.position]}`
}
if (cervix.exclude) cervixLabel = "( " + cervixLabel + " )"
return cervixLabel
}
},
note: note => {
return note.value.slice(0, 12) + '...'
},
desire: desire => {
if (typeof desire.value === 'number') {
const desireLabel = `${intensityLabels[desire.value]}`
},
sex: sex => {
let sexLabel = ''
if ( sex.solo || sex.partner ) {
sexLabel += 'Activity '
}
if (sex.condom || sex.pill || sex.iud ||
sex.patch || sex.ring || sex.implant || sex.other) {
sexLabel += 'Contraceptive'
}
class SymptomBox extends Component {
render() {
return (
<TouchableOpacity onPress={this.props.onPress}>
<View style={styles.symptomBox}>
<Image
source={require('./assets/placeholder.png')}
style={styles.symptomBoxImage}
/>
<Text>{this.props.title}</Text>
<Text>{this.props.data}</Text>
</View>
</TouchableOpacity>
)
}
}
class FillerBoxes extends Component {
render() {
const n = Dimensions.get('window').width / styles.symptomBox.minHeight
const fillerBoxes = []
for (let i = 0; i < Math.ceil(n); i++) {
fillerBoxes.push(
<View
width={styles.symptomBox.minHeight}
height={0}
key={i.toString()}
/>
)
}
return fillerBoxes