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
|
||||
} from 'react-native'
|
||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'
|
||||
import { saveSymptom } from '../../../db'
|
||||
import styles, {iconStyles} from '../../../styles'
|
||||
|
||||
export default class ActionButtonFooter extends Component {
|
||||
render() {
|
||||
const {
|
||||
symptom,
|
||||
cycleDay,
|
||||
saveAction,
|
||||
saveDisabled,
|
||||
@@ -17,53 +15,33 @@ export default class ActionButtonFooter extends Component {
|
||||
autoShowDayView = true}
|
||||
= this.props
|
||||
const navigateToOverView = () => navigate('CycleDay', {cycleDay})
|
||||
const buttons = [
|
||||
{
|
||||
title: 'Cancel',
|
||||
action: () => navigateToOverView(),
|
||||
icon: 'cancel'
|
||||
const saveButton = {
|
||||
title: 'Save',
|
||||
action: () => {
|
||||
saveAction()
|
||||
if (autoShowDayView) navigateToOverView()
|
||||
},
|
||||
{
|
||||
title: 'Delete',
|
||||
action: () => {
|
||||
saveSymptom(symptom, cycleDay)
|
||||
navigateToOverView()
|
||||
},
|
||||
disabledCondition: !cycleDay[symptom],
|
||||
icon: 'delete-outline'
|
||||
}, {
|
||||
title: 'Save',
|
||||
action: () => {
|
||||
saveAction()
|
||||
if (autoShowDayView) navigateToOverView()
|
||||
},
|
||||
disabledCondition: saveDisabled,
|
||||
icon: 'content-save-outline'
|
||||
}
|
||||
]
|
||||
disabledCondition: saveDisabled,
|
||||
icon: 'content-save-outline'
|
||||
}
|
||||
const textStyle = saveButton.disabledCondition ? styles.menuTextInActive : styles.menuText
|
||||
const iconStyle = saveButton.disabledCondition ?
|
||||
Object.assign({}, iconStyles.menuIcon, iconStyles.menuIconInactive) :
|
||||
iconStyles.menuIcon
|
||||
|
||||
return (
|
||||
<View style={styles.menu}>
|
||||
{buttons.map(({ title, action, disabledCondition, icon }, i) => {
|
||||
const textStyle = disabledCondition ? styles.menuTextInActive : styles.menuText
|
||||
const iconStyle = disabledCondition ?
|
||||
Object.assign({}, iconStyles.menuIcon, iconStyles.menuIconInactive) :
|
||||
iconStyles.menuIcon
|
||||
|
||||
return (
|
||||
<TouchableOpacity
|
||||
onPress={action}
|
||||
style={styles.menuItem}
|
||||
disabled={disabledCondition}
|
||||
key={i.toString()}
|
||||
>
|
||||
<Icon name={icon} {...iconStyle} />
|
||||
<Text style={textStyle}>
|
||||
{title}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
)
|
||||
})}
|
||||
<TouchableOpacity
|
||||
onPress={saveButton.action}
|
||||
style={styles.menuItem}
|
||||
disabled={saveButton.disabledCondition}
|
||||
key={'save'}
|
||||
>
|
||||
<Icon name={saveButton.icon} {...iconStyle} />
|
||||
<Text style={textStyle}>
|
||||
{saveButton.title}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user