solves the action footer, but messes up the header

This commit is contained in:
tina
2018-09-26 18:16:29 +02:00
parent e5052bf088
commit c06bfa2c91
9 changed files with 74 additions and 42 deletions
+4 -1
View File
@@ -56,7 +56,10 @@ export default class App extends Component {
return ( return (
<View style={{flex: 1}}> <View style={{flex: 1}}>
{this.state.currentPage != 'CycleDay' && <Header title={titles[this.state.currentPage]} />} {this.state.currentPage != 'CycleDay' && !isSymptomView(this.state.currentPage) &&
<Header
title={titles[this.state.currentPage]}
/>}
{React.createElement(page, { {React.createElement(page, {
navigate: this.navigate, navigate: this.navigate,
+9
View File
@@ -84,3 +84,12 @@ export const temperature = {
} }
export const noteExplainer = "Anything you want to add for the day?" export const noteExplainer = "Anything you want to add for the day?"
export const sharedDialogs = {
cancel: 'Cancel',
areYouSureTitle: 'Are you sure?',
areYouSureToUnset: 'Are you sure you want to unset all entered data?',
reallyUnsetData: 'Yes, I am sure',
save: 'Save',
unset: 'Unset'
}
+1 -7
View File
@@ -23,13 +23,7 @@ export default class SelectTabGroup extends Component {
if (isActive) activeStyle = styles.selectTabActive if (isActive) activeStyle = styles.selectTabActive
return ( return (
<TouchableOpacity <TouchableOpacity
onPress={() => { onPress={() => isActive ? this.props.onSelect(null) : this.props.onSelect(value)}
if (this.props.isRadioButton) {
this.props.onSelect(value)
} else {
isActive ? this.props.onSelect(null) : this.props.onSelect(value)
}
}}
key={i} key={i}
activeOpacity={1} activeOpacity={1}
> >
@@ -1,10 +1,11 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { import {
View, TouchableOpacity, Text View, TouchableOpacity, Text, Alert
} from 'react-native' } from 'react-native'
import Icon from 'react-native-vector-icons/MaterialCommunityIcons' import Icon from 'react-native-vector-icons/MaterialCommunityIcons'
import { saveSymptom } from '../../../db' import { saveSymptom } from '../../../db'
import styles, {iconStyles} from '../../../styles' import styles, {iconStyles} from '../../../styles'
import {sharedDialogs as labels} from '../labels/labels'
export default class ActionButtonFooter extends Component { export default class ActionButtonFooter extends Component {
render() { render() {
@@ -17,33 +18,29 @@ export default class ActionButtonFooter extends Component {
autoShowDayView = true} autoShowDayView = true}
= this.props = this.props
const navigateToOverView = () => navigate('CycleDay', {cycleDay}) const navigateToOverView = () => navigate('CycleDay', {cycleDay})
const buttonsNewEntry = [ const buttons = [
{ {
title: 'Cancel', title: labels.unset,
action: () => navigateToOverView(),
icon: 'cancel'
},
{
title: 'Add',
action: () => { action: () => {
saveAction() Alert.alert(
if (autoShowDayView) navigateToOverView() labels.areYouSureTitle,
}, labels.areYouSureToUnset,
disabledCondition: saveDisabled, [{
icon: 'content-save-outline' text: labels.cancel,
} style: 'cancel'
] }, {
const buttonsEdit = [ text: labels.reallyUnsetData,
{ onPress: () => {
title: 'Delete', saveSymptom(symptom, cycleDay)
action: () => { navigateToOverView()
saveSymptom(symptom, cycleDay) }
navigateToOverView() }]
)
}, },
disabledCondition: !cycleDay[symptom], disabledCondition: !cycleDay[symptom],
icon: 'delete-outline' icon: 'delete-outline'
}, { }, {
title: 'Save', title: labels.save,
action: () => { action: () => {
saveAction() saveAction()
if (autoShowDayView) navigateToOverView() if (autoShowDayView) navigateToOverView()
@@ -52,7 +49,6 @@ export default class ActionButtonFooter extends Component {
icon: 'content-save-outline' icon: 'content-save-outline'
} }
] ]
const buttons = !cycleDay[symptom] ? buttonsNewEntry : buttonsEdit
return ( return (
<View style={styles.menu}> <View style={styles.menu}>
+10 -1
View File
@@ -10,6 +10,7 @@ import { bleeding as labels } from '../labels/labels'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import SelectTabGroup from '../select-tab-group' import SelectTabGroup from '../select-tab-group'
import SymptomSection from './symptom-section' import SymptomSection from './symptom-section'
import Header from '../../header'
export default class Bleeding extends Component { export default class Bleeding extends Component {
constructor(props) { constructor(props) {
@@ -31,6 +32,15 @@ export default class Bleeding extends Component {
] ]
return ( return (
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<Header
title={'Bleeding'}
isSymptomView={true}
goBack={() => this.props.navigate('CycleDay', this.props.cycleDay)}
cycleDayNumber={this.props.cycleDayNumber}
date={this.props.cycleDay.date}
infoTitle={'Info here'}
infoText={'bla bla'}
/>
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<SymptomSection <SymptomSection
header="Heaviness" header="Heaviness"
@@ -40,7 +50,6 @@ export default class Bleeding extends Component {
buttons={bleedingRadioProps} buttons={bleedingRadioProps}
active={this.state.currentValue} active={this.state.currentValue}
onSelect={val => this.setState({ currentValue: val })} onSelect={val => this.setState({ currentValue: val })}
isRadioButton={true}
/> />
</SymptomSection> </SymptomSection>
<SymptomSection <SymptomSection
-3
View File
@@ -50,7 +50,6 @@ export default class Cervix extends Component {
buttons={cervixOpeningRadioProps} buttons={cervixOpeningRadioProps}
active={this.state.opening} active={this.state.opening}
onSelect={val => this.setState({ opening: val })} onSelect={val => this.setState({ opening: val })}
isRadioButton={true}
/> />
</SymptomSection> </SymptomSection>
<SymptomSection <SymptomSection
@@ -61,7 +60,6 @@ export default class Cervix extends Component {
buttons={cervixFirmnessRadioProps} buttons={cervixFirmnessRadioProps}
active={this.state.firmness} active={this.state.firmness}
onSelect={val => this.setState({ firmness: val })} onSelect={val => this.setState({ firmness: val })}
isRadioButton={true}
/> />
</SymptomSection> </SymptomSection>
<SymptomSection <SymptomSection
@@ -72,7 +70,6 @@ export default class Cervix extends Component {
buttons={cervixPositionRadioProps} buttons={cervixPositionRadioProps}
active={this.state.position} active={this.state.position}
onSelect={val => this.setState({ position: val })} onSelect={val => this.setState({ position: val })}
isRadioButton={false}
/> />
</SymptomSection> </SymptomSection>
<SymptomSection <SymptomSection
-1
View File
@@ -36,7 +36,6 @@ export default class Desire extends Component {
buttons={desireRadioProps} buttons={desireRadioProps}
active={this.state.currentValue} active={this.state.currentValue}
onSelect={val => this.setState({ currentValue: val })} onSelect={val => this.setState({ currentValue: val })}
isRadioButton={true}
/> />
</SymptomSection> </SymptomSection>
</ScrollView> </ScrollView>
+28 -6
View File
@@ -7,8 +7,10 @@ import styles, { iconStyles } from '../styles'
import Icon from 'react-native-vector-icons/MaterialCommunityIcons' import Icon from 'react-native-vector-icons/MaterialCommunityIcons'
import { formatDateForViewHeader } from '../components/cycle-day/labels/format' import { formatDateForViewHeader } from '../components/cycle-day/labels/format'
export default class Header extends Component { export default class Header extends Component {
render() { render() {
console.log(this.props)
return ( return (
this.props.isCycleDayOverView ? this.props.isCycleDayOverView ?
<View style={[styles.header, styles.headerCycleDay]}> <View style={[styles.header, styles.headerCycleDay]}>
@@ -32,12 +34,32 @@ export default class Header extends Component {
onPress={() => this.props.goToCycleDay('after')} onPress={() => this.props.goToCycleDay('after')}
/> />
</View > </View >
: : this.props.isSymptomView ?
<View style={styles.header}> <View style={[styles.header, styles.headerCycleDay]}>
<Text style={styles.dateHeader}> <Icon
{this.props.title} name='arrow-left-drop-circle'
</Text> {...iconStyles.navigationArrow}
</View > onPress={() => this.props.goBack()}
/>
<View>
<Text style={styles.dateHeader}>
{this.props.title}
</Text>
<Text style={styles.cycleDayNumber} >
{formatDateForViewHeader(this.props.date)}
</Text>
</View >
<Icon
name='information-outline'
{...iconStyles.navigationArrow}
/>
</View>
:
<View style={styles.header}>
<Text style={styles.dateHeader}>
{this.props.title}
</Text>
</View >
) )
} }
} }
+3
View File
@@ -132,6 +132,9 @@ export default StyleSheet.create({
justifyContent: 'space-between', justifyContent: 'space-between',
height: '15%' height: '15%'
}, },
headerSymptom: {
height: '15%'
},
navigationArrow: { navigationArrow: {
fontSize: 60, fontSize: 60,
color: fontOnPrimaryColor color: fontOnPrimaryColor