adds icons to chart

This commit is contained in:
tina
2018-09-28 16:35:20 +02:00
parent fb5a51621f
commit eed70545c6
+60 -2
View File
@@ -2,6 +2,7 @@ import React, { Component } from 'react'
import { View, FlatList } from 'react-native' import { View, FlatList } from 'react-native'
import range from 'date-range' import range from 'date-range'
import { LocalDate } from 'js-joda' import { LocalDate } from 'js-joda'
import Svg, { G } from 'react-native-svg'
import { makeYAxisLabels, normalizeToScale, makeHorizontalGrid } from './y-axis' import { makeYAxisLabels, normalizeToScale, makeHorizontalGrid } from './y-axis'
import nfpLines from './nfp-lines' import nfpLines from './nfp-lines'
import DayColumn from './day-column' import DayColumn from './day-column'
@@ -11,6 +12,13 @@ import { scaleObservable } from '../../local-storage'
import config from '../../config' import config from '../../config'
import { AppText } from '../app-text' import { AppText } from '../app-text'
import { shared as labels } from '../labels' import { shared as labels } from '../labels'
import BleedingIcon from '../../assets/bleeding'
import CervixIcon from '../../assets/cervix'
import DesireIcon from '../../assets/desire'
import MucusIcon from '../../assets/mucus'
import NoteIcon from '../../assets/note'
import PainIcon from '../../assets/pain'
import SexIcon from '../../assets/sex'
export default class CycleChart extends Component { export default class CycleChart extends Component {
constructor(props) { constructor(props) {
@@ -153,8 +161,20 @@ export default class CycleChart extends Component {
<View> <View>
<View style={[styles.yAxis, {height: this.symptomRowHeight}]}> <View style={[styles.yAxis, {height: this.symptomRowHeight}]}>
{this.symptomRowSymptoms.map(symptomName => { {this.symptomRowSymptoms.map(symptomName => {
return <View key={symptomName} style={{flex: 1}}> return <View
<AppText>{symptomName[0]}</AppText> style={{ alignItems: 'center', justifyContent: 'center' }}
key={symptomName}
width={styles.yAxis.width}
height={this.symptomRowHeight / this.symptomRowSymptoms.length}
>
<Svg
width={styles.yAxis.width * 0.8} height={this.symptomRowHeight / this.symptomRowSymptoms.length * 0.8}
viewBox={symptomIcons[symptomName].viewBox}
>
<G fill={symptomIcons[symptomName].color}>
{symptomIcons[symptomName].icon}
</G>
</Svg>
</View> </View>
})} })}
</View> </View>
@@ -224,4 +244,42 @@ function getInfoForNeighborColumns(index, cols) {
ret.leftTemperatureExclude = left.temperatureExclude ret.leftTemperatureExclude = left.temperatureExclude
} }
return ret return ret
}
const symptomIcons = {
'bleeding': {
'viewBox': '10 10 320 400',
'color': styles.iconShades.bleeding[3],
'icon': <BleedingIcon strokeWidth={'5'}/>
},
'mucus': {
'viewBox': '10 10 320 400',
'color': styles.iconShades.mucus[4],
'icon': <MucusIcon/>
},
'cervix': {
'viewBox': '10 10 320 440',
'color': styles.iconShades.cervix[3],
'icon': <CervixIcon/>
},
'desire': {
'viewBox': '10 10 320 380',
'color': styles.iconShades.desire[2],
'icon': <DesireIcon/>
},
'sex': {
'viewBox': '10 10 320 400',
'color': styles.iconShades.sex[2],
'icon': <SexIcon/>
},
'pain': {
'viewBox': '10 10 300 400',
'color': styles.iconShades.pain[0],
'icon': <PainIcon/>
},
'note': {
'viewBox': '10 10 270 400',
'color': styles.iconShades.note[0],
'icon': <NoteIcon/>
},
} }