Merge branch '143-don-t-allow-future-entries-except-note' into 'master'
Resolve "don't allow future entries except note" Closes #137 and #143 See merge request bloodyhealth/drip!65
This commit is contained in:
@@ -49,6 +49,7 @@ export default class CycleDayOverView extends Component {
|
|||||||
const cycleDay = this.state.cycleDay
|
const cycleDay = this.state.cycleDay
|
||||||
const getCycleDayNumber = cycleModule().getCycleDayNumber
|
const getCycleDayNumber = cycleModule().getCycleDayNumber
|
||||||
const cycleDayNumber = getCycleDayNumber(cycleDay.date)
|
const cycleDayNumber = getCycleDayNumber(cycleDay.date)
|
||||||
|
const dateInFuture = LocalDate.now().isBefore(LocalDate.parse(this.state.cycleDay.date))
|
||||||
return (
|
return (
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<Header
|
<Header
|
||||||
@@ -63,36 +64,42 @@ export default class CycleDayOverView extends Component {
|
|||||||
title='Bleeding'
|
title='Bleeding'
|
||||||
onPress={() => this.navigate('BleedingEditView')}
|
onPress={() => this.navigate('BleedingEditView')}
|
||||||
data={getLabel('bleeding', cycleDay.bleeding)}
|
data={getLabel('bleeding', cycleDay.bleeding)}
|
||||||
|
disabled={dateInFuture}
|
||||||
/>
|
/>
|
||||||
<SymptomBox
|
<SymptomBox
|
||||||
title='Temperature'
|
title='Temperature'
|
||||||
onPress={() => this.navigate('TemperatureEditView')}
|
onPress={() => this.navigate('TemperatureEditView')}
|
||||||
data={getLabel('temperature', cycleDay.temperature)}
|
data={getLabel('temperature', cycleDay.temperature)}
|
||||||
|
disabled={dateInFuture}
|
||||||
/>
|
/>
|
||||||
<SymptomBox
|
<SymptomBox
|
||||||
title='Mucus'
|
title='Mucus'
|
||||||
onPress={() => this.navigate('MucusEditView')}
|
onPress={() => this.navigate('MucusEditView')}
|
||||||
data={getLabel('mucus', cycleDay.mucus)}
|
data={getLabel('mucus', cycleDay.mucus)}
|
||||||
|
disabled={dateInFuture}
|
||||||
/>
|
/>
|
||||||
<SymptomBox
|
<SymptomBox
|
||||||
title='Cervix'
|
title='Cervix'
|
||||||
onPress={() => this.navigate('CervixEditView')}
|
onPress={() => this.navigate('CervixEditView')}
|
||||||
data={getLabel('cervix', cycleDay.cervix)}
|
data={getLabel('cervix', cycleDay.cervix)}
|
||||||
/>
|
disabled={dateInFuture}
|
||||||
<SymptomBox
|
|
||||||
title='Note'
|
|
||||||
onPress={() => this.navigate('NoteEditView')}
|
|
||||||
data={getLabel('note', cycleDay.note)}
|
|
||||||
/>
|
/>
|
||||||
<SymptomBox
|
<SymptomBox
|
||||||
title='Desire'
|
title='Desire'
|
||||||
onPress={() => this.navigate('DesireEditView')}
|
onPress={() => this.navigate('DesireEditView')}
|
||||||
data={getLabel('desire', cycleDay.desire)}
|
data={getLabel('desire', cycleDay.desire)}
|
||||||
|
disabled={dateInFuture}
|
||||||
/>
|
/>
|
||||||
<SymptomBox
|
<SymptomBox
|
||||||
title='Sex'
|
title='Sex'
|
||||||
onPress={() => this.navigate('SexEditView')}
|
onPress={() => this.navigate('SexEditView')}
|
||||||
data={getLabel('sex', cycleDay.sex)}
|
data={getLabel('sex', cycleDay.sex)}
|
||||||
|
disabled={dateInFuture}
|
||||||
|
/>
|
||||||
|
<SymptomBox
|
||||||
|
title='Note'
|
||||||
|
onPress={() => this.navigate('NoteEditView')}
|
||||||
|
data={getLabel('note', cycleDay.note)}
|
||||||
/>
|
/>
|
||||||
{/* this is just to make the last row adhere to the grid
|
{/* this is just to make the last row adhere to the grid
|
||||||
(and) because there are no pseudo properties in RN */}
|
(and) because there are no pseudo properties in RN */}
|
||||||
@@ -174,26 +181,26 @@ function getLabel(symptomName, symptom) {
|
|||||||
return label.slice(0, 42) + '...'
|
return label.slice(0, 42) + '...'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SymptomBox extends Component {
|
class SymptomBox extends Component {
|
||||||
render() {
|
render() {
|
||||||
const d = this.props.data
|
const d = this.props.data
|
||||||
const boxActive = d ? styles.symptomBoxActive : {}
|
const boxActive = d ? styles.symptomBoxActive : {}
|
||||||
const iconActive = d ? iconStyles.symptomBoxActive : {}
|
const iconActive = d ? iconStyles.symptomBoxActive : {}
|
||||||
const textStyle = d ? styles.symptomTextActive : {}
|
const iconStyle = Object.assign({}, iconStyles.symptomBox, iconActive, disabledStyle)
|
||||||
|
const textActive = d ? styles.symptomTextActive : {}
|
||||||
const symptomBoxStyle = Object.assign({}, styles.symptomBox, boxActive)
|
const disabledStyle = this.props.disabled ? styles.symptomInFuture : {}
|
||||||
const iconStyle = Object.assign({}, iconStyles.symptomBox, iconActive)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity onPress={this.props.onPress}>
|
<TouchableOpacity onPress={this.props.onPress} disabled={this.props.disabled}>
|
||||||
<View style={symptomBoxStyle}>
|
<View style={[styles.symptomBox, boxActive, disabledStyle]}>
|
||||||
<Icon
|
<Icon
|
||||||
name='thermometer'
|
name='thermometer'
|
||||||
{...iconStyle}
|
{...iconStyle}
|
||||||
/>
|
/>
|
||||||
<Text style={textStyle}>{this.props.title}</Text>
|
<Text style={[textActive, disabledStyle]}>{this.props.title}</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.symptomDataBox}>
|
<View style={[styles.symptomDataBox, disabledStyle]}>
|
||||||
<Text style={styles.symptomDataText}>{this.props.data}</Text>
|
<Text style={styles.symptomDataText}>{this.props.data}</Text>
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|||||||
@@ -61,6 +61,10 @@ export default StyleSheet.create({
|
|||||||
symptomTextActive: {
|
symptomTextActive: {
|
||||||
color: fontOnPrimaryColor
|
color: fontOnPrimaryColor
|
||||||
},
|
},
|
||||||
|
symptomInFuture: {
|
||||||
|
borderColor: 'lightgrey',
|
||||||
|
color: 'lightgrey'
|
||||||
|
},
|
||||||
symptomDataBox: {
|
symptomDataBox: {
|
||||||
borderColor: secondaryColor,
|
borderColor: secondaryColor,
|
||||||
borderStyle: 'solid',
|
borderStyle: 'solid',
|
||||||
|
|||||||
Reference in New Issue
Block a user