add date to symptom screen header
This commit is contained in:
@@ -81,6 +81,7 @@ export default class App extends Component {
|
|||||||
title={headerTitlesLowerCase[this.state.currentPage]}
|
title={headerTitlesLowerCase[this.state.currentPage]}
|
||||||
isSymptomView={true}
|
isSymptomView={true}
|
||||||
goBack={this.handleBackButtonPress}
|
goBack={this.handleBackButtonPress}
|
||||||
|
date={this.state.currentProps.date}
|
||||||
/>}
|
/>}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,9 @@ import React from 'react'
|
|||||||
import {
|
import {
|
||||||
View,
|
View,
|
||||||
Text} from 'react-native'
|
Text} from 'react-native'
|
||||||
import { LocalDate } from 'js-joda'
|
|
||||||
import moment from 'moment'
|
|
||||||
import styles from '../../styles'
|
import styles from '../../styles'
|
||||||
import NavigationArrow from './navigation-arrow'
|
import NavigationArrow from './navigation-arrow'
|
||||||
|
import formatDate from '../helpers/format-date'
|
||||||
const FormattedDate = ({ date }) => {
|
|
||||||
const today = LocalDate.now()
|
|
||||||
const dateToDisplay = LocalDate.parse(date)
|
|
||||||
const formattedDate = today.equals(dateToDisplay) ? 'today' : moment(date).format('MMMM Do YYYY')
|
|
||||||
return formattedDate.toLowerCase()
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function CycleDayHeader({ date, ...props }) {
|
export default function CycleDayHeader({ date, ...props }) {
|
||||||
return (<View style={[styles.header, styles.headerCycleDay]}>
|
return (<View style={[styles.header, styles.headerCycleDay]}>
|
||||||
@@ -23,7 +15,7 @@ export default function CycleDayHeader({ date, ...props }) {
|
|||||||
<NavigationArrow direction='left' {...props}/>
|
<NavigationArrow direction='left' {...props}/>
|
||||||
<View>
|
<View>
|
||||||
<Text style={styles.dateHeader}>
|
<Text style={styles.dateHeader}>
|
||||||
<FormattedDate date={date} />
|
{formatDate(date)}
|
||||||
</Text>
|
</Text>
|
||||||
{props.cycleDayNumber &&
|
{props.cycleDayNumber &&
|
||||||
<Text style={styles.cycleDayNumber}>
|
<Text style={styles.cycleDayNumber}>
|
||||||
@@ -33,4 +25,4 @@ export default function CycleDayHeader({ date, ...props }) {
|
|||||||
<NavigationArrow direction='right' {...props}/>
|
<NavigationArrow direction='right' {...props}/>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
import styles, { iconStyles } from '../../styles'
|
import styles, { iconStyles } from '../../styles'
|
||||||
import FeatherIcon from 'react-native-vector-icons/Feather'
|
import FeatherIcon from 'react-native-vector-icons/Feather'
|
||||||
import NavigationArrow from './navigation-arrow'
|
import NavigationArrow from './navigation-arrow'
|
||||||
|
import formatDate from '../helpers/format-date'
|
||||||
|
|
||||||
export default function SymptomViewHeader(props) {
|
export default function SymptomViewHeader(props) {
|
||||||
return (
|
return (
|
||||||
@@ -19,6 +20,9 @@ export default function SymptomViewHeader(props) {
|
|||||||
/>
|
/>
|
||||||
<View>
|
<View>
|
||||||
<Text style={styles.dateHeader}>
|
<Text style={styles.dateHeader}>
|
||||||
|
{formatDate(props.date)}
|
||||||
|
</Text>
|
||||||
|
<Text style={styles.cycleDayNumber}>
|
||||||
{props.title}
|
{props.title}
|
||||||
</Text>
|
</Text>
|
||||||
</View >
|
</View >
|
||||||
@@ -29,4 +33,4 @@ export default function SymptomViewHeader(props) {
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { LocalDate } from 'js-joda'
|
||||||
|
import moment from 'moment'
|
||||||
|
|
||||||
|
export default function (date) {
|
||||||
|
const today = LocalDate.now()
|
||||||
|
const dateToDisplay = LocalDate.parse(date)
|
||||||
|
const formattedDate = today.equals(dateToDisplay) ? 'today' : moment(date).format('MMMM Do YYYY')
|
||||||
|
return formattedDate.toLowerCase()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user