Make saving incomplete value possible

This commit is contained in:
Julia Friesel
2019-05-11 14:30:27 +02:00
parent ca68186351
commit 9fd17d769e
3 changed files with 7 additions and 31 deletions
@@ -1,7 +1,6 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { import {
View, TouchableOpacity, Text, Alert, ToastAndroid 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'
@@ -15,7 +14,6 @@ export default class ActionButtonFooter extends Component {
currentSymptomValue, currentSymptomValue,
date, date,
saveAction, saveAction,
saveDisabled,
navigate, navigate,
autoShowDayView = true} autoShowDayView = true}
= this.props = this.props
@@ -47,40 +45,24 @@ export default class ActionButtonFooter extends Component {
}, { }, {
title: labels.save, title: labels.save,
action: () => { action: () => {
if(saveDisabled) { saveAction()
ToastAndroid.show(labels.disabledInfo, ToastAndroid.LONG) if (autoShowDayView) navigateToOverView()
} else {
saveAction()
if (autoShowDayView) navigateToOverView()
}
}, },
disabledCondition: saveDisabled,
icon: 'content-save-outline' icon: 'content-save-outline'
} }
] ]
return ( return (
<View style={styles.actionButtonFooter}> <View style={styles.menu}>
{buttons.map(({ title, action, disabledCondition, icon }, i) => { {buttons.map(({ title, action, icon }, i) => {
const textStyle = [styles.menuText] const textStyle = [styles.menuText]
if (disabledCondition) {
textStyle.push(styles.menuTextInActive)
}
const iconStyle = disabledCondition ?
Object.assign(
{},
iconStyles.menuIcon,
iconStyles.menuIconInactive
)
:
iconStyles.menuIcon
return ( return (
<TouchableOpacity <TouchableOpacity
onPress={action} onPress={action}
style={styles.actionButtonItem} style={styles.actionButtonItem}
key={i.toString()} key={i.toString()}
> >
<Icon name={icon} {...iconStyle} /> <Icon name={icon} {...iconStyles.menuIcon} />
<Text style={textStyle}> <Text style={textStyle}>
{title.toLowerCase()} {title.toLowerCase()}
</Text> </Text>
+1 -4
View File
@@ -10,7 +10,6 @@ import { cervix as labels } from '../../../i18n/en/cycle-day'
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 { ActionHint } from '../../app-text'
export default class Cervix extends Component { export default class Cervix extends Component {
constructor(props) { constructor(props) {
@@ -36,7 +35,7 @@ export default class Cervix extends Component {
{ label: labels.position.categories[1], value: 1 }, { label: labels.position.categories[1], value: 1 },
{ label: labels.position.categories[2], value: 2 } { label: labels.position.categories[2], value: 2 }
] ]
const mandatoryNotCompletedYet = typeof this.state.opening != 'number' || typeof this.state.firmness != 'number' const mandatoryNotCompleted = typeof this.state.opening != 'number' || typeof this.state.firmness != 'number'
return ( return (
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
@@ -83,7 +82,6 @@ export default class Cervix extends Component {
/> />
</SymptomSection> </SymptomSection>
</ScrollView> </ScrollView>
<ActionHint isVisible={mandatoryNotCompletedYet}>{labels.actionHint}</ActionHint>
<ActionButtonFooter <ActionButtonFooter
symptom='cervix' symptom='cervix'
date={this.props.date} date={this.props.date}
@@ -96,7 +94,6 @@ export default class Cervix extends Component {
exclude: Boolean(this.state.exclude) exclude: Boolean(this.state.exclude)
}) })
}} }}
saveDisabled={mandatoryNotCompletedYet}
navigate={this.props.navigate} navigate={this.props.navigate}
/> />
</View> </View>
-3
View File
@@ -11,7 +11,6 @@ import computeNfpValue from '../../../lib/nfp-mucus'
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 { ActionHint } from '../../app-text'
export default class Mucus extends Component { export default class Mucus extends Component {
constructor(props) { constructor(props) {
@@ -71,7 +70,6 @@ export default class Mucus extends Component {
/> />
</SymptomSection> </SymptomSection>
</ScrollView> </ScrollView>
<ActionHint isVisible={mandatoryNotCompletedYet}>{labels.actionHint}</ActionHint>
<ActionButtonFooter <ActionButtonFooter
symptom='mucus' symptom='mucus'
date={this.props.date} date={this.props.date}
@@ -86,7 +84,6 @@ export default class Mucus extends Component {
exclude: Boolean(this.state.exclude) exclude: Boolean(this.state.exclude)
}) })
}} }}
saveDisabled={mandatoryNotCompletedYet}
navigate={this.props.navigate} navigate={this.props.navigate}
/> />
</View> </View>