Newer
Older
} from 'react-native'
import Icon from 'react-native-vector-icons/Entypo'
import { getOrCreateCycleDay } from '../../db'
import cycleModule from '../../lib/cycle'
import DotAndLine from './dot-and-line'
const label = styles.column.label
export default class DayColumn extends Component {
constructor() {
super()
this.getCycleDayNumber = cycleModule().getCycleDayNumber
}
passDateToDayView(dateString) {
const cycleDay = getOrCreateCycleDay(dateString)
this.props.navigate('CycleDay', { cycleDay })
}
shouldComponentUpdate(newProps) {
return Object.keys(newProps).some(key => newProps[key] != this.props[key])
}
render() {
const {
dateString,
y,
temperatureExclude,
drawFhmLine,
drawLtlAt,
rightY,
rightTemperatureExclude,
leftY,
const columnHeight = chartHeight * config.columnHeightPercentage
const xAxisHeight = chartHeight * config.xAxisHeightPercentage
const symptomHeight = chartHeight * config.symptomRowHeightPercentage
const ltlLine = (<View
position = 'absolute'
width={'100%'}
columnElements.push(
<DotAndLine
y={y}
exclude={temperatureExclude}
rightY={rightY}
rightTemperatureExclude={rightTemperatureExclude}
leftY={leftY}
leftTemperatureExclude={leftTemperatureExclude}
const cycleDayNumber = this.getCycleDayNumber(dateString)
const shortDate = dateString.split('-').slice(1).join('-')
const cycleDayLabel = (
{cycleDayNumber ? cycleDayNumber : ' '}
<Text style = {label.date}>
// we merge the colors here instead of from the stylesheet because of a RN
// bug that doesn't apply borderLeftColor otherwise
const potentialCustomStyle = {
height: columnHeight,
borderLeftColor: 'grey',
}
potentialCustomStyle.borderLeftColor = styles.nfpLine.borderColor
potentialCustomStyle.borderLeftWidth = 3
const column = React.createElement(
style: [styles.column.rect, potentialCustomStyle],
onPress: () => {
this.passDateToDayView(dateString)
},
},
columnElements
return (
<View>
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<View height={symptomHeight}>
<View style={styles.symptomRow}>
{typeof symptoms.bleeding === 'number' &&
<Icon
name='drop'
size={12}
color={styles.bleedingIconShades[symptoms.bleeding]}
key='bleeding'
/>
}
</View>
<View style={styles.symptomRow}>
{typeof symptoms.mucus === 'number' &&
<View
{...styles.mucusIcon}
backgroundColor={styles.mucusIconShades[symptoms.mucus]}
key='mucus'
/>
}
</View>
<View style={styles.symptomRow}>
{typeof symptoms.cervix === 'number' &&
<View
{...styles.mucusIcon}
// cervix is sum of openess and firmness - fertile only when closed and hard (=0)
backgroundColor={symptoms.cervix > 0 ? 'blue' : 'green'}
key='cervix'
/>
}
</View>
<View style={styles.symptomRow}>
{typeof symptoms.sex === 'number' &&
<View
{...styles.mucusIcon}
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
key='sex'
/>
}
</View>
<View style={styles.symptomRow}>
{typeof symptoms.desire === 'number' &&
<View
{...styles.mucusIcon}
backgroundColor='red'
key='desire'
/>
}
</View>
<View style={styles.symptomRow}>
{symptoms.pain &&
<View
{...styles.mucusIcon}
backgroundColor='blue'
key='pain'
/>
}
</View>
<View style={styles.symptomRow}>
{symptoms.note &&
<View
{...styles.mucusIcon}
backgroundColor='green'
key='note'
/>
}
</View>
<View style={{height: xAxisHeight}}>
{cycleDayLabel}
{dateLabel}
</View>
</View>
)