Merge branch '76-change-day-view-layout' into 'master'
Resolve "change day view layout" Closes #76 See merge request bloodyhealth/drip!17
This commit is contained in:
+63
-39
@@ -33,45 +33,69 @@ export default class Bleeding extends Component {
|
||||
{label: labels[3], value: 3 },
|
||||
]
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text>Bleeding</Text>
|
||||
<RadioForm
|
||||
radio_props={bleedingRadioProps}
|
||||
initial={this.state.currentValue}
|
||||
formHorizontal={true}
|
||||
labelHorizontal={false}
|
||||
onPress={(itemValue) => {
|
||||
this.setState({currentValue: itemValue})
|
||||
}}
|
||||
/>
|
||||
<Text>Exclude</Text>
|
||||
<Switch
|
||||
onValueChange={(val) => {
|
||||
this.setState({exclude: val})
|
||||
}}
|
||||
value={this.state.exclude} />
|
||||
<Button
|
||||
onPress={() => this.showView('dayView')}
|
||||
title="Cancel">
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() => {
|
||||
saveBleeding(this.cycleDay)
|
||||
this.showView('dayView')
|
||||
}}
|
||||
title="Delete entry">
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() => {
|
||||
saveBleeding(this.cycleDay, {
|
||||
value: this.state.currentValue,
|
||||
exclude: this.state.exclude
|
||||
})
|
||||
this.showView('dayView')
|
||||
}}
|
||||
disabled={ this.state.currentValue === -1 }
|
||||
title="Save">
|
||||
</Button>
|
||||
<View style={ styles.symptomEditView }>
|
||||
<View style={ styles.symptomEditSplitSymptomsAndLastRowButtons }>
|
||||
<View style={ styles.symptomEditListedSymptomView }>
|
||||
<View style={{flex: 1}}>
|
||||
<Text style={styles.symptomDayView}>Bleeding</Text>
|
||||
</View>
|
||||
<View style={{flex: 1}}>
|
||||
<RadioForm
|
||||
radio_props={bleedingRadioProps}
|
||||
initial={this.state.currentValue}
|
||||
formHorizontal={true}
|
||||
labelHorizontal={false}
|
||||
labelStyle={styles.radioButton}
|
||||
onPress={(itemValue) => {
|
||||
this.setState({currentValue: itemValue})
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View style={ styles.itemsInRowSeparatedView }>
|
||||
<View style={ styles.singleButtonView }>
|
||||
<Text style={ styles.symptomDayView }>Exclude</Text>
|
||||
</View>
|
||||
<View style={ styles.singleButtonView }>
|
||||
<Switch
|
||||
onValueChange={(val) => {
|
||||
this.setState({exclude: val})
|
||||
}}
|
||||
value={this.state.exclude}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View style={ styles.itemsInRowSeparatedView }>
|
||||
<View style={ styles.singleButtonView }>
|
||||
<Button
|
||||
onPress={() => this.showView('dayView')}
|
||||
title="Cancel">
|
||||
</Button>
|
||||
</View>
|
||||
<View style={ styles.singleButtonView }>
|
||||
<Button
|
||||
onPress={() => {
|
||||
saveBleeding(this.cycleDay)
|
||||
this.showView('dayView')
|
||||
}}
|
||||
title="Delete">
|
||||
</Button>
|
||||
</View>
|
||||
<View style={ styles.singleButtonView }>
|
||||
<Button
|
||||
onPress={() => {
|
||||
saveBleeding(this.cycleDay, {
|
||||
value: this.state.currentValue,
|
||||
exclude: this.state.exclude
|
||||
})
|
||||
this.showView('dayView')
|
||||
}}
|
||||
disabled={ this.state.currentValue === -1 }
|
||||
title="Save">
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
+29
-17
@@ -39,32 +39,44 @@ export default class DayView extends Component {
|
||||
const bleedingValue = this.cycleDay.bleeding && this.cycleDay.bleeding.value
|
||||
let bleedingLabel
|
||||
if (typeof bleedingValue === 'number') {
|
||||
bleedingLabel = `Bleeding: ${labels[bleedingValue]}`
|
||||
if (this.cycleDay.bleeding.exclude) bleedingLabel += " (Excluded)"
|
||||
bleedingLabel = `${labels[bleedingValue]}`
|
||||
if (this.cycleDay.bleeding.exclude) bleedingLabel = "( " + bleedingLabel + " )"
|
||||
} else {
|
||||
bleedingLabel = null
|
||||
bleedingLabel = 'edit'
|
||||
}
|
||||
const temperatureValue = this.cycleDay.temperature && this.cycleDay.temperature.value
|
||||
let temperatureLabel
|
||||
if (typeof temperatureValue === 'number') {
|
||||
temperatureLabel = `Temperature: ${temperatureValue}`
|
||||
if (this.cycleDay.temperature.exclude) temperatureLabel += " (Excluded)"
|
||||
temperatureLabel = `${temperatureValue} °C`
|
||||
if (this.cycleDay.temperature.exclude) temperatureLabel = "( " + temperatureLabel + " )"
|
||||
} else {
|
||||
temperatureLabel = null
|
||||
temperatureLabel = 'edit'
|
||||
}
|
||||
|
||||
return (
|
||||
<View>
|
||||
<Text style={styles.welcome}>{bleedingLabel}</Text>
|
||||
<Text style={styles.welcome}>{temperatureLabel}</Text>
|
||||
<Button
|
||||
onPress={() => this.showView('bleedingEditView')}
|
||||
title="Edit bleeding">
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() => this.showView('temperatureEditView')}
|
||||
title="Edit temperature">
|
||||
</Button>
|
||||
<View style={ styles.symptomEditListedSymptomView }>
|
||||
<View style={ styles.itemsInRowSeparatedView }>
|
||||
<View style={{flex: 1}}>
|
||||
<Text style={styles.symptomDayView}>Bleeding</Text>
|
||||
</View>
|
||||
<View style={ styles.singleButtonView }>
|
||||
<Button
|
||||
onPress={() => this.showView('bleedingEditView')}
|
||||
title={bleedingLabel}>
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
<View style={ styles.itemsInRowSeparatedView}>
|
||||
<View style={{flex: 1}}>
|
||||
<Text style={styles.symptomDayView}>Temperature</Text>
|
||||
</View>
|
||||
<View style={ styles.singleButtonView }>
|
||||
<Button
|
||||
onPress={() => this.showView('temperatureEditView')}
|
||||
title={temperatureLabel}>
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
</View >
|
||||
)
|
||||
}
|
||||
|
||||
+17
-10
@@ -29,16 +29,23 @@ export default class Day extends Component {
|
||||
render() {
|
||||
const cycleDayNumber = getCycleDayNumber(this.cycleDay.date)
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.welcome}>{formatDateForViewHeader(this.cycleDay.date)}</Text>
|
||||
{ cycleDayNumber && <Text>Cycle day {cycleDayNumber}</Text> }
|
||||
{
|
||||
{ dayView: <DayView cycleDay={this.cycleDay} showView={this.showView} />,
|
||||
bleedingEditView: <BleedingEditView cycleDay={this.cycleDay} showView={this.showView}/>,
|
||||
temperatureEditView: <TemperatureEditView cycleDay={this.cycleDay} showView={this.showView}/>
|
||||
}[this.state.visibleComponent]
|
||||
}
|
||||
|
||||
<View style={ styles.cycleDayOuterView }>
|
||||
<View style={ styles.cycleDayDateView }>
|
||||
<Text style={styles.dateHeader}>
|
||||
{formatDateForViewHeader(this.cycleDay.date)}
|
||||
</Text>
|
||||
</View >
|
||||
<View style={ styles.cycleDayNumberView }>
|
||||
{ cycleDayNumber && <Text style={styles.cycleDayNumber} >Cycle day {cycleDayNumber}</Text> }
|
||||
</View >
|
||||
<View style={ styles.cycleDaySymptomsView }>
|
||||
{
|
||||
{ dayView: <DayView cycleDay={this.cycleDay} showView={this.showView} />,
|
||||
bleedingEditView: <BleedingEditView cycleDay={this.cycleDay} showView={this.showView}/>,
|
||||
temperatureEditView: <TemperatureEditView cycleDay={this.cycleDay} showView={this.showView}/>
|
||||
}[this.state.visibleComponent]
|
||||
}
|
||||
</View >
|
||||
</View >
|
||||
)
|
||||
}
|
||||
|
||||
@@ -46,20 +46,32 @@ export default class Home extends Component {
|
||||
render() {
|
||||
const navigate = this.props.navigation.navigate
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.welcome}>{this.state.welcomeText}</Text>
|
||||
<Button
|
||||
onPress={() => this.passTodayToDayView()}
|
||||
title="Edit symptoms for today">
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() => navigate('calendar')}
|
||||
title="Go to calendar">
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() => deleteAll()}
|
||||
title="delete everything">
|
||||
</Button>
|
||||
<View style={ styles.homeContainerView }>
|
||||
<View style={{flex: 2}}>
|
||||
<View>
|
||||
<Text style={styles.welcome}>{this.state.welcomeText}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View style={ styles.homeButtonsView}>
|
||||
<View>
|
||||
<Button
|
||||
onPress={() => this.passTodayToDayView()}
|
||||
title="Edit symptoms for today">
|
||||
</Button>
|
||||
</View>
|
||||
<View>
|
||||
<Button
|
||||
onPress={() => navigate('calendar')}
|
||||
title="Go to calendar">
|
||||
</Button>
|
||||
</View>
|
||||
<View>
|
||||
<Button
|
||||
onPress={() => deleteAll()}
|
||||
title="delete everything">
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,97 @@ export default StyleSheet.create({
|
||||
welcome: {
|
||||
fontSize: 20,
|
||||
margin: 30,
|
||||
textAlign: 'center'
|
||||
textAlign: 'center',
|
||||
textAlignVertical: 'center'
|
||||
},
|
||||
dateHeader: {
|
||||
fontSize: 20,
|
||||
fontWeight: 'bold',
|
||||
margin: 30,
|
||||
color: 'white',
|
||||
textAlign: 'center',
|
||||
textAlignVertical: 'center'
|
||||
},
|
||||
cycleDayNumber: {
|
||||
fontSize: 18,
|
||||
margin: 20,
|
||||
textAlign: 'center',
|
||||
textAlignVertical: 'center'
|
||||
},
|
||||
symptomDayView: {
|
||||
fontSize: 20,
|
||||
margin: 30,
|
||||
textAlign: 'left',
|
||||
textAlignVertical: 'center'
|
||||
},
|
||||
radioButton: {
|
||||
fontSize: 18,
|
||||
margin: 5,
|
||||
textAlign: 'center',
|
||||
textAlignVertical: 'center'
|
||||
},
|
||||
singleButtonView: {
|
||||
flex: 1,
|
||||
margin: 5
|
||||
},
|
||||
itemsInRowView: {
|
||||
flex: 1,
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'center'
|
||||
},
|
||||
itemsInRowSeparatedView: {
|
||||
flex: 1,
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-evenly',
|
||||
alignItems: 'center'
|
||||
},
|
||||
symptomEditView: {
|
||||
flex: 1,
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'flex-start'
|
||||
},
|
||||
symptomEditSplitSymptomsAndLastRowButtons: {
|
||||
flex: 4,
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'flex-start'
|
||||
},
|
||||
symptomEditListedSymptomView: {
|
||||
flex: 1,
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'flex-start'
|
||||
},
|
||||
cycleDayOuterView: {
|
||||
flex: 1,
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'space-around'
|
||||
},
|
||||
cycleDayDateView: {
|
||||
flex: 2,
|
||||
justifyContent: 'center',
|
||||
backgroundColor: 'steelblue'
|
||||
},
|
||||
cycleDayNumberView: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
backgroundColor: 'skyblue'
|
||||
},
|
||||
cycleDaySymptomsView: {
|
||||
flex: 8,
|
||||
justifyContent: 'center'
|
||||
},
|
||||
homeContainerView: {
|
||||
flex: 0.5,
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'space-around'
|
||||
},
|
||||
homeButtonsView: {
|
||||
flex: 3,
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'space-around',
|
||||
margin: 5
|
||||
}
|
||||
})
|
||||
+64
-41
@@ -8,6 +8,7 @@ import {
|
||||
} from 'react-native'
|
||||
|
||||
import { saveTemperature, getPreviousTemperature } from './db'
|
||||
import styles from './styles'
|
||||
|
||||
export default class Temp extends Component {
|
||||
constructor(props) {
|
||||
@@ -32,47 +33,69 @@ export default class Temp extends Component {
|
||||
render() {
|
||||
const cycleDay = this.cycleDay
|
||||
return (
|
||||
<View>
|
||||
<Text>Temperature</Text>
|
||||
<TextInput
|
||||
placeholder="Enter temperature"
|
||||
onChangeText={(val) => {
|
||||
this.setState({currentValue: val})
|
||||
}}
|
||||
keyboardType='numeric'
|
||||
value = {this.state.currentValue}
|
||||
/>
|
||||
<Text>Exclude</Text>
|
||||
<Switch
|
||||
onValueChange = {(val) => {
|
||||
this.setState({ exclude: val })
|
||||
}}
|
||||
value = { this.state.exclude }
|
||||
/>
|
||||
<Button
|
||||
onPress={() => {
|
||||
this.showView('dayView')
|
||||
}}
|
||||
title="Cancel">
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() => {
|
||||
saveTemperature(cycleDay)
|
||||
this.showView('dayView')
|
||||
}}
|
||||
title="Delete entry">
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() => {
|
||||
saveTemperature(cycleDay, {
|
||||
value: Number(this.state.currentValue),
|
||||
exclude: this.state.exclude
|
||||
})
|
||||
this.showView('dayView')
|
||||
}}
|
||||
disabled={ this.state.currentValue === '' }
|
||||
title="Save">
|
||||
</Button>
|
||||
<View style={ styles.symptomEditView }>
|
||||
<View style={ styles.symptomEditSplitSymptomsAndLastRowButtons }>
|
||||
<View style={ styles.itemsInRowView }>
|
||||
<View style={{flex: 3, margin: 5}}>
|
||||
<Text style={styles.symptomDayView}>Temperature (°C)</Text>
|
||||
</View>
|
||||
<View style={{flex: 1, margin: 5}}>
|
||||
<TextInput
|
||||
placeholder="Enter"
|
||||
onChangeText={(val) => {
|
||||
this.setState({currentValue: val})
|
||||
}}
|
||||
keyboardType='numeric'
|
||||
value = {this.state.currentValue}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View style={ styles.itemsInRowSeparatedView }>
|
||||
<View style={{flex: 1, margin: 5}}>
|
||||
<Text style={styles.symptomDayView}>Exclude</Text>
|
||||
</View>
|
||||
<View style={{flex: 1, margin: 5}}>
|
||||
<Switch
|
||||
onValueChange = {(val) => {
|
||||
this.setState({ exclude: val })
|
||||
}}
|
||||
value = { this.state.exclude }
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View style={ styles.itemsInRowSeparatedView }>
|
||||
<View style={ styles.singleButtonView }>
|
||||
<Button
|
||||
onPress={() => {
|
||||
this.showView('dayView')
|
||||
}}
|
||||
title="Cancel">
|
||||
</Button>
|
||||
</View>
|
||||
<View style={ styles.singleButtonView }>
|
||||
<Button
|
||||
onPress={() => {
|
||||
saveTemperature(cycleDay)
|
||||
this.showView('dayView')
|
||||
}}
|
||||
title="Delete">
|
||||
</Button>
|
||||
</View>
|
||||
<View style={ styles.singleButtonView }>
|
||||
<Button
|
||||
onPress={() => {
|
||||
saveTemperature(cycleDay, {
|
||||
value: Number(this.state.currentValue),
|
||||
exclude: this.state.exclude
|
||||
})
|
||||
this.showView('dayView')
|
||||
}}
|
||||
disabled={ this.state.currentValue === '' }
|
||||
title="Save">
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user