Skip to content
Snippets Groups Projects
Commit 7852123d authored by tina's avatar tina
Browse files

Merge branch '46-replace-picker-in-bleeding' into 'master'

Resolve "replace picker in bleeding"

Closes #46

See merge request bloodyhealth/drip!7
parents bb2b86d2 e53cd03b
No related branches found
No related tags found
No related merge requests found
...@@ -3,9 +3,9 @@ import { ...@@ -3,9 +3,9 @@ import {
View, View,
Button, Button,
Text, Text,
Picker,
Switch Switch
} from 'react-native' } from 'react-native'
import RadioForm from 'react-native-simple-radio-button'
import styles from './styles' import styles from './styles'
import { saveBleeding } from './db' import { saveBleeding } from './db'
import { formatDateForViewHeader } from './format' import { formatDateForViewHeader } from './format'
...@@ -16,9 +16,13 @@ export default class Bleeding extends Component { ...@@ -16,9 +16,13 @@ export default class Bleeding extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
const cycleDay = props.navigation.state.params.cycleDay const cycleDay = props.navigation.state.params.cycleDay
let bleedingValue = cycleDay.bleeding && cycleDay.bleeding.value
if (! (typeof bleedingValue === 'number') ){
bleedingValue = -1
}
this.state = { this.state = {
cycleDay, cycleDay,
currentValue: Number((cycleDay.bleeding && cycleDay.bleeding.value) || 0).toString(), currentValue: bleedingValue,
exclude: cycleDay.bleeding ? cycleDay.bleeding.exclude : false exclude: cycleDay.bleeding ? cycleDay.bleeding.exclude : false
} }
} }
...@@ -27,22 +31,26 @@ export default class Bleeding extends Component { ...@@ -27,22 +31,26 @@ export default class Bleeding extends Component {
render() { render() {
const navigate = this.props.navigation.navigate const navigate = this.props.navigation.navigate
const day = this.state.cycleDay const day = this.state.cycleDay
const bleedingRadioProps = [
{label: labels[0], value: 0 },
{label: labels[1], value: 1 },
{label: labels[2], value: 2 },
{label: labels[3], value: 3 },
]
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Text style={styles.welcome}>{formatDateForViewHeader(day.date)}</Text> <Text style={styles.welcome}>{formatDateForViewHeader(day.date)}</Text>
<Text>Cycle day {getCycleDay()}</Text> <Text>Cycle day {getCycleDay()}</Text>
<Text>Bleeding</Text> <Text>Bleeding</Text>
<Picker <RadioForm
selectedValue={this.state.currentValue} radio_props={bleedingRadioProps}
style={{ height: 50, width: 150 }} initial={this.state.currentValue}
onValueChange={(itemValue) => { formHorizontal={true}
labelHorizontal={false}
onPress={(itemValue) => {
this.setState({ currentValue: itemValue }) this.setState({ currentValue: itemValue })
}}> }}
<Picker.Item label={labels[0]} value="0" /> />
<Picker.Item label={labels[1]} value="1" />
<Picker.Item label={labels[2]} value="2" />
<Picker.Item label={labels[3]} value="3" />
</Picker>
<Text>Exclude</Text> <Text>Exclude</Text>
<Switch <Switch
onValueChange={(val) => { onValueChange={(val) => {
...@@ -65,7 +73,7 @@ export default class Bleeding extends Component { ...@@ -65,7 +73,7 @@ export default class Bleeding extends Component {
<Button <Button
onPress={() => { onPress={() => {
saveBleeding(day, { saveBleeding(day, {
value: Number(this.state.currentValue), value: this.state.currentValue,
exclude: this.state.exclude exclude: this.state.exclude
}) })
navigate('dayView', { cycleDay: day }) navigate('dayView', { cycleDay: day })
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
"moment": "^2.22.1", "moment": "^2.22.1",
"react": "16.3.1", "react": "16.3.1",
"react-native": "0.55.4", "react-native": "0.55.4",
"react-native-simple-radio-button": "^2.7.1",
"react-navigation": "^2.0.4", "react-navigation": "^2.0.4",
"realm": "^2.7.1", "realm": "^2.7.1",
"uuid": "^3.2.1" "uuid": "^3.2.1"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment