diff --git a/components/chart/chart.js b/components/chart/chart.js index 4106938..4c97637 100644 --- a/components/chart/chart.js +++ b/components/chart/chart.js @@ -1,31 +1,17 @@ import React, { Component } from 'react' import { View, FlatList, ActivityIndicator } from 'react-native' import { LocalDate } from 'js-joda' -import { makeYAxisLabels, makeHorizontalGrid } from './y-axis' +import YAxis, { makeHorizontalGrid } from './y-axis' import nfpLines from './nfp-lines' import DayColumn from './day-column' import { getCycleDaysSortedByDate, getAmountOfCycleDays } from '../../db' import styles from './styles' -import { cycleDayColor } from '../../styles' import { scaleObservable } from '../../local-storage' import config from '../../config' -import AppText from '../app-text' -import AppLoadingView from '../app-loading' -import { shared as labels } from '../../i18n/en/labels' -import DripIcon from '../../assets/drip-icons' -import DripHomeIcon from '../../assets/drip-home-icons' -import nothingChanged from '../../db/db-unchanged' -const symptomIcons = { - bleeding: , - mucus: , - cervix: , - desire: , - sex: , - pain: , - mood: , - note: -} +import AppLoadingView from '../app-loading' + +import nothingChanged from '../../db/db-unchanged' export default class CycleChart extends Component { constructor(props) { @@ -129,49 +115,27 @@ export default class CycleChart extends Component { } render() { + const { chartHeight, chartLoaded } = this.state return ( - {!this.state.chartLoaded && } + {!chartLoaded && } - {this.state.chartHeight && this.state.chartLoaded && - - - {this.symptomRowSymptoms.map(symptomName => { - return - {symptomIcons[symptomName]} - - })} - - - {makeYAxisLabels(this.columnHeight)} - - - - - {labels.date.toLowerCase()} - - - } + {chartHeight && chartLoaded && ( + + )} - - {this.state.chartHeight && this.state.chartLoaded && + {chartHeight && chartLoaded && makeHorizontalGrid(this.columnHeight, this.symptomRowHeight) } - {this.state.chartHeight && + {chartHeight && , + mucus: , + cervix: , + desire: , + sex: , + pain: , + mood: , + note: +} + export function makeYAxisLabels(columnHeight) { const units = unitObservable.value @@ -72,4 +94,42 @@ function getAbsoluteValue(relative, columnHeight) { const verticalPadding = columnHeight * config.temperatureScale.verticalPadding const scaleHeight = columnHeight - 2 * verticalPadding return scaleHeight * relative + verticalPadding -} \ No newline at end of file +} + +const YAxis = ({ height, symptomsToDisplay, symptomsSectionHeight }) => { + return ( + + + {symptomsToDisplay.map(symptomName => { + return + {symptomIcons[symptomName]} + + })} + + {makeYAxisLabels(height)} + + + + {labels.date.toLowerCase()} + + + + ) +} + +YAxis.propTypes = { + height: PropTypes.number, + symptomsToDisplay: PropTypes.array, + symptomsSectionHeight: PropTypes.number, +} + +export default YAxis