reduces footer actions to save, leaving no possibility to delete data once it was saved
This commit is contained in:
@@ -3,13 +3,11 @@ import {
|
|||||||
View, TouchableOpacity, Text
|
View, TouchableOpacity, Text
|
||||||
} 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 styles, {iconStyles} from '../../../styles'
|
import styles, {iconStyles} from '../../../styles'
|
||||||
|
|
||||||
export default class ActionButtonFooter extends Component {
|
export default class ActionButtonFooter extends Component {
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
symptom,
|
|
||||||
cycleDay,
|
cycleDay,
|
||||||
saveAction,
|
saveAction,
|
||||||
saveDisabled,
|
saveDisabled,
|
||||||
@@ -17,53 +15,33 @@ 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 buttons = [
|
const saveButton = {
|
||||||
{
|
title: 'Save',
|
||||||
title: 'Cancel',
|
action: () => {
|
||||||
action: () => navigateToOverView(),
|
saveAction()
|
||||||
icon: 'cancel'
|
if (autoShowDayView) navigateToOverView()
|
||||||
},
|
},
|
||||||
{
|
disabledCondition: saveDisabled,
|
||||||
title: 'Delete',
|
icon: 'content-save-outline'
|
||||||
action: () => {
|
}
|
||||||
saveSymptom(symptom, cycleDay)
|
const textStyle = saveButton.disabledCondition ? styles.menuTextInActive : styles.menuText
|
||||||
navigateToOverView()
|
const iconStyle = saveButton.disabledCondition ?
|
||||||
},
|
Object.assign({}, iconStyles.menuIcon, iconStyles.menuIconInactive) :
|
||||||
disabledCondition: !cycleDay[symptom],
|
iconStyles.menuIcon
|
||||||
icon: 'delete-outline'
|
|
||||||
}, {
|
|
||||||
title: 'Save',
|
|
||||||
action: () => {
|
|
||||||
saveAction()
|
|
||||||
if (autoShowDayView) navigateToOverView()
|
|
||||||
},
|
|
||||||
disabledCondition: saveDisabled,
|
|
||||||
icon: 'content-save-outline'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.menu}>
|
<View style={styles.menu}>
|
||||||
{buttons.map(({ title, action, disabledCondition, icon }, i) => {
|
<TouchableOpacity
|
||||||
const textStyle = disabledCondition ? styles.menuTextInActive : styles.menuText
|
onPress={saveButton.action}
|
||||||
const iconStyle = disabledCondition ?
|
style={styles.menuItem}
|
||||||
Object.assign({}, iconStyles.menuIcon, iconStyles.menuIconInactive) :
|
disabled={saveButton.disabledCondition}
|
||||||
iconStyles.menuIcon
|
key={'save'}
|
||||||
|
>
|
||||||
return (
|
<Icon name={saveButton.icon} {...iconStyle} />
|
||||||
<TouchableOpacity
|
<Text style={textStyle}>
|
||||||
onPress={action}
|
{saveButton.title}
|
||||||
style={styles.menuItem}
|
</Text>
|
||||||
disabled={disabledCondition}
|
</TouchableOpacity>
|
||||||
key={i.toString()}
|
|
||||||
>
|
|
||||||
<Icon name={icon} {...iconStyle} />
|
|
||||||
<Text style={textStyle}>
|
|
||||||
{title}
|
|
||||||
</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ export default class Bleeding extends Component {
|
|||||||
</SymptomSection>
|
</SymptomSection>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<ActionButtonFooter
|
<ActionButtonFooter
|
||||||
symptom='bleeding'
|
|
||||||
cycleDay={this.props.cycleDay}
|
cycleDay={this.props.cycleDay}
|
||||||
saveAction={() => {
|
saveAction={() => {
|
||||||
saveSymptom('bleeding', this.props.cycleDay, {
|
saveSymptom('bleeding', this.props.cycleDay, {
|
||||||
|
|||||||
Reference in New Issue
Block a user