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

This commit is contained in:
tina
2018-06-15 19:31:29 +02:00
parent a46eb4421b
commit 4a5afd4662
6 changed files with 228 additions and 123 deletions
+29 -5
View File
@@ -33,34 +33,56 @@ export default class Bleeding extends Component {
{label: labels[3], value: 3 }, {label: labels[3], value: 3 },
] ]
return ( return (
<View style={styles.container}> <View style={{flex: 1, flexDirection: 'column', justifyContent: 'space-between', alignItems: 'flex-start'}}>
<Text>Bleeding</Text> <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 <RadioForm
radio_props={bleedingRadioProps} radio_props={bleedingRadioProps}
initial={this.state.currentValue} initial={this.state.currentValue}
formHorizontal={true} formHorizontal={true}
labelHorizontal={false} labelHorizontal={false}
labelStyle={styles.radioButton}
onPress={(itemValue) => { onPress={(itemValue) => {
this.setState({currentValue: itemValue}) this.setState({currentValue: itemValue})
}} }}
/> />
<Text>Exclude</Text> </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 <Switch
onValueChange={(val) => { onValueChange={(val) => {
this.setState({exclude: val}) this.setState({exclude: val})
}} }}
value={this.state.exclude} /> 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 <Button
onPress={() => this.showView('dayView')} onPress={() => this.showView('dayView')}
title="Cancel"> title="Cancel">
</Button> </Button>
</View>
<View style={{flex: 1, margin: 5}}>
<Button <Button
onPress={() => { onPress={() => {
saveBleeding(this.cycleDay) saveBleeding(this.cycleDay)
this.showView('dayView') this.showView('dayView')
}} }}
title="Delete entry"> title="Delete">
</Button> </Button>
</View>
<View style={{flex: 1, margin: 5}}>
<Button <Button
onPress={() => { onPress={() => {
saveBleeding(this.cycleDay, { saveBleeding(this.cycleDay, {
@@ -73,6 +95,8 @@ export default class Bleeding extends Component {
title="Save"> title="Save">
</Button> </Button>
</View> </View>
</View>
</View>
) )
} }
} }
+23 -11
View File
@@ -39,32 +39,44 @@ export default class DayView extends Component {
const bleedingValue = this.cycleDay.bleeding && this.cycleDay.bleeding.value const bleedingValue = this.cycleDay.bleeding && this.cycleDay.bleeding.value
let bleedingLabel let bleedingLabel
if (typeof bleedingValue === 'number') { if (typeof bleedingValue === 'number') {
bleedingLabel = `Bleeding: ${labels[bleedingValue]}` bleedingLabel = `${labels[bleedingValue]}`
if (this.cycleDay.bleeding.exclude) bleedingLabel += " (Excluded)" if (this.cycleDay.bleeding.exclude) bleedingLabel = "( " + bleedingLabel + " )"
} else { } else {
bleedingLabel = null bleedingLabel = 'edit'
} }
const temperatureValue = this.cycleDay.temperature && this.cycleDay.temperature.value const temperatureValue = this.cycleDay.temperature && this.cycleDay.temperature.value
let temperatureLabel let temperatureLabel
if (typeof temperatureValue === 'number') { if (typeof temperatureValue === 'number') {
temperatureLabel = `Temperature: ${temperatureValue}` temperatureLabel = `${temperatureValue} °C`
if (this.cycleDay.temperature.exclude) temperatureLabel += " (Excluded)" if (this.cycleDay.temperature.exclude) temperatureLabel = "( " + temperatureLabel + " )"
} else { } else {
temperatureLabel = null temperatureLabel = 'edit'
} }
return ( return (
<View> <View style={{flex: 1, flexDirection: 'column', justifyContent: 'flex-start'}}>
<Text style={styles.welcome}>{bleedingLabel}</Text> <View style={{flexDirection: 'row', justifyContent: 'space-evenly', alignItems: 'center'}}>
<Text style={styles.welcome}>{temperatureLabel}</Text> <View style={{flex: 1}}>
<Text style={styles.symptomDayView}>Bleeding</Text>
</View>
<View style={{flex: 1, margin:5}}>
<Button <Button
onPress={() => this.showView('bleedingEditView')} onPress={() => this.showView('bleedingEditView')}
title="Edit bleeding"> title={bleedingLabel}>
</Button> </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 <Button
onPress={() => this.showView('temperatureEditView')} onPress={() => this.showView('temperatureEditView')}
title="Edit temperature"> title={temperatureLabel}>
</Button> </Button>
</View>
</View>
</View > </View >
) )
} }
+11 -4
View File
@@ -29,16 +29,23 @@ export default class Day extends Component {
render() { render() {
const cycleDayNumber = getCycleDayNumber(this.cycleDay.date) const cycleDayNumber = getCycleDayNumber(this.cycleDay.date)
return ( return (
<View style={styles.container}> <View style={{flex: 1, flexDirection: 'column', justifyContent: 'space-around'}}>
<Text style={styles.welcome}>{formatDateForViewHeader(this.cycleDay.date)}</Text> <View style={{flex: 2, justifyContent: 'center', backgroundColor: 'steelblue'}}>
{ cycleDayNumber && <Text>Cycle day {cycleDayNumber}</Text> } <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} />, { dayView: <DayView cycleDay={this.cycleDay} showView={this.showView} />,
bleedingEditView: <BleedingEditView cycleDay={this.cycleDay} showView={this.showView}/>, bleedingEditView: <BleedingEditView cycleDay={this.cycleDay} showView={this.showView}/>,
temperatureEditView: <TemperatureEditView cycleDay={this.cycleDay} showView={this.showView}/> temperatureEditView: <TemperatureEditView cycleDay={this.cycleDay} showView={this.showView}/>
}[this.state.visibleComponent] }[this.state.visibleComponent]
} }
</View >
</View > </View >
) )
} }
+13 -1
View File
@@ -46,21 +46,33 @@ export default class Home extends Component {
render() { render() {
const navigate = this.props.navigation.navigate const navigate = this.props.navigation.navigate
return ( return (
<View style={styles.container}> <View style={{flex: 0.5, flexDirection: 'column', justifyContent: 'space-around'}}>
<View style={{flex: 2}}>
<View>
<Text style={styles.welcome}>{this.state.welcomeText}</Text> <Text style={styles.welcome}>{this.state.welcomeText}</Text>
</View>
</View>
<View style={{flex: 3, flexDirection: 'column', justifyContent: 'space-around', margin: 5}}>
<View>
<Button <Button
onPress={() => this.passTodayToDayView()} onPress={() => this.passTodayToDayView()}
title="Edit symptoms for today"> title="Edit symptoms for today">
</Button> </Button>
</View>
<View>
<Button <Button
onPress={() => navigate('calendar')} onPress={() => navigate('calendar')}
title="Go to calendar"> title="Go to calendar">
</Button> </Button>
</View>
<View>
<Button <Button
onPress={() => deleteAll()} onPress={() => deleteAll()}
title="delete everything"> title="delete everything">
</Button> </Button>
</View> </View>
</View>
</View>
) )
} }
} }
+29 -2
View File
@@ -8,6 +8,33 @@ export default StyleSheet.create({
welcome: { welcome: {
fontSize: 20, fontSize: 20,
margin: 30, 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'
},
}) })
+27 -4
View File
@@ -8,6 +8,7 @@ import {
} from 'react-native' } from 'react-native'
import { saveTemperature, getPreviousTemperature } from './db' import { saveTemperature, getPreviousTemperature } from './db'
import styles from './styles'
export default class Temp extends Component { export default class Temp extends Component {
constructor(props) { constructor(props) {
@@ -32,8 +33,13 @@ export default class Temp extends Component {
render() { render() {
const cycleDay = this.cycleDay const cycleDay = this.cycleDay
return ( return (
<View> <View style={{flex: 1, flexDirection: 'column', justifyContent: 'space-between', alignItems: 'flex-start'}}>
<Text>Temperature</Text> <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 <TextInput
placeholder="Enter temperature" placeholder="Enter temperature"
onChangeText={(val) => { onChangeText={(val) => {
@@ -42,26 +48,41 @@ export default class Temp extends Component {
keyboardType='numeric' keyboardType='numeric'
value = {this.state.currentValue} value = {this.state.currentValue}
/> />
<Text>Exclude</Text> </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 <Switch
onValueChange = {(val) => { onValueChange = {(val) => {
this.setState({ exclude: val }) this.setState({ exclude: val })
}} }}
value = { this.state.exclude } 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 <Button
onPress={() => { onPress={() => {
this.showView('dayView') this.showView('dayView')
}} }}
title="Cancel"> title="Cancel">
</Button> </Button>
</View>
<View style={{flex: 1, margin: 5}}>
<Button <Button
onPress={() => { onPress={() => {
saveTemperature(cycleDay) saveTemperature(cycleDay)
this.showView('dayView') this.showView('dayView')
}} }}
title="Delete entry"> title="Delete">
</Button> </Button>
</View>
<View style={{flex: 1, margin: 5}}>
<Button <Button
onPress={() => { onPress={() => {
saveTemperature(cycleDay, { saveTemperature(cycleDay, {
@@ -74,6 +95,8 @@ export default class Temp extends Component {
title="Save"> title="Save">
</Button> </Button>
</View> </View>
</View>
</View>
) )
} }
} }