Skip to content
Snippets Groups Projects
Commit 180a25cd authored by Julia Friesel's avatar Julia Friesel
Browse files

Turn symptom buttons into footer component

parent fb002236
No related branches found
No related tags found
No related merge requests found
import React, { Component } from 'react'
import {
View,
Button,
} from 'react-native'
import { saveSymptom } from '../../../db'
import styles from '../../../styles'
export default class ActionButtonFooter extends Component {
render() {
const { symptom, cycleDay, saveAction, saveDisabled, navigate} = this.props
const navigateToOverView = () => navigate('CycleDay', cycleDay)
const buttons = [
{
title: 'Cancel',
action: () => navigateToOverView()
},
{
title: 'Delete',
action: () => {
saveSymptom(symptom, cycleDay)
navigateToOverView()
},
disabledCondition: !cycleDay[symptom]
}, {
title: 'Save',
action: () => {
saveAction()
navigateToOverView()
},
disabledCondition: saveDisabled
}
]
return (
<View style={styles.actionButtonRow}>
{buttons.map(({ title, action, disabledCondition }, i) => {
const style = { flex: 1, marginHorizontal: 10 }
if (i === 0) style.marginLeft = 0
if (i === buttons.length - 1) style.marginRight = 0
return (
<View style={style} key={i}>
<Button
onPress={action}
disabled={disabledCondition}
title={title}>
</Button>
</View >
)
})}
</View>
)
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment