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,
columnHeight,
symptomHeight,
chartHeight,
symptomRowSymptoms,
xAxisHeight
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>
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
146
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
const symptomIconViews = {
bleeding: (
<SymptomIconView
value={this.props.bleeding}
symptomHeight={symptomHeight}
key='bleeding'
>
<Icon
name='drop'
size={12}
color={styles.bleedingIconShades[this.props.bleeding]}
/>
</SymptomIconView>
),
mucus: (
<SymptomIconView
value={this.props.mucus}
symptomHeight={symptomHeight}
key='mucus'
>
<View
{...styles.mucusIcon}
backgroundColor={styles.mucusIconShades[this.props.mucus]}
/>
</SymptomIconView>
),
cervix: (
<SymptomIconView
value={this.props.cervix}
symptomHeight={symptomHeight}
key='cervix'
>
<View
{...styles.mucusIcon}
// cervix is sum of openess and firmness - fertile only when closed and hard (=0)
backgroundColor={this.props.cervix > 0 ? 'blue' : 'green'}
/>
</SymptomIconView>
),
sex: (
<SymptomIconView
value={this.props.sex}
symptomHeight={symptomHeight}
key='sex'
>
<View
{...styles.mucusIcon}
backgroundColor='orange'
/>
</SymptomIconView>
),
desire: (
<SymptomIconView
value={this.props.desire}
symptomHeight={symptomHeight}
key='desire'
>
<View
{...styles.mucusIcon}
backgroundColor='red'
/>
</SymptomIconView>
),
pain: (
<SymptomIconView
value={this.props.pain}
symptomHeight={symptomHeight}
key='pain'
>
<View
{...styles.mucusIcon}
backgroundColor='blue'
/>
</SymptomIconView>
),
note: (
<SymptomIconView
value={this.props.note}
symptomHeight={symptomHeight}
key='note'
>
<View
{...styles.mucusIcon}
backgroundColor='green'
/>
</SymptomIconView>
)
}
<TouchableOpacity
onPress={() => this.passDateToDayView(dateString)}
activeOpacity={1}
>
<View>
{symptomRowSymptoms.map(symptomName => symptomIconViews[symptomName])}
<Svg width={config.columnWidth} height={columnHeight}>
<View style={{height: xAxisHeight}}>
{cycleDayLabel}
{dateLabel}
</View>
function SymptomIconView(props) {
const style = [styles.symptomRow, {height: props.symptomHeight}]
return (
<View style={style}>
{(typeof props.value === 'number' || props.value === true || typeof props.value === 'string') &&
props.children
}
</View>
)
}