Display persisted bleeding value in edit view

This commit is contained in:
Julia Friesel
2018-06-05 18:18:57 +02:00
parent 8ee53ba75f
commit c4f68e6065
2 changed files with 17 additions and 3 deletions
+16 -2
View File
@@ -13,9 +13,10 @@ import { bleeding as labels } from './labels'
export default class Bleeding extends Component {
constructor(props) {
super(props)
const cycleDay = props.navigation.state.params.cycleDay
this.state = {
cycleDay: props.navigation.state.params.cycleDay,
currentValue: "1"
cycleDay,
currentValue: Number((cycleDay.bleeding && cycleDay.bleeding.value) || 0).toString()
}
}
@@ -38,6 +39,19 @@ export default class Bleeding extends Component {
<Picker.Item label={labels[2]} value="2" />
<Picker.Item label={labels[3]} value="3" />
</Picker>
<Button
onPress={() => {
navigate('dayView', { cycleDay: day })
}}
title="Cancel">
</Button>
<Button
onPress={() => {
saveBleeding(day)
navigate('dayView', { cycleDay: day })
}}
title="Delete entry">
</Button>
<Button
onPress={() => {
saveBleeding(day, {
+1 -1
View File
@@ -23,7 +23,7 @@ export default class DayView extends Component {
return (
<View style={styles.container}>
<Text style={styles.welcome}>{formatDateForViewHeader(day.date)}</Text>
<Text style={styles.welcome}>{bleedingValue != undefined ? labels[bleedingValue] : ''}</Text>
<Text style={styles.welcome}>{typeof bleedingValue === 'number' ? labels[bleedingValue] : ''}</Text>
<Button
onPress={() => navigate('bleeding', { cycleDay: day })}
title="Edit bleeding">