Remove cycleDay from state
This commit is contained in:
+6
-7
@@ -15,22 +15,21 @@ import getCycleDay from './get-cycle-day'
|
|||||||
export default class Bleeding extends Component {
|
export default class Bleeding extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
const cycleDay = props.navigation.state.params.cycleDay
|
this.cycleDay = props.navigation.state.params.cycleDay
|
||||||
let bleedingValue = cycleDay.bleeding && cycleDay.bleeding.value
|
let bleedingValue = this.cycleDay.bleeding && this.cycleDay.bleeding.value
|
||||||
if (! (typeof bleedingValue === 'number') ){
|
if (! (typeof bleedingValue === 'number') ){
|
||||||
bleedingValue = -1
|
bleedingValue = -1
|
||||||
}
|
}
|
||||||
this.state = {
|
this.state = {
|
||||||
cycleDay,
|
|
||||||
currentValue: bleedingValue,
|
currentValue: bleedingValue,
|
||||||
exclude: cycleDay.bleeding ? cycleDay.bleeding.exclude : false
|
exclude: this.cycleDay.bleeding ? this.cycleDay.bleeding.exclude : false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO display cycle day
|
// TODO display cycle day
|
||||||
render() {
|
render() {
|
||||||
const navigate = this.props.navigation.navigate
|
const navigate = this.props.navigation.navigate
|
||||||
const day = this.state.cycleDay
|
const day = this.cycleDay
|
||||||
const bleedingRadioProps = [
|
const bleedingRadioProps = [
|
||||||
{label: labels[0], value: 0 },
|
{label: labels[0], value: 0 },
|
||||||
{label: labels[1], value: 1 },
|
{label: labels[1], value: 1 },
|
||||||
@@ -48,13 +47,13 @@ export default class Bleeding extends Component {
|
|||||||
formHorizontal={true}
|
formHorizontal={true}
|
||||||
labelHorizontal={false}
|
labelHorizontal={false}
|
||||||
onPress={(itemValue) => {
|
onPress={(itemValue) => {
|
||||||
this.setState({ currentValue: itemValue })
|
this.setState({currentValue: itemValue})
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Text>Exclude</Text>
|
<Text>Exclude</Text>
|
||||||
<Switch
|
<Switch
|
||||||
onValueChange={(val) => {
|
onValueChange={(val) => {
|
||||||
this.setState({ exclude: val })
|
this.setState({exclude: val})
|
||||||
}}
|
}}
|
||||||
value={this.state.exclude} />
|
value={this.state.exclude} />
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
+6
-7
@@ -15,26 +15,25 @@ import getCycleDay from './get-cycle-day'
|
|||||||
export default class Temp extends Component {
|
export default class Temp extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
const cycleDay = props.navigation.state.params.cycleDay
|
this.cycleDay = props.navigation.state.params.cycleDay
|
||||||
let initialValue
|
let initialValue
|
||||||
|
|
||||||
if(cycleDay.temperature) {
|
if(this.cycleDay.temperature) {
|
||||||
initialValue = cycleDay.temperature.value.toString()
|
initialValue = this.cycleDay.temperature.value.toString()
|
||||||
} else {
|
} else {
|
||||||
const prevTemp = getPreviousTemperature(cycleDay)
|
const prevTemp = getPreviousTemperature(this.cycleDay)
|
||||||
initialValue = prevTemp ? prevTemp.toString() : ''
|
initialValue = prevTemp ? prevTemp.toString() : ''
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
cycleDay,
|
|
||||||
currentValue: initialValue,
|
currentValue: initialValue,
|
||||||
exclude: cycleDay.temperature ? cycleDay.temperature.exclude : false
|
exclude: this.cycleDay.temperature ? this.cycleDay.temperature.exclude : false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const navigate = this.props.navigation.navigate
|
const navigate = this.props.navigation.navigate
|
||||||
const cycleDay = this.state.cycleDay
|
const cycleDay = this.cycleDay
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Text style={styles.welcome}>{formatDateForViewHeader(cycleDay.date)}</Text>
|
<Text style={styles.welcome}>{formatDateForViewHeader(cycleDay.date)}</Text>
|
||||||
|
|||||||
Reference in New Issue
Block a user