Refactors the header

This commit is contained in:
Sofiya Tepikin
2019-09-14 12:39:30 +02:00
parent 20595c6c3a
commit 5d436630d3
15 changed files with 175 additions and 195 deletions
+26 -5
View File
@@ -6,8 +6,9 @@ import { connect } from 'react-redux'
import { getDate } from '../../../slices/date'
import { saveSymptom } from '../../../db'
import formatDate from '../../helpers/format-date'
import Header from '../../header/symptom-view'
import Header from '../../header'
import SymptomInfo from './symptom-info'
import { headerTitles } from '../../../i18n/en/labels'
@@ -80,16 +81,36 @@ class SymptomView extends Component {
)
}
showConfirmationAlert = () => {
const cancelButton = {
text: sharedDialogs.cancel,
style: 'cancel'
}
const confirmationButton = {
text: sharedDialogs.reallyDeleteData,
onPress: this.onDeleteConfirmation
}
return Alert.alert(
sharedDialogs.areYouSureTitle,
sharedDialogs.areYouSureToDelete,
[cancelButton, confirmationButton]
)
}
render() {
const { symptom } = this.props
return (
<View style={{flex: 1}}>
<Header
title={headerTitles[symptom].toLowerCase()}
date={this.date}
goBack={this.props.handleBackButtonPress}
shouldShowDelete={this.state.shouldShowDelete}
onDelete={this.showConfirmationAlert}
subtitle={formatDate(this.date)}
handleBack={this.props.handleBackButtonPress}
handleDelete={
this.state.shouldShowDelete && this.showConfirmationAlert
}
/>
<View flex={1}>
<ScrollView style={styles.page}>