Revert "Merge branch 'chore/cleanup-date-usage' into 'main'"
This reverts merge request !492
This commit is contained in:
@@ -5,33 +5,31 @@ import { StyleSheet, TouchableOpacity, View } from 'react-native'
|
||||
import AppIcon from '../common/app-icon'
|
||||
import AppText from '../common/app-text'
|
||||
|
||||
import cycleModule from '../../lib/cycle'
|
||||
import { dateToTitle } from '../helpers/format-date'
|
||||
import { connect } from 'react-redux'
|
||||
import { getDate, setDate } from '../../slices/date'
|
||||
|
||||
import { general as labels } from '../../i18n/en/cycle-day'
|
||||
import { nextDate, prevDate } from '../helpers/cycle-day'
|
||||
import { Colors, Containers, Spacing, Typography } from '../../styles'
|
||||
import { HIT_SLOP } from '../../config'
|
||||
|
||||
const SymptomPageTitle = ({ date, onNextCycleDay, onPrevCycleDay }) => {
|
||||
const title = dateToTitle(date)
|
||||
|
||||
const { getCycleDayNumber } = cycleModule()
|
||||
const cycleDayNumber = getCycleDayNumber(date)
|
||||
const subtitle = cycleDayNumber && `${labels.cycleDayNumber}${cycleDayNumber}`
|
||||
|
||||
const SymptomPageTitle = ({ date, setDate, subtitle, title }) => {
|
||||
const navigate = (isForward) => {
|
||||
const newDate = isForward ? nextDate(date) : prevDate(date)
|
||||
setDate(newDate)
|
||||
}
|
||||
const formattedTitle =
|
||||
title.length > 21 ? title.substring(0, 18) + '...' : title
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<TouchableOpacity onPress={onPrevCycleDay} hitSlop={HIT_SLOP}>
|
||||
<TouchableOpacity onPress={() => navigate(false)} hitSlop={HIT_SLOP}>
|
||||
<AppIcon name="chevron-left" color={Colors.orange} />
|
||||
</TouchableOpacity>
|
||||
<View style={styles.textContainer}>
|
||||
<AppText style={styles.title}>{formattedTitle}</AppText>
|
||||
{subtitle && <AppText style={styles.subtitle}>{subtitle}</AppText>}
|
||||
</View>
|
||||
<TouchableOpacity onPress={onNextCycleDay} hitSlop={HIT_SLOP}>
|
||||
<TouchableOpacity onPress={() => navigate(true)} hitSlop={HIT_SLOP}>
|
||||
<AppIcon name="chevron-right" color={Colors.orange} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
@@ -40,8 +38,9 @@ const SymptomPageTitle = ({ date, onNextCycleDay, onPrevCycleDay }) => {
|
||||
|
||||
SymptomPageTitle.propTypes = {
|
||||
date: PropTypes.string.isRequired,
|
||||
onNextCycleDay: PropTypes.func.isRequired,
|
||||
onPrevCycleDay: PropTypes.func.isRequired,
|
||||
setDate: PropTypes.func.isRequired,
|
||||
subtitle: PropTypes.string,
|
||||
title: PropTypes.string,
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
@@ -59,4 +58,16 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
})
|
||||
|
||||
export default SymptomPageTitle
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
date: getDate(state),
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
setDate: (date) => dispatch(setDate(date)),
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(SymptomPageTitle)
|
||||
|
||||
Reference in New Issue
Block a user