import React, { Component } from 'react'
import {
Text, View, TouchableOpacity
} from 'react-native'
import Svg,{ G, Rect, Line } from 'react-native-svg'
import Icon from 'react-native-vector-icons/Entypo'
import styles from './styles'
import config from '../../config'
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,
leftTemperatureExclude,
columnHeight,
symptomHeight,
chartHeight,
symptomRowSymptoms,
xAxisHeight
} = this.props
const columnElements = []
if(drawLtlAt) {
const ltlLine = ()
columnElements.push(ltlLine)
}
if (drawFhmLine) {
const x = styles.nfpLine.strokeWidth / 2
const fhmLine = ()
columnElements.push(fhmLine)
}
if (y) {
columnElements.push(
)
}
const cycleDayNumber = this.getCycleDayNumber(dateString)
const shortDate = dateString.split('-').slice(1).join('-')
const cycleDayLabel = (
{cycleDayNumber ? cycleDayNumber : ' '}
)
const dateLabel = (
{shortDate}
)
const column = (
{ columnElements }
)
const symptomIconViews = {
bleeding: (
),
mucus: (
),
cervix: (
0 ? 'blue' : 'green'}
/>
),
sex: (
),
desire: (
),
pain: (
),
note: (
)
}
return (
this.passDateToDayView(dateString)}
activeOpacity={1}
>
{symptomRowSymptoms.map(symptomName => symptomIconViews[symptomName])}
{cycleDayLabel}
{dateLabel}
)
}
}
function SymptomIconView(props) {
const style = [styles.symptomRow, {height: props.symptomHeight}]
return (
{(typeof props.value === 'number' || props.value === true || typeof props.value === 'string') &&
props.children
}
)
}