Clean up line lengths in calendar
This commit is contained in:
+14
-8
@@ -1,27 +1,29 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { View } from 'react-native'
|
import { View } from 'react-native'
|
||||||
import { Calendar } from 'react-native-calendars'
|
import { Calendar } from 'react-native-calendars'
|
||||||
import * as styles from '../styles/index'
|
import * as styles from '../styles'
|
||||||
import { getOrCreateCycleDay, bleedingDaysSortedByDate } from '../db'
|
import { getOrCreateCycleDay, bleedingDaysSortedByDate } from '../db'
|
||||||
|
|
||||||
export default class CalendarView extends Component {
|
export default class CalendarView extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = { bleedingDaysInCalFormat: getBleedingDaysInCalFormat(bleedingDaysSortedByDate) }
|
this.state = {
|
||||||
|
bleedingDaysInCalFormat: toCalFormat(bleedingDaysSortedByDate)
|
||||||
|
}
|
||||||
|
|
||||||
this.setStateWithCalendarFormattedDays = (function (CalendarComponent) {
|
this.setStateWithCalFormattedDays = (function (CalendarComponent) {
|
||||||
return function() {
|
return function() {
|
||||||
CalendarComponent.setState({
|
CalendarComponent.setState({
|
||||||
bleedingDaysInCalFormat: getBleedingDaysInCalFormat(bleedingDaysSortedByDate)
|
bleedingDaysInCalFormat: toCalFormat(bleedingDaysSortedByDate)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})(this)
|
})(this)
|
||||||
|
|
||||||
bleedingDaysSortedByDate.addListener(this.setStateWithCalendarFormattedDays)
|
bleedingDaysSortedByDate.addListener(this.setStateWithCalFormattedDays)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
bleedingDaysSortedByDate.removeListener(this.setStateWithCalendarFormattedDays)
|
bleedingDaysSortedByDate.removeListener(this.setStateWithCalFormattedDays)
|
||||||
}
|
}
|
||||||
|
|
||||||
passDateToDayView(result) {
|
passDateToDayView(result) {
|
||||||
@@ -43,10 +45,14 @@ export default class CalendarView extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBleedingDaysInCalFormat(bleedingDaysSortedByDate) {
|
function toCalFormat(bleedingDaysSortedByDate) {
|
||||||
const shadesOfRed = ['#ffbaba', '#ff7b7b', '#ff5252', '#ff0000']
|
const shadesOfRed = ['#ffbaba', '#ff7b7b', '#ff5252', '#ff0000']
|
||||||
return bleedingDaysSortedByDate.reduce((acc, day) => {
|
return bleedingDaysSortedByDate.reduce((acc, day) => {
|
||||||
acc[day.date] = { startingDay: true, endingDay: true, color: shadesOfRed[day.bleeding.value] }
|
acc[day.date] = {
|
||||||
|
startingDay: true,
|
||||||
|
endingDay: true,
|
||||||
|
color: shadesOfRed[day.bleeding.value]
|
||||||
|
}
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user