diff --git a/components/home.js b/components/home.js index 2962492..6f4ab05 100644 --- a/components/home.js +++ b/components/home.js @@ -5,10 +5,11 @@ import { Text, ScrollView } from 'react-native' -import { LocalDate } from 'js-joda' +import { LocalDate, ChronoUnit } from 'js-joda' import styles from '../styles/index' import cycleModule from '../lib/cycle' import { getOrCreateCycleDay, bleedingDaysSortedByDate, fillWithDummyData, deleteAll } from '../db' +import {bleedingPrediction as labels} from './labels' const getCycleDayNumber = cycleModule().getCycleDayNumber @@ -19,23 +20,25 @@ export default class Home extends Component { const cycleDayNumber = getCycleDayNumber(this.todayDateString) this.state = { - welcomeText: determineWelcomeText(cycleDayNumber) + welcomeText: determineWelcomeText(cycleDayNumber), + predictionText: determinePredictionText() } - this.setStateWithCurrentWelcomeText = (function (HomeComponent) { + this.setStateWithCurrentText = (function (HomeComponent) { return function () { const cycleDayNumber = getCycleDayNumber(HomeComponent.todayDateString) HomeComponent.setState({ - welcomeText: determineWelcomeText(cycleDayNumber) + welcomeText: determineWelcomeText(cycleDayNumber), + predictionText: determinePredictionText() }) } })(this) - bleedingDaysSortedByDate.addListener(this.setStateWithCurrentWelcomeText) + bleedingDaysSortedByDate.addListener(this.setStateWithCurrentText) } componentWillUnmount() { - bleedingDaysSortedByDate.removeListener(this.setStateWithCurrentWelcomeText) + bleedingDaysSortedByDate.removeListener(this.setStateWithCurrentText) } passTodayToDayView() { @@ -49,6 +52,7 @@ export default class Home extends Component { return ( {this.state.welcomeText} + {this.state.predictionText}