Skip to content
Snippets Groups Projects
Commit 4a5afd46 authored by tina's avatar tina
Browse files

change layouts of cycle-day, edit symptoms screens and home

parent a46eb442
No related branches found
No related tags found
No related merge requests found
......@@ -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={{flex: 1, flexDirection: 'column', justifyContent: 'space-between', alignItems: 'flex-start'}}>
<View style={{flex: 4, flexDirection: 'column', justifyContent: 'flex-start', alignItems: 'flex-start'}}>
<View style={{flex: 1, flexDirection: 'column', justifyContent: 'flex-start', alignItems: 'flex-start'}}>
<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={{flex: 1, flexDirection: 'row', justifyContent: 'space-evenly', alignItems: 'center'}}>
<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={{flex: 1, flexDirection: 'row', justifyContent: 'space-evenly', alignItems: 'center'}}>
<View style={{flex: 1, margin: 5}}>
<Button
onPress={() => this.showView('dayView')}
title="Cancel">
</Button>
</View>
<View style={{flex: 1, margin: 5}}>
<Button
onPress={() => {
saveBleeding(this.cycleDay)
this.showView('dayView')
}}
title="Delete">
</Button>
</View>
<View style={{flex: 1, margin: 5}}>
<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>
)
}
......
......@@ -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={{flex: 1, flexDirection: 'column', justifyContent: 'flex-start'}}>
<View style={{flexDirection: 'row', justifyContent: 'space-evenly', alignItems: 'center'}}>
<View style={{flex: 1}}>
<Text style={styles.symptomDayView}>Bleeding</Text>
</View>
<View style={{flex: 1, margin:5}}>
<Button
onPress={() => this.showView('bleedingEditView')}
title={bleedingLabel}>
</Button>
</View>
</View>
<View style={{flexDirection: 'row', justifyContent: 'space-evenly', alignItems: 'center'}}>
<View style={{flex: 1}}>
<Text style={styles.symptomDayView}>Temperature</Text>
</View>
<View style={{flex: 1, margin:5}}>
<Button
onPress={() => this.showView('temperatureEditView')}
title={temperatureLabel}>
</Button>
</View>
</View>
</View >
)
}
......
......@@ -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={{flex: 1, flexDirection: 'column', justifyContent: 'space-around'}}>
<View style={{flex: 2, justifyContent: 'center', backgroundColor: 'steelblue'}}>
<Text style={styles.dateHeader}>
{formatDateForViewHeader(this.cycleDay.date)}
</Text>
</View >
<View style={{flex: 1, justifyContent: 'center', backgroundColor: 'skyblue'}}>
{ cycleDayNumber && <Text style={styles.cycleDayNumber} >Cycle day {cycleDayNumber}</Text> }
</View >
<View style={{flex: 8, justifyContent: 'center',}}>
{
{ 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={{flex: 0.5, flexDirection: 'column', justifyContent: 'space-around'}}>
<View style={{flex: 2}}>
<View>
<Text style={styles.welcome}>{this.state.welcomeText}</Text>
</View>
</View>
<View style={{flex: 3, flexDirection: 'column', justifyContent: 'space-around', margin: 5}}>
<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,33 @@ 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'
},
})
\ No newline at end of file
......@@ -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={{flex: 1, flexDirection: 'column', justifyContent: 'space-between', alignItems: 'flex-start'}}>
<View style={{flex: 4, flexDirection: 'column', justifyContent: 'flex-start', alignItems: 'flex-start'}}>
<View style={{flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center'}}>
<View style={{flex: 3, margin: 5}}>
<Text style={styles.symptomDayView}>Temperature (°C)</Text>
</View>
<View style={{flex: 1, margin: 5}}>
<TextInput
placeholder="Enter temperature"
onChangeText={(val) => {
this.setState({currentValue: val})
}}
keyboardType='numeric'
value = {this.state.currentValue}
/>
</View>
</View>
<View style={{flexDirection: 'row', justifyContent: 'space-evenly', alignItems: 'center'}}>
<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={{flex: 1, flexDirection: 'row', justifyContent: 'space-evenly', alignItems: 'center'}}>
<View style={{flex: 1, margin: 5}}>
<Button
onPress={() => {
this.showView('dayView')
}}
title="Cancel">
</Button>
</View>
<View style={{flex: 1, margin: 5}}>
<Button
onPress={() => {
saveTemperature(cycleDay)
this.showView('dayView')
}}
title="Delete">
</Button>
</View>
<View style={{flex: 1, margin: 5}}>
<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>
)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment