From 432c56c0c6fa20175cfe913a7d5795857a3d40a1 Mon Sep 17 00:00:00 2001 From: tina Date: Wed, 29 Aug 2018 17:29:33 +0200 Subject: [PATCH] information about bleeding data is shown on home screen --- components/home.js | 40 +- components/labels.js | 9 + package-lock.json | 3090 +++++++++++++++++++++--------------------- 3 files changed, 1588 insertions(+), 1551 deletions(-) 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}