Remove sex from chart if not enabled
This commit is contained in:
@@ -13,7 +13,11 @@ import Tutorial from './Tutorial'
|
|||||||
import YAxis from './y-axis'
|
import YAxis from './y-axis'
|
||||||
|
|
||||||
import { getCycleDaysSortedByDate } from '../../db'
|
import { getCycleDaysSortedByDate } from '../../db'
|
||||||
import { getChartFlag, setChartFlag } from '../../local-storage'
|
import {
|
||||||
|
getChartFlag,
|
||||||
|
setChartFlag,
|
||||||
|
sexTrackingCategoryObservable,
|
||||||
|
} from '../../local-storage'
|
||||||
import { makeColumnInfo } from '../helpers/chart'
|
import { makeColumnInfo } from '../helpers/chart'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -60,6 +64,16 @@ const CycleChart = ({ navigate, setDate }) => {
|
|||||||
(symptom) => symptom !== 'temperature'
|
(symptom) => symptom !== 'temperature'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const symptomRowEnabledSymptoms = symptomRowSymptoms.filter((symptom) => {
|
||||||
|
if (symptom === 'sex') {
|
||||||
|
if (sexTrackingCategoryObservable.value) {
|
||||||
|
return symptom
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return symptom
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const shouldShowTemperatureColumn = chartSymptoms.indexOf('temperature') > -1
|
const shouldShowTemperatureColumn = chartSymptoms.indexOf('temperature') > -1
|
||||||
|
|
||||||
const { width, height } = Dimensions.get('window')
|
const { width, height } = Dimensions.get('window')
|
||||||
@@ -71,8 +85,9 @@ const CycleChart = ({ navigate, setDate }) => {
|
|||||||
remainingHeight * CHART_SYMPTOM_HEIGHT_RATIO
|
remainingHeight * CHART_SYMPTOM_HEIGHT_RATIO
|
||||||
)
|
)
|
||||||
const symptomRowHeight =
|
const symptomRowHeight =
|
||||||
PixelRatio.roundToNearestPixel(symptomRowSymptoms.length * symptomHeight) +
|
PixelRatio.roundToNearestPixel(
|
||||||
CHART_GRID_LINE_HORIZONTAL_WIDTH
|
symptomRowEnabledSymptoms.length * symptomHeight
|
||||||
|
) + CHART_GRID_LINE_HORIZONTAL_WIDTH
|
||||||
const columnHeight = remainingHeight - symptomRowHeight
|
const columnHeight = remainingHeight - symptomRowHeight
|
||||||
|
|
||||||
const chartHeight = shouldShowTemperatureColumn
|
const chartHeight = shouldShowTemperatureColumn
|
||||||
@@ -89,7 +104,7 @@ const CycleChart = ({ navigate, setDate }) => {
|
|||||||
navigate={navigate}
|
navigate={navigate}
|
||||||
symptomHeight={symptomHeight}
|
symptomHeight={symptomHeight}
|
||||||
columnHeight={columnHeight}
|
columnHeight={columnHeight}
|
||||||
symptomRowSymptoms={symptomRowSymptoms}
|
symptomRowSymptoms={symptomRowEnabledSymptoms}
|
||||||
chartSymptoms={chartSymptoms}
|
chartSymptoms={chartSymptoms}
|
||||||
shouldShowTemperatureColumn={shouldShowTemperatureColumn}
|
shouldShowTemperatureColumn={shouldShowTemperatureColumn}
|
||||||
xAxisHeight={xAxisHeight}
|
xAxisHeight={xAxisHeight}
|
||||||
@@ -114,7 +129,7 @@ const CycleChart = ({ navigate, setDate }) => {
|
|||||||
<View style={styles.chartArea}>
|
<View style={styles.chartArea}>
|
||||||
<YAxis
|
<YAxis
|
||||||
height={columnHeight}
|
height={columnHeight}
|
||||||
symptomsToDisplay={symptomRowSymptoms}
|
symptomsToDisplay={symptomRowEnabledSymptoms}
|
||||||
symptomsSectionHeight={symptomRowHeight}
|
symptomsSectionHeight={symptomRowHeight}
|
||||||
shouldShowTemperatureColumn={shouldShowTemperatureColumn}
|
shouldShowTemperatureColumn={shouldShowTemperatureColumn}
|
||||||
xAxisHeight={xAxisHeight}
|
xAxisHeight={xAxisHeight}
|
||||||
|
|||||||
Reference in New Issue
Block a user