Newer
Older
} from 'react-native'
import Svg,{ G, Rect, Line } from 'react-native-svg'
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 = (<Line
x1={0}
y1={drawLtlAt}
x2={config.columnWidth}
y2={drawLtlAt}
if (drawFhmLine) {
const x = styles.nfpLine.strokeWidth / 2
const fhmLine = (<Line
x1={x}
y1={x}
x2={x}
y2={columnHeight}
{...styles.nfpLine}
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}>
<Rect
height={chartHeight}
{...styles.column.rect}
/>
{ columnElements }
</G>
<TouchableOpacity
onPress={() => this.passDateToDayView(dateString)}
activeOpacity={1}
>
<View height={symptomHeight}>
<View style={styles.symptomRow}>
{typeof this.props.bleeding === 'number' &&
color={styles.bleedingIconShades[this.props.bleeding]}
key='bleeding'
/>
}
</View>
<View style={styles.symptomRow}>
{typeof this.props.mucus === 'number' &&
backgroundColor={styles.mucusIconShades[this.props.mucus]}
key='mucus'
/>
}
</View>
<View style={styles.symptomRow}>
{typeof this.props.cervix === 'number' &&
<View
{...styles.mucusIcon}
// cervix is sum of openess and firmness - fertile only when closed and hard (=0)
backgroundColor={this.props.cervix > 0 ? 'blue' : 'green'}
key='cervix'
/>
}
</View>
<View style={styles.symptomRow}>
{typeof this.props.sex === 'number' &&
key='sex'
/>
}
</View>
<View style={styles.symptomRow}>
{typeof this.props.desire === 'number' &&
<View
{...styles.mucusIcon}
backgroundColor='red'
key='desire'
/>
}
</View>
<View style={styles.symptomRow}>
<View
{...styles.mucusIcon}
backgroundColor='blue'
key='pain'
/>
}
</View>
<View style={styles.symptomRow}>
<View
{...styles.mucusIcon}
backgroundColor='green'
key='note'
/>
}
</View>
<Svg width={config.columnWidth} height={columnHeight}>
<View style={{height: xAxisHeight}}>
{cycleDayLabel}
{dateLabel}
</View>