Simplify markup and move symptom screens to symptom dir

This commit is contained in:
Julia Friesel
2018-07-15 22:36:06 +02:00
parent 9eb1ad6af1
commit eba5837350
9 changed files with 268 additions and 371 deletions
+46
View File
@@ -0,0 +1,46 @@
import React from 'react'
import {
View,
Button,
} from 'react-native'
import { saveSymptom } from '../../db'
export default function (showView) {
return function ({ symptom, cycleDay, saveAction, saveDisabled}) {
const buttons = [
{
title: 'Cancel',
action: () => showView('dayView')
},
{
title: 'Delete',
action: () => {
saveSymptom(symptom, cycleDay)
showView('dayView')
}
}, {
title: 'Save',
action: () => {
saveAction()
showView('dayView')
},
disabled: saveDisabled
}
]
return 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 >
)
})
}
}