Merge branch 'master' into 73-implement-nfp-logic-for-mucus-mode
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { Text as ReactNativeText, View, FlatList } from 'react-native'
|
import { Text as ReactNativeText, View, FlatList, ScrollView } from 'react-native'
|
||||||
import range from 'date-range'
|
import range from 'date-range'
|
||||||
import Svg,{
|
import Svg,{
|
||||||
G,
|
G,
|
||||||
@@ -109,6 +109,13 @@ export default class CycleChart extends Component {
|
|||||||
this.drawDotAndLines(y, cycleDay.temperature.exclude, index)
|
this.drawDotAndLines(y, cycleDay.temperature.exclude, index)
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
{cycleDay && cycleDay.mucus ?
|
||||||
|
<Circle
|
||||||
|
{...styles.mucusIcon}
|
||||||
|
fill={styles.mucusIconShades[cycleDay.mucus.value]}
|
||||||
|
/> : null}
|
||||||
|
|
||||||
|
{y ? this.drawDotAndLines(y, cycleDay.temperature.exclude, index) : null}
|
||||||
</G>
|
</G>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -160,7 +167,7 @@ export default class CycleChart extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={{flex: 1, flexDirection: 'row'}}>
|
<ScrollView contentContainerStyle={{flexDirection: 'row'}}>
|
||||||
<View {...styles.yAxis}>{yAxis.labels}</View>
|
<View {...styles.yAxis}>{yAxis.labels}</View>
|
||||||
<FlatList
|
<FlatList
|
||||||
horizontal={true}
|
horizontal={true}
|
||||||
@@ -177,7 +184,7 @@ export default class CycleChart extends Component {
|
|||||||
keyExtractor={item => item.dateString}
|
keyExtractor={item => item.dateString}
|
||||||
>
|
>
|
||||||
</FlatList>
|
</FlatList>
|
||||||
</View>
|
</ScrollView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,9 +45,21 @@ const styles = {
|
|||||||
bleedingIcon: {
|
bleedingIcon: {
|
||||||
fill: '#fb2e01',
|
fill: '#fb2e01',
|
||||||
scale: 0.6,
|
scale: 0.6,
|
||||||
x: 7,
|
x: 6,
|
||||||
y: 3
|
y: 3
|
||||||
},
|
},
|
||||||
|
mucusIcon: {
|
||||||
|
cx: config.columnWidth / 2,
|
||||||
|
cy: 50,
|
||||||
|
r: 10
|
||||||
|
},
|
||||||
|
mucusIconShades: [
|
||||||
|
'#cc99cc',
|
||||||
|
'#bf7fbf',
|
||||||
|
'#b266b2',
|
||||||
|
'#a64ca6',
|
||||||
|
'#993299'
|
||||||
|
],
|
||||||
yAxis: {
|
yAxis: {
|
||||||
height: config.chartHeight,
|
height: config.chartHeight,
|
||||||
width: config.columnWidth,
|
width: config.columnWidth,
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import {
|
|||||||
mucusFeeling as feelingLabels,
|
mucusFeeling as feelingLabels,
|
||||||
mucusTexture as textureLabels,
|
mucusTexture as textureLabels,
|
||||||
mucusNFP as computeSensiplanMucusLabels,
|
mucusNFP as computeSensiplanMucusLabels,
|
||||||
|
cervixOpening as openingLabels,
|
||||||
|
cervixFirmness as firmnessLabels,
|
||||||
|
cervixPosition as positionLabels
|
||||||
} from './labels/labels'
|
} from './labels/labels'
|
||||||
import cycleDayModule from '../../lib/cycle'
|
import cycleDayModule from '../../lib/cycle'
|
||||||
import { bleedingDaysSortedByDate } from '../../db'
|
import { bleedingDaysSortedByDate } from '../../db'
|
||||||
@@ -41,36 +44,53 @@ export default class DayView extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const bleedingValue = this.cycleDay.bleeding && this.cycleDay.bleeding.value
|
|
||||||
let bleedingLabel
|
let bleedingLabel
|
||||||
if (typeof bleedingValue === 'number') {
|
if (this.cycleDay.bleeding) {
|
||||||
bleedingLabel = `${bleedingLabels[bleedingValue]}`
|
const bleeding = this.cycleDay.bleeding
|
||||||
if (this.cycleDay.bleeding.exclude) bleedingLabel = "( " + bleedingLabel + " )"
|
if (typeof bleeding === 'number') {
|
||||||
|
bleedingLabel = `${bleedingLabels[bleeding]}`
|
||||||
|
if (bleeding.exclude) bleedingLabel = "( " + bleedingLabel + " )"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
bleedingLabel = 'edit'
|
bleedingLabel = 'edit'
|
||||||
}
|
}
|
||||||
const temperatureValue = this.cycleDay.temperature && this.cycleDay.temperature.value
|
|
||||||
let temperatureLabel
|
let temperatureLabel
|
||||||
if (typeof temperatureValue === 'number') {
|
if (this.cycleDay.temperature) {
|
||||||
temperatureLabel = `${temperatureValue} °C - ${this.cycleDay.temperature.time}`
|
const temperature = this.cycleDay.temperature
|
||||||
if (this.cycleDay.temperature.exclude) {
|
if (typeof temperature === 'number') {
|
||||||
|
temperatureLabel = `${temperature} °C - ${temperature.time}`
|
||||||
|
if (temperature.exclude) {
|
||||||
temperatureLabel = "( " + temperatureLabel + " )"
|
temperatureLabel = "( " + temperatureLabel + " )"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
temperatureLabel = 'edit'
|
temperatureLabel = 'edit'
|
||||||
}
|
}
|
||||||
|
|
||||||
const mucusFeelingValue = this.cycleDay.mucus && this.cycleDay.mucus.feeling
|
|
||||||
const mucusTextureValue = this.cycleDay.mucus && this.cycleDay.mucus.texture
|
|
||||||
const mucusComputedValue = this.cycleDay.mucus && this.cycleDay.mucus.value
|
|
||||||
let mucusLabel
|
let mucusLabel
|
||||||
if (typeof mucusFeelingValue === 'number' && typeof mucusTextureValue === 'number') {
|
if (this.cycleDay.mucus) {
|
||||||
mucusLabel = `${feelingLabels[mucusFeelingValue]} + ${textureLabels[mucusTextureValue]} ( ${computeSensiplanMucusLabels[mucusComputedValue]} )`
|
const mucus = this.cycleDay.mucus
|
||||||
if (this.cycleDay.mucus.exclude) mucusLabel = "( " + mucusLabel + " )"
|
if (typeof mucus.feeling === 'number' && typeof mucus.texture === 'number') {
|
||||||
|
mucusLabel = `${feelingLabels[mucus.feeling]} + ${textureLabels[mucus.texture]} ( ${computeSensiplanMucusLabels[mucus.computedNfp]} )`
|
||||||
|
if (mucus.exclude) mucusLabel = "( " + mucusLabel + " )"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mucusLabel = 'edit'
|
mucusLabel = 'edit'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let cervixLabel
|
||||||
|
if (this.cycleDay.cervix) {
|
||||||
|
const cervix = this.cycleDay.cervix
|
||||||
|
if (cervix.opening > -1 && cervix.firmness > -1) {
|
||||||
|
cervixLabel = `${openingLabels[cervix.opening]} + ${firmnessLabels[cervix.firmness]}`
|
||||||
|
if (cervix.position > -1) cervixLabel += `+ ${positionLabels[cervix.position]}`
|
||||||
|
if (cervix.exclude) cervixLabel = "( " + cervixLabel + " )"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cervixLabel = 'edit'
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.symptomEditView}>
|
<View style={styles.symptomEditView}>
|
||||||
<View style={styles.symptomViewRowInline}>
|
<View style={styles.symptomViewRowInline}>
|
||||||
@@ -100,6 +120,15 @@ export default class DayView extends Component {
|
|||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>Cervix</Text>
|
||||||
|
<View style={ styles.symptomEditButton }>
|
||||||
|
<Button
|
||||||
|
onPress={() => this.showView('cervixEditView')}
|
||||||
|
title={cervixLabel}>
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
</View >
|
</View >
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import {
|
import {
|
||||||
View,
|
View,
|
||||||
Text
|
Text,
|
||||||
|
ScrollView
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import cycleModule from '../../lib/cycle'
|
import cycleModule from '../../lib/cycle'
|
||||||
import { getFertilityStatusStringForDay } from '../../lib/sympto-adapter'
|
import { getFertilityStatusStringForDay } from '../../lib/sympto-adapter'
|
||||||
@@ -10,6 +11,7 @@ import BleedingEditView from './symptoms/bleeding'
|
|||||||
import TemperatureEditView from './symptoms/temperature'
|
import TemperatureEditView from './symptoms/temperature'
|
||||||
import MucusEditView from './symptoms/mucus'
|
import MucusEditView from './symptoms/mucus'
|
||||||
import { formatDateForViewHeader } from './labels/format'
|
import { formatDateForViewHeader } from './labels/format'
|
||||||
|
import CervixEditView from './symptoms/cervix'
|
||||||
import styles from '../../styles'
|
import styles from '../../styles'
|
||||||
import actionButtonModule from './action-buttons'
|
import actionButtonModule from './action-buttons'
|
||||||
|
|
||||||
@@ -35,7 +37,7 @@ export default class Day extends Component {
|
|||||||
const cycleDayNumber = getCycleDayNumber(this.cycleDay.date)
|
const cycleDayNumber = getCycleDayNumber(this.cycleDay.date)
|
||||||
const fertilityStatus = getFertilityStatusStringForDay(this.cycleDay.date)
|
const fertilityStatus = getFertilityStatusStringForDay(this.cycleDay.date)
|
||||||
return (
|
return (
|
||||||
<View>
|
<ScrollView>
|
||||||
<View style={ styles.cycleDayDateView }>
|
<View style={ styles.cycleDayDateView }>
|
||||||
<Text style={styles.dateHeader}>
|
<Text style={styles.dateHeader}>
|
||||||
{formatDateForViewHeader(this.cycleDay.date)}
|
{formatDateForViewHeader(this.cycleDay.date)}
|
||||||
@@ -56,11 +58,12 @@ export default class Day extends Component {
|
|||||||
{ dayView: <DayView cycleDay={this.cycleDay} showView={this.showView} />,
|
{ dayView: <DayView cycleDay={this.cycleDay} showView={this.showView} />,
|
||||||
bleedingEditView: <BleedingEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>,
|
bleedingEditView: <BleedingEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>,
|
||||||
temperatureEditView: <TemperatureEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>,
|
temperatureEditView: <TemperatureEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>,
|
||||||
mucusEditView: <MucusEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>
|
mucusEditView: <MucusEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons}/>,
|
||||||
|
cervixEditView: <CervixEditView cycleDay={this.cycleDay} makeActionButtons={this.makeActionButtons} />
|
||||||
}[this.state.visibleComponent]
|
}[this.state.visibleComponent]
|
||||||
}
|
}
|
||||||
</View >
|
</View >
|
||||||
</View >
|
</ScrollView >
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,16 @@ const bleeding = ['spotting', 'light', 'medium', 'heavy']
|
|||||||
const mucusFeeling = ['dry', 'nothing', 'wet', 'slippery']
|
const mucusFeeling = ['dry', 'nothing', 'wet', 'slippery']
|
||||||
const mucusTexture = ['nothing', 'creamy', 'egg white']
|
const mucusTexture = ['nothing', 'creamy', 'egg white']
|
||||||
const mucusNFP = ['t', 'Ø', 'f', 'S', '+S']
|
const mucusNFP = ['t', 'Ø', 'f', 'S', '+S']
|
||||||
|
const cervixOpening = ['closed', 'medium', 'open']
|
||||||
|
const cervixFirmness = ['hard', 'soft']
|
||||||
|
const cervixPosition = ['low', 'medium', 'high']
|
||||||
|
|
||||||
export {
|
export {
|
||||||
bleeding,
|
bleeding,
|
||||||
mucusFeeling,
|
mucusFeeling,
|
||||||
mucusTexture,
|
mucusTexture,
|
||||||
mucusNFP
|
mucusNFP,
|
||||||
|
cervixOpening,
|
||||||
|
cervixFirmness,
|
||||||
|
cervixPosition
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
import React, { Component } from 'react'
|
||||||
|
import {
|
||||||
|
View,
|
||||||
|
Text,
|
||||||
|
Switch
|
||||||
|
} from 'react-native'
|
||||||
|
import RadioForm from 'react-native-simple-radio-button'
|
||||||
|
import styles from '../../../styles'
|
||||||
|
import { saveSymptom } from '../../../db'
|
||||||
|
import {
|
||||||
|
cervixOpening as openingLabels,
|
||||||
|
cervixFirmness as firmnessLabels,
|
||||||
|
cervixPosition as positionLabels
|
||||||
|
} from '../labels/labels'
|
||||||
|
|
||||||
|
export default class Cervix extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
this.cycleDay = props.cycleDay
|
||||||
|
this.makeActionButtons = props.makeActionButtons
|
||||||
|
this.state = {
|
||||||
|
exclude: this.cycleDay.cervix ? this.cycleDay.cervix.exclude : false
|
||||||
|
};
|
||||||
|
|
||||||
|
/* eslint-disable react/no-direct-mutation-state */
|
||||||
|
['opening', 'firmness', 'position'].forEach(label => {
|
||||||
|
this.state[label] = this.cycleDay.cervix && this.cycleDay.cervix[label]
|
||||||
|
if (typeof this.state[label] !== 'number') {
|
||||||
|
this.state[label] = -1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
/* eslint-enable react/no-direct-mutation-state */
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const cervixOpeningRadioProps = [
|
||||||
|
{label: openingLabels[0], value: 0},
|
||||||
|
{label: openingLabels[1], value: 1},
|
||||||
|
{label: openingLabels[2], value: 2}
|
||||||
|
]
|
||||||
|
const cervixFirmnessRadioProps = [
|
||||||
|
{label: firmnessLabels[0], value: 0 },
|
||||||
|
{label: firmnessLabels[1], value: 1 }
|
||||||
|
]
|
||||||
|
const cervixPositionRadioProps = [
|
||||||
|
{label: positionLabels[0], value: 0 },
|
||||||
|
{label: positionLabels[1], value: 1 },
|
||||||
|
{label: positionLabels[2], value: 2 }
|
||||||
|
]
|
||||||
|
return(
|
||||||
|
<View style={ styles.symptomEditView }>
|
||||||
|
<Text style={styles.symptomDayView}>Cervix</Text>
|
||||||
|
<Text style={styles.symptomDayView}>Opening</Text>
|
||||||
|
<View style={styles.radioButtonRow}>
|
||||||
|
<RadioForm
|
||||||
|
radio_props={cervixOpeningRadioProps}
|
||||||
|
initial={this.state.opening}
|
||||||
|
formHorizontal={true}
|
||||||
|
labelHorizontal={false}
|
||||||
|
labelStyle={styles.radioButton}
|
||||||
|
onPress={(itemValue) => {
|
||||||
|
this.setState({opening: itemValue})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<Text style={styles.symptomDayView}>Firmness</Text>
|
||||||
|
<View style={styles.radioButtonRow}>
|
||||||
|
<RadioForm
|
||||||
|
radio_props={cervixFirmnessRadioProps}
|
||||||
|
initial={this.state.firmness}
|
||||||
|
formHorizontal={true}
|
||||||
|
labelHorizontal={false}
|
||||||
|
labelStyle={styles.radioButton}
|
||||||
|
onPress={(itemValue) => {
|
||||||
|
this.setState({firmness: itemValue})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<Text style={styles.symptomDayView}>Position</Text>
|
||||||
|
<View style={styles.radioButtonRow}>
|
||||||
|
<RadioForm
|
||||||
|
radio_props={cervixPositionRadioProps}
|
||||||
|
initial={this.state.position}
|
||||||
|
formHorizontal={true}
|
||||||
|
labelHorizontal={false}
|
||||||
|
labelStyle={styles.radioButton}
|
||||||
|
onPress={(itemValue) => {
|
||||||
|
this.setState({position: itemValue})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>Exclude</Text>
|
||||||
|
<Switch
|
||||||
|
onValueChange={(val) => {
|
||||||
|
this.setState({ exclude: val })
|
||||||
|
}}
|
||||||
|
value={this.state.exclude}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.actionButtonRow}>
|
||||||
|
{this.makeActionButtons(
|
||||||
|
{
|
||||||
|
symptom: 'cervix',
|
||||||
|
cycleDay: this.cycleDay,
|
||||||
|
saveAction: () => {
|
||||||
|
saveSymptom('cervix', this.cycleDay, {
|
||||||
|
opening: this.state.opening,
|
||||||
|
firmness: this.state.firmness,
|
||||||
|
position: this.state.position,
|
||||||
|
exclude: this.state.exclude
|
||||||
|
})
|
||||||
|
},
|
||||||
|
saveDisabled: this.state.opening === -1 || this.state.firmness === -1
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,17 +21,17 @@ export default class Mucus extends Component {
|
|||||||
this.makeActionButtons = props.makeActionButtons
|
this.makeActionButtons = props.makeActionButtons
|
||||||
this.state = {
|
this.state = {
|
||||||
exclude: this.cycleDay.mucus ? this.cycleDay.mucus.exclude : false
|
exclude: this.cycleDay.mucus ? this.cycleDay.mucus.exclude : false
|
||||||
}
|
};
|
||||||
|
|
||||||
this.state.currentFeelingValue = this.cycleDay.mucus && this.cycleDay.mucus.feeling
|
/* eslint-disable react/no-direct-mutation-state */
|
||||||
if (typeof this.state.currentFeelingValue !== 'number') {
|
['feeling', 'texture'].forEach(label => {
|
||||||
this.state.currentFeelingValue = -1
|
this.state[label] = this.cycleDay.mucus && this.cycleDay.mucus[label]
|
||||||
|
if (typeof this.state[label] !== 'number') {
|
||||||
|
this.state[label] = -1
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
/* eslint-enable react/no-direct-mutation-state */
|
||||||
|
|
||||||
this.state.currentTextureValue = this.cycleDay.mucus && this.cycleDay.mucus.texture
|
|
||||||
if (typeof this.state.currentTextureValue !== 'number') {
|
|
||||||
this.state.currentTextureValue = -1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -53,12 +53,12 @@ export default class Mucus extends Component {
|
|||||||
<View style={styles.radioButtonRow}>
|
<View style={styles.radioButtonRow}>
|
||||||
<RadioForm
|
<RadioForm
|
||||||
radio_props={mucusFeelingRadioProps}
|
radio_props={mucusFeelingRadioProps}
|
||||||
initial={this.state.currentFeelingValue}
|
initial={this.state.feeling}
|
||||||
formHorizontal={true}
|
formHorizontal={true}
|
||||||
labelHorizontal={false}
|
labelHorizontal={false}
|
||||||
labelStyle={styles.radioButton}
|
labelStyle={styles.radioButton}
|
||||||
onPress={(itemValue) => {
|
onPress={(itemValue) => {
|
||||||
this.setState({ currentFeelingValue: itemValue })
|
this.setState({feeling: itemValue })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
@@ -66,12 +66,12 @@ export default class Mucus extends Component {
|
|||||||
<View style={styles.radioButtonRow}>
|
<View style={styles.radioButtonRow}>
|
||||||
<RadioForm
|
<RadioForm
|
||||||
radio_props={mucusTextureRadioProps}
|
radio_props={mucusTextureRadioProps}
|
||||||
initial={this.state.currentTextureValue}
|
initial={this.state.texture}
|
||||||
formHorizontal={true}
|
formHorizontal={true}
|
||||||
labelHorizontal={false}
|
labelHorizontal={false}
|
||||||
labelStyle={styles.radioButton}
|
labelStyle={styles.radioButton}
|
||||||
onPress={(itemValue) => {
|
onPress={(itemValue) => {
|
||||||
this.setState({ currentTextureValue: itemValue })
|
this.setState({texture: itemValue })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
@@ -92,13 +92,13 @@ export default class Mucus extends Component {
|
|||||||
cycleDay: this.cycleDay,
|
cycleDay: this.cycleDay,
|
||||||
saveAction: () => {
|
saveAction: () => {
|
||||||
saveSymptom('mucus', this.cycleDay, {
|
saveSymptom('mucus', this.cycleDay, {
|
||||||
feeling: this.state.currentFeelingValue,
|
feeling: this.state.feeling,
|
||||||
texture: this.state.currentTextureValue,
|
texture: this.state.texture,
|
||||||
value: computeSensiplanValue(this.state.currentFeelingValue, this.state.currentTextureValue),
|
value: computeSensiplanValue(this.state.feeling, this.state.texture),
|
||||||
exclude: this.state.exclude
|
exclude: this.state.exclude
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
saveDisabled: this.state.currentFeelingValue === -1 || this.state.currentTextureValue === -1
|
saveDisabled: this.state.feeling === -1 || this.state.texture === -1
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ import {
|
|||||||
View,
|
View,
|
||||||
Text,
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
Switch
|
Switch,
|
||||||
|
Keyboard
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
|
import DateTimePicker from 'react-native-modal-datetime-picker-nevo'
|
||||||
|
|
||||||
import { getPreviousTemperature, saveSymptom } from '../../../db'
|
import { getPreviousTemperature, saveSymptom } from '../../../db'
|
||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
@@ -17,9 +19,11 @@ export default class Temp extends Component {
|
|||||||
this.makeActionButtons = props.makeActionButtons
|
this.makeActionButtons = props.makeActionButtons
|
||||||
let initialValue
|
let initialValue
|
||||||
|
|
||||||
if (this.cycleDay.temperature) {
|
const temp = this.cycleDay.temperature
|
||||||
initialValue = this.cycleDay.temperature.value.toString()
|
|
||||||
this.time = this.cycleDay.temperature.time
|
if (temp) {
|
||||||
|
initialValue = temp.value.toString()
|
||||||
|
this.time = temp.time
|
||||||
} else {
|
} else {
|
||||||
const prevTemp = getPreviousTemperature(this.cycleDay)
|
const prevTemp = getPreviousTemperature(this.cycleDay)
|
||||||
initialValue = prevTemp ? prevTemp.toString() : ''
|
initialValue = prevTemp ? prevTemp.toString() : ''
|
||||||
@@ -27,7 +31,9 @@ export default class Temp extends Component {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
currentValue: initialValue,
|
currentValue: initialValue,
|
||||||
exclude: this.cycleDay.temperature ? this.cycleDay.temperature.exclude : false
|
exclude: temp ? temp.exclude : false,
|
||||||
|
time: this.time || LocalTime.now().truncatedTo(ChronoUnit.MINUTES).toString(),
|
||||||
|
isTimePickerVisible: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,6 +53,28 @@ export default class Temp extends Component {
|
|||||||
value={this.state.currentValue}
|
value={this.state.currentValue}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
<View style={styles.symptomViewRowInline}>
|
||||||
|
<Text style={styles.symptomDayView}>Time</Text>
|
||||||
|
<TextInput
|
||||||
|
style={styles.temperatureTextInput}
|
||||||
|
onFocus={() => {
|
||||||
|
Keyboard.dismiss()
|
||||||
|
this.setState({isTimePickerVisible: true})
|
||||||
|
}}
|
||||||
|
value={this.state.time}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<DateTimePicker
|
||||||
|
mode="time"
|
||||||
|
isVisible={this.state.isTimePickerVisible}
|
||||||
|
onConfirm={jsDate => {
|
||||||
|
this.setState({
|
||||||
|
time: `${jsDate.getHours()}:${jsDate.getMinutes()}`,
|
||||||
|
isTimePickerVisible: false
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
onCancel={() => this.setState({isTimePickerVisible: false})}
|
||||||
|
/>
|
||||||
<View style={styles.symptomViewRowInline}>
|
<View style={styles.symptomViewRowInline}>
|
||||||
<Text style={styles.symptomDayView}>Exclude</Text>
|
<Text style={styles.symptomDayView}>Exclude</Text>
|
||||||
<Switch
|
<Switch
|
||||||
@@ -63,18 +91,24 @@ export default class Temp extends Component {
|
|||||||
saveAction: () => {
|
saveAction: () => {
|
||||||
const dataToSave = {
|
const dataToSave = {
|
||||||
value: Number(this.state.currentValue),
|
value: Number(this.state.currentValue),
|
||||||
exclude: this.state.exclude
|
exclude: this.state.exclude,
|
||||||
}
|
time: this.state.time
|
||||||
if (!cycleDay.temperature || cycleDay.temperature && !cycleDay.temperature.time) {
|
|
||||||
const now = LocalTime.now().truncatedTo(ChronoUnit.MINUTES).toString()
|
|
||||||
dataToSave.time = now
|
|
||||||
}
|
}
|
||||||
saveSymptom('temperature', cycleDay, dataToSave)
|
saveSymptom('temperature', cycleDay, dataToSave)
|
||||||
},
|
},
|
||||||
saveDisabled: this.state.currentValue === ''
|
saveDisabled: this.state.currentValue === '' || isInvalidTime(this.state.time)
|
||||||
})}
|
})}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isInvalidTime(timeString) {
|
||||||
|
try {
|
||||||
|
LocalTime.parse(timeString)
|
||||||
|
} catch (err) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
+4
-3
@@ -2,7 +2,8 @@ import React, { Component } from 'react'
|
|||||||
import {
|
import {
|
||||||
View,
|
View,
|
||||||
Button,
|
Button,
|
||||||
Text
|
Text,
|
||||||
|
ScrollView
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import { LocalDate } from 'js-joda'
|
import { LocalDate } from 'js-joda'
|
||||||
import styles from '../styles/index'
|
import styles from '../styles/index'
|
||||||
@@ -46,7 +47,7 @@ export default class Home extends Component {
|
|||||||
render() {
|
render() {
|
||||||
const navigate = this.props.navigation.navigate
|
const navigate = this.props.navigation.navigate
|
||||||
return (
|
return (
|
||||||
<View>
|
<ScrollView>
|
||||||
<Text style={styles.welcome}>{this.state.welcomeText}</Text>
|
<Text style={styles.welcome}>{this.state.welcomeText}</Text>
|
||||||
<View style={styles.homeButtons}>
|
<View style={styles.homeButtons}>
|
||||||
<View style={styles.homeButton}>
|
<View style={styles.homeButton}>
|
||||||
@@ -80,7 +81,7 @@ export default class Home extends Component {
|
|||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</ScrollView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-2
@@ -10,7 +10,11 @@ const TemperatureSchema = {
|
|||||||
name: 'Temperature',
|
name: 'Temperature',
|
||||||
properties: {
|
properties: {
|
||||||
value: 'double',
|
value: 'double',
|
||||||
exclude: 'bool'
|
exclude: 'bool',
|
||||||
|
time: {
|
||||||
|
type: 'string',
|
||||||
|
optional: true
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +36,16 @@ const MucusSchema = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CervixSchema = {
|
||||||
|
name: 'Cervix',
|
||||||
|
properties: {
|
||||||
|
opening: 'int',
|
||||||
|
firmness: 'int',
|
||||||
|
position: {type: 'int', optional: true },
|
||||||
|
exclude: 'bool'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const CycleDaySchema = {
|
const CycleDaySchema = {
|
||||||
name: 'CycleDay',
|
name: 'CycleDay',
|
||||||
primaryKey: 'date',
|
primaryKey: 'date',
|
||||||
@@ -48,6 +62,10 @@ const CycleDaySchema = {
|
|||||||
mucus: {
|
mucus: {
|
||||||
type: 'Mucus',
|
type: 'Mucus',
|
||||||
optional: true
|
optional: true
|
||||||
|
},
|
||||||
|
cervix: {
|
||||||
|
type: 'Cervix',
|
||||||
|
optional: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,7 +75,8 @@ const realmConfig = {
|
|||||||
CycleDaySchema,
|
CycleDaySchema,
|
||||||
TemperatureSchema,
|
TemperatureSchema,
|
||||||
BleedingSchema,
|
BleedingSchema,
|
||||||
MucusSchema
|
MucusSchema,
|
||||||
|
CervixSchema
|
||||||
],
|
],
|
||||||
// we only want this in dev mode
|
// we only want this in dev mode
|
||||||
deleteRealmIfMigrationNeeded: true
|
deleteRealmIfMigrationNeeded: true
|
||||||
|
|||||||
Generated
+56
-21
@@ -3482,13 +3482,11 @@
|
|||||||
},
|
},
|
||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
@@ -3501,18 +3499,15 @@
|
|||||||
},
|
},
|
||||||
"code-point-at": {
|
"code-point-at": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"console-control-strings": {
|
"console-control-strings": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
@@ -3615,8 +3610,7 @@
|
|||||||
},
|
},
|
||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"ini": {
|
"ini": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
@@ -3626,7 +3620,6 @@
|
|||||||
"is-fullwidth-code-point": {
|
"is-fullwidth-code-point": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"number-is-nan": "^1.0.0"
|
"number-is-nan": "^1.0.0"
|
||||||
}
|
}
|
||||||
@@ -3639,20 +3632,17 @@
|
|||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "2.2.4",
|
"version": "2.2.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "^5.1.1",
|
"safe-buffer": "^5.1.1",
|
||||||
"yallist": "^3.0.0"
|
"yallist": "^3.0.0"
|
||||||
@@ -3669,7 +3659,6 @@
|
|||||||
"mkdirp": {
|
"mkdirp": {
|
||||||
"version": "0.5.1",
|
"version": "0.5.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "0.0.8"
|
"minimist": "0.0.8"
|
||||||
}
|
}
|
||||||
@@ -3742,8 +3731,7 @@
|
|||||||
},
|
},
|
||||||
"number-is-nan": {
|
"number-is-nan": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"object-assign": {
|
"object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
@@ -3753,7 +3741,6 @@
|
|||||||
"once": {
|
"once": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
}
|
}
|
||||||
@@ -3859,7 +3846,6 @@
|
|||||||
"string-width": {
|
"string-width": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"code-point-at": "^1.0.0",
|
"code-point-at": "^1.0.0",
|
||||||
"is-fullwidth-code-point": "^1.0.0",
|
"is-fullwidth-code-point": "^1.0.0",
|
||||||
@@ -6272,6 +6258,14 @@
|
|||||||
"yargs": "^9.0.0"
|
"yargs": "^9.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"react-native-animatable": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-native-animatable/-/react-native-animatable-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-GGYEYvderfzPZcPnw7xov4nlRmi9d6oqcIzx0fGkUUsMshOQEtq5IEzFp3np0uTB9n8/gZIZcdbUPggVlVydMg==",
|
||||||
|
"requires": {
|
||||||
|
"prop-types": "^15.5.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"react-native-calendars": {
|
"react-native-calendars": {
|
||||||
"version": "1.19.3",
|
"version": "1.19.3",
|
||||||
"resolved": "https://registry.npmjs.org/react-native-calendars/-/react-native-calendars-1.19.3.tgz",
|
"resolved": "https://registry.npmjs.org/react-native-calendars/-/react-native-calendars-1.19.3.tgz",
|
||||||
@@ -6304,6 +6298,47 @@
|
|||||||
"react-native-drawer-layout": "1.3.2"
|
"react-native-drawer-layout": "1.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"react-native-modal": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-native-modal/-/react-native-modal-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-DsF4r8ScW0y+bn+7ThzBLP4az/hsi+e9ge79vExkjpw6uNFwNWQPY21BRE4uyip7PpsqEDSyvVb8GH3UXZIYcA==",
|
||||||
|
"requires": {
|
||||||
|
"prop-types": "15.5.10",
|
||||||
|
"react-native-animatable": "^1.2.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"prop-types": {
|
||||||
|
"version": "15.5.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.5.10.tgz",
|
||||||
|
"integrity": "sha1-J5ffwxJhguOpXj37suiT3ddFYVQ=",
|
||||||
|
"requires": {
|
||||||
|
"fbjs": "^0.8.9",
|
||||||
|
"loose-envify": "^1.3.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"react-native-modal-datetime-picker-nevo": {
|
||||||
|
"version": "4.11.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-native-modal-datetime-picker-nevo/-/react-native-modal-datetime-picker-nevo-4.11.0.tgz",
|
||||||
|
"integrity": "sha512-nDUlHyUoRHO+fzt0cc2g+a8kYx+RZQZnjVY01jDIspAbRGTJuCt9x+LjTvhuDQpoXEJYvBEw1W7dz9mn3tNsoQ==",
|
||||||
|
"requires": {
|
||||||
|
"moment": "^2.19.0",
|
||||||
|
"prop-types": "15.5.10",
|
||||||
|
"react-native-modal": "3.1.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"prop-types": {
|
||||||
|
"version": "15.5.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.5.10.tgz",
|
||||||
|
"integrity": "sha1-J5ffwxJhguOpXj37suiT3ddFYVQ=",
|
||||||
|
"requires": {
|
||||||
|
"fbjs": "^0.8.9",
|
||||||
|
"loose-envify": "^1.3.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"react-native-safe-area-view": {
|
"react-native-safe-area-view": {
|
||||||
"version": "0.8.0",
|
"version": "0.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-native-safe-area-view/-/react-native-safe-area-view-0.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-native-safe-area-view/-/react-native-safe-area-view-0.8.0.tgz",
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
"react": "16.3.1",
|
"react": "16.3.1",
|
||||||
"react-native": "0.55.4",
|
"react-native": "0.55.4",
|
||||||
"react-native-calendars": "^1.19.3",
|
"react-native-calendars": "^1.19.3",
|
||||||
|
"react-native-modal-datetime-picker-nevo": "^4.11.0",
|
||||||
"react-native-simple-radio-button": "^2.7.1",
|
"react-native-simple-radio-button": "^2.7.1",
|
||||||
"react-native-svg": "^6.3.1",
|
"react-native-svg": "^6.3.1",
|
||||||
"react-navigation": "^2.0.4",
|
"react-navigation": "^2.0.4",
|
||||||
|
|||||||
Reference in New Issue
Block a user