import React, { Component } from 'react' import { View, Text, Button, TextInput, Switch } from 'react-native' import styles from './styles' import { saveTemperature, getPreviousTemperature } from './db' import { formatDateForViewHeader } from './format' import getCycleDay from './get-cycle-day' export default class Temp extends Component { constructor(props) { super(props) this.cycleDay = props.navigation.state.params.cycleDay let initialValue if(this.cycleDay.temperature) { initialValue = this.cycleDay.temperature.value.toString() } else { const prevTemp = getPreviousTemperature(this.cycleDay) initialValue = prevTemp ? prevTemp.toString() : '' } this.state = { currentValue: initialValue, exclude: this.cycleDay.temperature ? this.cycleDay.temperature.exclude : false } } render() { const navigate = this.props.navigation.navigate const cycleDay = this.cycleDay return ( {formatDateForViewHeader(cycleDay.date)} Cycle day {getCycleDay()} Temperature { this.setState({currentValue: val}) }} keyboardType='numeric' value = {this.state.currentValue} /> Exclude { this.setState({ exclude: val }) }} value = { this.state.exclude } /> ) } }