diff --git a/components/chart/chart.js b/components/chart/chart.js index ffc311f..604966e 100644 --- a/components/chart/chart.js +++ b/components/chart/chart.js @@ -1,6 +1,5 @@ import React, { Component } from 'react' -import { View } from 'react-native' -import { RecyclerListView, DataProvider, LayoutProvider } from "recyclerlistview" +import { View, FlatList, Dimensions } from 'react-native' import range from 'date-range' import { LocalDate } from 'js-joda' import { yAxis, normalizeToScale } from './y-axis' @@ -11,19 +10,6 @@ import config from './config' const yAxisView = {yAxis.labels} -const dataProvider = new DataProvider((a,b) => { - return Object.keys(a).some(key => a[key] != b[key]) -}) - -const layoutProvider = new LayoutProvider( - () => DayColumn, - (_, item) => { - item.height = config.chartHeight - item.width = config.columnWidth - return item - } -) - function getInfoForNeighborColumns(index, cols) { const ret = {} const right = index > 0 ? cols[index - 1] : undefined @@ -39,25 +25,24 @@ function getInfoForNeighborColumns(index, cols) { return ret } -function rowRenderer (_, item, index) { - return ( - - ) -} - export default class CycleChart extends Component { constructor(props) { super(props) - this.columns = makeColumnInfo(config.xAxisRangeInDays) this.state = { - dataProvider: dataProvider.cloneWithRows(this.columns) + columns: makeColumnInfo(config.xAxisRangeInDays), + loading: true + } + this.renderColumn = ({item, index}) => { + if (index === 15 + 1 && this.state.loading) this.setState({loading: false}) + return ( + + ) } - this.rowRenderer = rowRenderer.bind(this) this.reCalculateChartInfo = (function(Chart) { return function() { @@ -74,24 +59,34 @@ export default class CycleChart extends Component { render() { + const {height, width} = Dimensions.get('window') return ( - - { yAxisView } - - + + {this.state.loading && + } + + {yAxisView} + item.dateString} + > + + ) } } function makeColumnInfo(n) { - const xAxisDates = getPreviousDays(n).reverse().map(jsDate => { + const xAxisDates = getPreviousDays(n).map(jsDate => { return LocalDate.of( jsDate.getFullYear(), jsDate.getMonth() + 1, diff --git a/components/chart/config.js b/components/chart/config.js index d18c722..e9d5f95 100644 --- a/components/chart/config.js +++ b/components/chart/config.js @@ -2,10 +2,10 @@ const config = { chartHeight: 350, columnWidth: 30, temperatureScale: { - low: 33, + low: 35, high: 40 }, - xAxisRangeInDays: 40 + xAxisRangeInDays: 50 } const margin = 3 diff --git a/components/chart/day-column.js b/components/chart/day-column.js index 2fda961..a24899a 100644 --- a/components/chart/day-column.js +++ b/components/chart/day-column.js @@ -13,10 +13,17 @@ import { getOrCreateCycleDay } from '../../db' import cycleModule from '../../lib/cycle' import setUpFertilityStatusFunc from './nfp-lines' import { horizontalGrid } from './y-axis' +import slowlog from 'react-native-slowlog' const getCycleDayNumber = cycleModule().getCycleDayNumber +const label = styles.column.label export default class DayColumn extends Component { + constructor(props) { + super(props) + this.getFhmAndLtlInfo = setUpFertilityStatusFunc() + // slowlog(this, /.*/) + } makeDayColumn(data, index) { const { dateString, @@ -27,10 +34,9 @@ export default class DayColumn extends Component { mucus } = data const cycleDayNumber = getCycleDayNumber(dateString) - const label = styles.column.label const dateLabel = dateString.split('-').slice(1).join('-') - const getFhmAndLtlInfo = setUpFertilityStatusFunc() - const nfpLineInfo = getFhmAndLtlInfo(dateString, cycleDay) + // const nfpLineInfo = this.getFhmAndLtlInfo(dateString, temperature) + const nfpLineInfo = {} return ( this.passDateToDayView(dateString)}> @@ -53,7 +59,7 @@ export default class DayColumn extends Component { {dateLabel} - {cycleDay && cycleDay.bleeding ? + {bleeding ?