diff --git a/components/app.js b/components/app.js index b9838de..3792069 100644 --- a/components/app.js +++ b/components/app.js @@ -33,7 +33,8 @@ class App extends Component { constructor(props) { super(props) this.state = { - currentPage: HOME_PAGE + currentPage: HOME_PAGE, + cycleDay: {}, } this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonPress) setupNotifications(this.navigate) @@ -43,7 +44,7 @@ class App extends Component { this.backHandler.remove() } - navigate = (pageName, props) => { + navigate = (pageName, cycleDay) => { const { currentPage } = this.state // for the back button to work properly, we want to // remember two origins: which menu item we came from @@ -55,7 +56,7 @@ class App extends Component { if (!this.isSymptomView()) { this.originForSymptomView = currentPage } - this.setState({ currentPage: pageName, currentProps: props }) + this.setState({ currentPage: pageName, cycleDay }) } handleBackButtonPress = () => { @@ -65,9 +66,7 @@ class App extends Component { return false } if (this.isSymptomView()) { - this.navigate( - this.originForSymptomView, { date: this.props.date } - ) + this.navigate(this.originForSymptomView) } else if (this.isSettingsView()) { this.navigate(SETTINGS_MENU_PAGE) } else if (currentPage === CYCLE_DAY_PAGE) { @@ -96,7 +95,7 @@ class App extends Component { } render() { - const { currentPage } = this.state + const { currentPage, cycleDay } = this.state const pages = { Home, Calendar, @@ -125,6 +124,7 @@ class App extends Component { diff --git a/components/cycle-day/cycle-day-overview.js b/components/cycle-day/cycle-day-overview.js index 914f212..93ccb9c 100644 --- a/components/cycle-day/cycle-day-overview.js +++ b/components/cycle-day/cycle-day-overview.js @@ -33,7 +33,8 @@ class CycleDayOverView extends Component { } navigate(symptom) { - this.props.navigate(symptom) + const { cycleDay } = this.state + this.props.navigate(symptom, cycleDay) } render() { @@ -77,7 +78,7 @@ class CycleDayOverView extends Component { key={symptom} symptom={symptom} symptomData={symptomData} - onPress={() => this.navigate(symptomEditView)} + onPress={() => this.navigate(symptomEditView, symptomData)} disabled={dateInFuture} />) }) diff --git a/components/home.js b/components/home.js index 351d68e..25c46b8 100644 --- a/components/home.js +++ b/components/home.js @@ -17,6 +17,7 @@ import styles, { cycleDayColor, periodColor, secondaryColor } from '../styles' import AppText from './app-text' import Button from './button' import { formatDateForShortText } from './helpers/format-date' +import { getCycleDay } from '../db' const IconText = ({ children, wrapperStyles }) => { return ( @@ -81,7 +82,10 @@ class Home extends Component { navigateToBleedingEditView = () => { this.setTodayDate() - this.props.navigate('BleedingEditView') + this.props.navigate( + 'BleedingEditView', + getCycleDay(this.todayDateString) + ) } render() {