Substitute navigate&setDate props with naviation&route props

This commit is contained in:
MariaZ
2022-09-28 19:59:17 +02:00
parent b6024ae921
commit e2d6387647
5 changed files with 38 additions and 35 deletions
+11 -9
View File
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useEffect } from 'react'
import { ScrollView, StyleSheet, View } from 'react-native'
import PropTypes from 'prop-types'
import moment from 'moment'
@@ -10,6 +10,7 @@ import Footnote from './common/Footnote'
import cycleModule from '../lib/cycle'
import { getFertilityStatusForDay } from '../lib/sympto-adapter'
import setupNotifications from '../lib/notifications'
import {
determinePredictionText,
formatWithOrdinalSuffix,
@@ -19,13 +20,10 @@ import { Colors, Fonts, Sizes, Spacing } from '../styles'
import { LocalDate } from '@js-joda/core'
import { useTranslation } from 'react-i18next'
const Home = ({ navigate, setDate }) => {
const Home = ({ navigation }) => {
const { t } = useTranslation()
function navigateToCycleDayView() {
setDate(todayDateString)
navigate('CycleDay')
}
useEffect(() => setupNotifications(navigation), [])
const todayDateString = LocalDate.now().toString()
const { getCycleDayNumber, getPredictedMenses } = cycleModule()
@@ -33,11 +31,14 @@ const Home = ({ navigate, setDate }) => {
const { status, phase, statusText } =
getFertilityStatusForDay(todayDateString)
const prediction = determinePredictionText(getPredictedMenses(), t)
const cycleDayText = cycleDayNumber
? formatWithOrdinalSuffix(cycleDayNumber)
: ''
function navigateToCycleDayView() {
navigation.navigate('CycleDayOverview', { date: todayDateString })
}
return (
<ScrollView
style={styles.container}
@@ -109,8 +110,9 @@ const styles = StyleSheet.create({
})
Home.propTypes = {
navigate: PropTypes.func,
setDate: PropTypes.func,
navigation: PropTypes.shape({
navigate: PropTypes.func.isRequired,
}).isRequired,
}
export default Home