Replace action button footer in remaining symptom views
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import { View, BackHandler, ScrollView } from 'react-native'
|
||||
import { View, BackHandler } from 'react-native'
|
||||
import Header from './components/header'
|
||||
import Menu from './components/menu'
|
||||
import Home from './components/home'
|
||||
@@ -9,11 +9,11 @@ import symptomViews from './components/cycle-day/symptoms'
|
||||
import Chart from './components/chart/chart'
|
||||
import Settings from './components/settings'
|
||||
import Stats from './components/stats'
|
||||
import styles from './styles'
|
||||
|
||||
// this is until react native fixes this bugg, see
|
||||
// https://github.com/facebook/react-native/issues/18868#issuecomment-382671739
|
||||
import { YellowBox } from 'react-native'
|
||||
import ActionButtonFooter from './components/cycle-day/symptoms/action-button-footer';
|
||||
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated'])
|
||||
|
||||
const isSymptomView = name => Object.keys(symptomViews).indexOf(name) > -1
|
||||
@@ -46,37 +46,21 @@ export default class App extends Component {
|
||||
this.setState({currentPage: pageName, currentProps: props})
|
||||
}
|
||||
|
||||
setActionButtonState(actionButtonInfo) {
|
||||
this.setState({actionButtonInfo})
|
||||
}
|
||||
|
||||
unsetActionButtonState() {
|
||||
this.setState({actionButtonInfo: null})
|
||||
}
|
||||
|
||||
render() {
|
||||
const page = {
|
||||
Home, Calendar, CycleDay, Chart, Settings, Stats, ...symptomViews
|
||||
}[this.state.currentPage]
|
||||
return (
|
||||
<View style={{height: '100%', justifyContent: 'space-between' }}>
|
||||
<View>
|
||||
<View style={styles.menuOnBottom}>
|
||||
|
||||
{this.state.currentPage != 'CycleDay' && <Header title={this.state.currentPage} />}
|
||||
<ScrollView>
|
||||
|
||||
{React.createElement(page, {
|
||||
navigate: this.navigate.bind(this),
|
||||
setActionButtonState: this.setActionButtonState.bind(this),
|
||||
unsetActionButtonState: this.unsetActionButtonState.bind(this),
|
||||
...this.state.currentProps
|
||||
})}
|
||||
</ScrollView>
|
||||
</View>
|
||||
{isSymptomView(this.state.currentPage) && this.state.actionButtonInfo ?
|
||||
<ActionButtonFooter
|
||||
{...this.state.actionButtonInfo}
|
||||
navigate={this.navigate.bind(this)}
|
||||
/>
|
||||
:
|
||||
|
||||
{!isSymptomView(this.state.currentPage) &&
|
||||
<Menu navigate={this.navigate.bind(this)} />
|
||||
}
|
||||
</View>
|
||||
|
||||
@@ -8,6 +8,7 @@ import RadioForm from 'react-native-simple-radio-button'
|
||||
import styles from '../../../styles'
|
||||
import { saveSymptom } from '../../../db'
|
||||
import { bleeding as labels } from '../labels/labels'
|
||||
import ActionButtonFooter from './action-button-footer'
|
||||
|
||||
export default class Bleeding extends Component {
|
||||
constructor(props) {
|
||||
@@ -32,8 +33,8 @@ export default class Bleeding extends Component {
|
||||
{ label: labels[3], value: 3 },
|
||||
]
|
||||
return (
|
||||
<View style={styles.menuOnBottom}>
|
||||
<View>
|
||||
<View style={styles.symptomEditView}>
|
||||
<Text style={styles.symptomDayView}>Bleeding</Text>
|
||||
<View style={styles.radioButtonRow}>
|
||||
<RadioForm
|
||||
@@ -57,21 +58,18 @@ export default class Bleeding extends Component {
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View style={styles.actionButtonRow}>
|
||||
{this.makeActionButtons(
|
||||
{
|
||||
symptom: 'bleeding',
|
||||
cycleDay: this.cycleDay,
|
||||
saveAction: () => {
|
||||
saveSymptom('bleeding', this.cycleDay, {
|
||||
<ActionButtonFooter
|
||||
symptom='bleeding'
|
||||
cycleDay={this.props.cycleDay}
|
||||
saveAction={() => {
|
||||
saveSymptom('bleeding', this.props.cycleDay, {
|
||||
value: this.state.currentValue,
|
||||
exclude: this.state.exclude
|
||||
})
|
||||
},
|
||||
saveDisabled: this.state.currentValue === -1
|
||||
}
|
||||
)}
|
||||
</View>
|
||||
}}
|
||||
saveDisabled={this.state.currentValue === -1}
|
||||
navigate={this.props.navigate}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
cervixFirmness as firmnessLabels,
|
||||
cervixPosition as positionLabels
|
||||
} from '../labels/labels'
|
||||
import ActionButtonFooter from './action-button-footer'
|
||||
|
||||
export default class Cervix extends Component {
|
||||
constructor(props) {
|
||||
@@ -48,7 +49,8 @@ export default class Cervix extends Component {
|
||||
{ label: positionLabels[2], value: 2 }
|
||||
]
|
||||
return (
|
||||
<View style={ styles.symptomEditView }>
|
||||
<View style={styles.menuOnBottom}>
|
||||
<View>
|
||||
<Text style={styles.symptomDayView}>Cervix</Text>
|
||||
<Text style={styles.symptomDayView}>Opening</Text>
|
||||
<View style={styles.radioButtonRow}>
|
||||
@@ -98,23 +100,21 @@ export default class Cervix extends Component {
|
||||
value={this.state.exclude}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.actionButtonRow}>
|
||||
{this.makeActionButtons(
|
||||
{
|
||||
symptom: 'cervix',
|
||||
cycleDay: this.cycleDay,
|
||||
saveAction: () => {
|
||||
</View>
|
||||
<ActionButtonFooter
|
||||
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>
|
||||
}}
|
||||
saveDisabled={this.state.opening === -1 || this.state.firmness === -1}
|
||||
navigate={this.props.navigate}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import RadioForm from 'react-native-simple-radio-button'
|
||||
import styles from '../../../styles'
|
||||
import { saveSymptom } from '../../../db'
|
||||
import { intensity as labels } from '../labels/labels'
|
||||
import ActionButtonFooter from './action-button-footer'
|
||||
|
||||
export default class Desire extends Component {
|
||||
constructor(props) {
|
||||
@@ -27,7 +28,8 @@ export default class Desire extends Component {
|
||||
{ label: labels[2], value: 2 }
|
||||
]
|
||||
return (
|
||||
<View style={styles.symptomEditView}>
|
||||
<View style={styles.menuOnBottom}>
|
||||
<View>
|
||||
<Text style={styles.symptomDayView}>Desire</Text>
|
||||
<View style={styles.radioButtonRow}>
|
||||
<RadioForm
|
||||
@@ -41,18 +43,16 @@ export default class Desire extends Component {
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.actionButtonRow}>
|
||||
{this.makeActionButtons(
|
||||
{
|
||||
symptom: 'desire',
|
||||
cycleDay: this.cycleDay,
|
||||
saveAction: () => {
|
||||
saveSymptom('desire', this.cycleDay, { value: this.state.currentValue })
|
||||
},
|
||||
saveDisabled: this.state.currentValue === -1
|
||||
}
|
||||
)}
|
||||
</View>
|
||||
<ActionButtonFooter
|
||||
symptom='desire'
|
||||
cycleDay={this.cycleDay}
|
||||
saveAction={() => {
|
||||
saveSymptom('desire', this.cycleDay, { value: this.state.currentValue })
|
||||
}}
|
||||
saveDisabled={this.state.currentValue === -1}
|
||||
navigate={this.props.navigate}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
mucusTexture as textureLabels
|
||||
} from '../labels/labels'
|
||||
import computeSensiplanValue from '../../../lib/sensiplan-mucus'
|
||||
import ActionButtonFooter from './action-button-footer'
|
||||
|
||||
|
||||
export default class Mucus extends Component {
|
||||
@@ -31,7 +32,6 @@ export default class Mucus extends Component {
|
||||
}
|
||||
})
|
||||
/* eslint-enable react/no-direct-mutation-state */
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -47,7 +47,8 @@ export default class Mucus extends Component {
|
||||
{ label: textureLabels[2], value: 2 }
|
||||
]
|
||||
return (
|
||||
<View style={ styles.symptomEditView }>
|
||||
<View style={styles.menuOnBottom}>
|
||||
<View>
|
||||
<Text style={styles.symptomDayView}>Mucus</Text>
|
||||
<Text style={styles.symptomDayView}>Feeling</Text>
|
||||
<View style={styles.radioButtonRow}>
|
||||
@@ -84,25 +85,21 @@ export default class Mucus extends Component {
|
||||
value={this.state.exclude}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.actionButtonRow}>
|
||||
{this.makeActionButtons(
|
||||
{
|
||||
symptom: 'mucus',
|
||||
cycleDay: this.cycleDay,
|
||||
saveAction: () => {
|
||||
</View>
|
||||
<ActionButtonFooter
|
||||
symptom='mucus'
|
||||
cycleDay={this.cycleDay}
|
||||
saveAction={() => {
|
||||
saveSymptom('mucus', this.cycleDay, {
|
||||
feeling: this.state.feeling,
|
||||
texture: this.state.texture,
|
||||
value: computeSensiplanValue(this.state.feeling, this.state.texture),
|
||||
exclude: this.state.exclude
|
||||
})
|
||||
},
|
||||
saveDisabled: this.state.feeling === -1 || this.state.texture === -1
|
||||
}
|
||||
)}
|
||||
</View>
|
||||
|
||||
}}
|
||||
saveDisabled={this.state.feeling === -1 || this.state.texture === -1}
|
||||
navigate={this.props.navigate}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
|
||||
import styles from '../../../styles'
|
||||
import { saveSymptom } from '../../../db'
|
||||
import ActionButtonFooter from './action-button-footer'
|
||||
|
||||
export default class Temp extends Component {
|
||||
constructor(props) {
|
||||
@@ -22,7 +23,7 @@ export default class Temp extends Component {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.symptomEditView}>
|
||||
<View style={styles.menuOnBottom}>
|
||||
<View style={styles.symptomViewRow}>
|
||||
<Text style={styles.symptomDayView}>Note</Text>
|
||||
<TextInput
|
||||
@@ -34,18 +35,17 @@ export default class Temp extends Component {
|
||||
value={this.state.currentValue}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.actionButtonRow}>
|
||||
{this.makeActionButtons({
|
||||
symptom: 'note',
|
||||
cycleDay: this.cycleDay,
|
||||
saveAction: () => {
|
||||
<ActionButtonFooter
|
||||
symptom='note'
|
||||
cycleDay={this.cycleDay}
|
||||
saveAction={() => {
|
||||
saveSymptom('note', this.cycleDay, {
|
||||
value: this.state.currentValue
|
||||
})
|
||||
},
|
||||
saveDisabled: !this.state.currentValue
|
||||
})}
|
||||
</View>
|
||||
}}
|
||||
saveDisabled={!this.state.currentValue}
|
||||
navigate={this.props.navigate}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
sexActivity as activityLabels,
|
||||
contraceptives as contraceptiveLabels
|
||||
} from '../labels/labels'
|
||||
import ActionButtonFooter from './action-button-footer'
|
||||
|
||||
export default class Sex extends Component {
|
||||
constructor(props) {
|
||||
@@ -30,7 +31,8 @@ export default class Sex extends Component {
|
||||
render() {
|
||||
|
||||
return (
|
||||
<View style={styles.symptomEditView}>
|
||||
<View style={styles.menuOnBottom}>
|
||||
<View>
|
||||
<Text style={styles.symptomDayView}>SEX</Text>
|
||||
<View style={styles.symptomViewRowInline}>
|
||||
<Text style={styles.symptomDayView}>{activityLabels.solo}</Text>
|
||||
@@ -134,22 +136,20 @@ export default class Sex extends Component {
|
||||
}}
|
||||
/>
|
||||
}
|
||||
<View style={styles.actionButtonRow}>
|
||||
{this.props.makeActionButtons(
|
||||
{
|
||||
symptom: 'sex',
|
||||
cycleDay: this.cycleDay,
|
||||
saveAction: () => {
|
||||
</View>
|
||||
<ActionButtonFooter
|
||||
symptom='sex'
|
||||
cycleDay={this.cycleDay}
|
||||
saveAction={() => {
|
||||
const copyOfState = Object.assign({}, this.state)
|
||||
if (!copyOfState.other) {
|
||||
copyOfState.note = null
|
||||
}
|
||||
saveSymptom('sex', this.cycleDay, copyOfState)
|
||||
},
|
||||
saveDisabled: Object.values(this.state).every(value => !value)
|
||||
}
|
||||
)}
|
||||
</View>
|
||||
}}
|
||||
saveDisabled={Object.values(this.state).every(value => !value)}
|
||||
navigate={this.props.navigate}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import DateTimePicker from 'react-native-modal-datetime-picker-nevo'
|
||||
import { getPreviousTemperature, saveSymptom } from '../../../db'
|
||||
import styles from '../../../styles'
|
||||
import { LocalTime, ChronoUnit } from 'js-joda'
|
||||
import ActionButtonFooter from './action-button-footer'
|
||||
|
||||
const MINUTES = ChronoUnit.MINUTES
|
||||
|
||||
@@ -37,29 +38,12 @@ export default class Temp extends Component {
|
||||
time: this.time || LocalTime.now().truncatedTo(MINUTES).toString(),
|
||||
isTimePickerVisible: false
|
||||
}
|
||||
|
||||
props.setActionButtonState({
|
||||
symptom : 'temperature',
|
||||
cycleDay: props.cycleDay,
|
||||
saveAction: () => {
|
||||
const dataToSave = {
|
||||
value: Number(this.state.currentValue),
|
||||
exclude: this.state.exclude,
|
||||
time: this.state.time
|
||||
}
|
||||
saveSymptom('temperature', props.cycleDay, dataToSave)
|
||||
},
|
||||
saveDisabled: this.state.currentValue === '' || isInvalidTime(this.state.time)
|
||||
})
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.props.unsetActionButtonState()
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.symptomEditView}>
|
||||
<View style={styles.menuOnBottom}>
|
||||
<View>
|
||||
<View style={styles.symptomViewRowInline}>
|
||||
<Text style={styles.symptomDayView}>Temperature (°C)</Text>
|
||||
<TextInput
|
||||
@@ -104,6 +88,21 @@ export default class Temp extends Component {
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<ActionButtonFooter
|
||||
symptom='temperature'
|
||||
cycleDay={this.cycleDay}
|
||||
saveAction={() => {
|
||||
const dataToSave = {
|
||||
value: Number(this.state.currentValue),
|
||||
exclude: this.state.exclude,
|
||||
time: this.state.time
|
||||
}
|
||||
saveSymptom('temperature', this.props.cycleDay, dataToSave)
|
||||
}}
|
||||
saveDisabled={this.state.currentValue === '' || isInvalidTime(this.state.time)}
|
||||
navigate={this.props.navigate}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
ScrollView
|
||||
} from 'react-native'
|
||||
import { LocalDate, ChronoUnit } from 'js-joda'
|
||||
import Header from './header'
|
||||
import styles from '../styles/index'
|
||||
import cycleModule from '../lib/cycle'
|
||||
import getCycleInfo from '../lib/cycle-length'
|
||||
|
||||
@@ -83,6 +83,10 @@ export default StyleSheet.create({
|
||||
symptomDataText: {
|
||||
fontSize: 12
|
||||
},
|
||||
menuOnBottom: {
|
||||
flex: 1,
|
||||
justifyContent: 'space-between'
|
||||
},
|
||||
symptomEditRow: {
|
||||
justifyContent: 'space-between',
|
||||
marginBottom: 10,
|
||||
|
||||
Reference in New Issue
Block a user