Change getCycleDay signature and process LocalDate

This commit is contained in:
Julia Friesel
2018-06-09 12:00:06 +02:00
parent 1430734874
commit 5b406848cb
10 changed files with 129 additions and 223 deletions
+19 -3
View File
@@ -5,18 +5,30 @@ import {
Text
} from 'react-native'
import styles from './styles'
import getCycleDay from './get-cycle-day'
import cycleDayModule from './get-cycle-day-number'
import { getCycleDaysSortedByDateView, deleteAll } from './db'
import { LocalDate } from 'js-joda'
const cycleDaysSortedByDateView = getCycleDaysSortedByDateView()
const getCycleDayNumber = cycleDayModule(cycleDaysSortedByDateView)
const now = new Date()
const cycleDayNumber = getCycleDayNumber(LocalDate.of(now.getFullYear(), now.getMonth() + 1, now.getDate()))
const welcomeTextWithCycleDay = `Welcome! Today is day ${cycleDayNumber} of your current cycle`
const welcomeText = `Welcome! We don't have enough information to know what your current cycle day is`
export default class Home extends Component {
constructor(props) {
super(props)
this.state = {
welcomeText: cycleDayNumber ? welcomeTextWithCycleDay : welcomeText
}
}
render() {
const navigate = this.props.navigation.navigate
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome! Today is day {getCycleDay()} of your current cycle</Text>
<Text style={styles.welcome}>{this.state.welcomeText}</Text>
<Button
onPress={() => navigate('temperatureList')}
title="Edit symptoms for today">
@@ -25,7 +37,11 @@ export default class Home extends Component {
onPress={() => navigate('calendar')}
title="Go to calendar">
</Button>
<Button
onPress={() => deleteAll()}
title="delete everything">
</Button>
</View>
)
}
}
}