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 getCycleDayNumber = cycleModule().getCycleDayNumber
|
||||
const cycleDayNumber = getCycleDayNumber(cycleDay.date)
|
||||
const dateInFuture = LocalDate.now().isBefore(LocalDate.parse(this.state.cycleDay.date))
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<Header
|
||||
@@ -63,36 +64,42 @@ export default class CycleDayOverView extends Component {
|
||||
title='Bleeding'
|
||||
onPress={() => this.navigate('BleedingEditView')}
|
||||
data={getLabel('bleeding', cycleDay.bleeding)}
|
||||
disabled={dateInFuture}
|
||||
/>
|
||||
<SymptomBox
|
||||
title='Temperature'
|
||||
onPress={() => this.navigate('TemperatureEditView')}
|
||||
data={getLabel('temperature', cycleDay.temperature)}
|
||||
disabled={dateInFuture}
|
||||
/>
|
||||
<SymptomBox
|
||||
title='Mucus'
|
||||
onPress={() => this.navigate('MucusEditView')}
|
||||
data={getLabel('mucus', cycleDay.mucus)}
|
||||
disabled={dateInFuture}
|
||||
/>
|
||||
<SymptomBox
|
||||
title='Cervix'
|
||||
onPress={() => this.navigate('CervixEditView')}
|
||||
data={getLabel('cervix', cycleDay.cervix)}
|
||||
/>
|
||||
<SymptomBox
|
||||
title='Note'
|
||||
onPress={() => this.navigate('NoteEditView')}
|
||||
data={getLabel('note', cycleDay.note)}
|
||||
disabled={dateInFuture}
|
||||
/>
|
||||
<SymptomBox
|
||||
title='Desire'
|
||||
onPress={() => this.navigate('DesireEditView')}
|
||||
data={getLabel('desire', cycleDay.desire)}
|
||||
disabled={dateInFuture}
|
||||
/>
|
||||
<SymptomBox
|
||||
title='Sex'
|
||||
onPress={() => this.navigate('SexEditView')}
|
||||
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
|
||||
(and) because there are no pseudo properties in RN */}
|
||||
@@ -174,26 +181,26 @@ function getLabel(symptomName, symptom) {
|
||||
return label.slice(0, 42) + '...'
|
||||
}
|
||||
|
||||
|
||||
class SymptomBox extends Component {
|
||||
render() {
|
||||
const d = this.props.data
|
||||
const boxActive = d ? styles.symptomBoxActive : {}
|
||||
const iconActive = d ? iconStyles.symptomBoxActive : {}
|
||||
const textStyle = d ? styles.symptomTextActive : {}
|
||||
|
||||
const symptomBoxStyle = Object.assign({}, styles.symptomBox, boxActive)
|
||||
const iconStyle = Object.assign({}, iconStyles.symptomBox, iconActive)
|
||||
const iconStyle = Object.assign({}, iconStyles.symptomBox, iconActive, disabledStyle)
|
||||
const textActive = d ? styles.symptomTextActive : {}
|
||||
const disabledStyle = this.props.disabled ? styles.symptomInFuture : {}
|
||||
|
||||
return (
|
||||
<TouchableOpacity onPress={this.props.onPress}>
|
||||
<View style={symptomBoxStyle}>
|
||||
<TouchableOpacity onPress={this.props.onPress} disabled={this.props.disabled}>
|
||||
<View style={[styles.symptomBox, boxActive, disabledStyle]}>
|
||||
<Icon
|
||||
name='thermometer'
|
||||
{...iconStyle}
|
||||
/>
|
||||
<Text style={textStyle}>{this.props.title}</Text>
|
||||
<Text style={[textActive, disabledStyle]}>{this.props.title}</Text>
|
||||
</View>
|
||||
<View style={styles.symptomDataBox}>
|
||||
<View style={[styles.symptomDataBox, disabledStyle]}>
|
||||
<Text style={styles.symptomDataText}>{this.props.data}</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
@@ -61,6 +61,10 @@ export default StyleSheet.create({
|
||||
symptomTextActive: {
|
||||
color: fontOnPrimaryColor
|
||||
},
|
||||
symptomInFuture: {
|
||||
borderColor: 'lightgrey',
|
||||
color: 'lightgrey'
|
||||
},
|
||||
symptomDataBox: {
|
||||
borderColor: secondaryColor,
|
||||
borderStyle: 'solid',
|
||||
|
||||
Reference in New Issue
Block a user