import React, { Component } from 'react' import { Text, View, TouchableOpacity } from 'react-native' 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 getCycleDayNumber = cycleModule().getCycleDayNumber const label = styles.column.label export default class DayColumn extends Component { 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, bleeding, mucus, drawFhmLine, drawLtlAt, rightY, rightTemperatureExclude, leftY, leftTemperatureExclude } = this.props const columnElements = [] if (typeof bleeding === 'number') { columnElements.push( ) } if (typeof mucus === 'number') { const mucusIcon = ( ) columnElements.push(mucusIcon) } if(drawFhmLine) { const fhmLine = () columnElements.push(fhmLine) } if(drawLtlAt) { const ltlLine = () columnElements.push(ltlLine) } if (y) { columnElements.push( ) } const cycleDayNumber = getCycleDayNumber(dateString) const shortDate = dateString.split('-').slice(1).join('-') const cycleDayLabel = ( {cycleDayNumber} ) const dateLabel = ( {shortDate} ) columnElements.push( {cycleDayLabel} {dateLabel} ) return React.createElement( TouchableOpacity, { style: styles.column.rect, key: this.props.index.toString(), onPress: () => { this.passDateToDayView(dateString) }, activeOpacity: 1 }, columnElements ) } }