Produce horizontal grid once, not for every column

This commit is contained in:
Julia Friesel
2018-08-13 15:20:42 +02:00
parent cd1e689aae
commit 2d221c4060
4 changed files with 14 additions and 12 deletions
+4 -3
View File
@@ -2,7 +2,7 @@ import React, { Component } from 'react'
import { View, FlatList } from 'react-native' import { View, FlatList } from 'react-native'
import range from 'date-range' import range from 'date-range'
import { LocalDate } from 'js-joda' import { LocalDate } from 'js-joda'
import { yAxis, normalizeToScale } from './y-axis' import { yAxis, normalizeToScale, horizontalGrid } from './y-axis'
import DayColumn from './day-column' import DayColumn from './day-column'
import { getCycleDay, cycleDaysSortedByDate, getAmountOfCycleDays } from '../../db' import { getCycleDay, cycleDaysSortedByDate, getAmountOfCycleDays } from '../../db'
import styles from './styles' import styles from './styles'
@@ -43,7 +43,8 @@ export default class CycleChart extends Component {
return ( return (
<View style={{ flexDirection: 'row' }}> <View style={{ flexDirection: 'row' }}>
{yAxisView} {yAxisView}
<FlatList {horizontalGrid}
{<FlatList
horizontal={true} horizontal={true}
inverted={true} inverted={true}
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
@@ -53,7 +54,7 @@ export default class CycleChart extends Component {
initialNumToRender={15} initialNumToRender={15}
maxToRenderPerBatch={5} maxToRenderPerBatch={5}
> >
</FlatList> </FlatList>}
</View> </View>
) )
} }
+1 -2
View File
@@ -8,7 +8,6 @@ import config from './config'
import { getOrCreateCycleDay } from '../../db' import { getOrCreateCycleDay } from '../../db'
import cycleModule from '../../lib/cycle' import cycleModule from '../../lib/cycle'
import setUpFertilityStatusFunc from './nfp-lines' import setUpFertilityStatusFunc from './nfp-lines'
import { horizontalGrid } from './y-axis'
const getCycleDayNumber = cycleModule().getCycleDayNumber const getCycleDayNumber = cycleModule().getCycleDayNumber
const label = styles.column.label const label = styles.column.label
@@ -69,7 +68,7 @@ export default class DayColumn extends Component {
columnElements.push(mucusIcon) columnElements.push(mucusIcon)
} }
columnElements.push(cycleDayLabel, dateLabel, horizontalGrid) columnElements.push(cycleDayLabel, dateLabel)
if(nfpLineInfo.drawFhmLine) { if(nfpLineInfo.drawFhmLine) {
const fhmLine = (<View const fhmLine = (<View
+9 -5
View File
@@ -42,8 +42,7 @@ const styles = {
height: config.chartHeight, height: config.chartHeight,
borderStyle: 'solid', borderStyle: 'solid',
borderColor: 'grey', borderColor: 'grey',
borderWidth: 1, borderWidth: 0.5
backgroundColor: 'transparent'
} }
}, },
bleedingIcon: { bleedingIcon: {
@@ -67,6 +66,9 @@ const styles = {
yAxis: { yAxis: {
height: config.chartHeight, height: config.chartHeight,
width: config.columnWidth, width: config.columnWidth,
borderRightWidth: 0.5,
borderColor: 'lightgrey',
borderStyle: 'solid'
}, },
yAxisLabel: { yAxisLabel: {
position: 'absolute', position: 'absolute',
@@ -76,10 +78,12 @@ const styles = {
fontWeight: 'bold' fontWeight: 'bold'
}, },
horizontalGrid: { horizontalGrid: {
position:'absolute',
borderColor: 'lightgrey', borderColor: 'lightgrey',
borderWidth: 1, borderWidth: 0.5,
width: config.columnWidth, width: '100%',
borderStyle: 'solid' borderStyle: 'solid',
left: config.columnWidth
}, },
nfpLine: { nfpLine: {
borderColor: '#00b159', borderColor: '#00b159',
-2
View File
@@ -37,8 +37,6 @@ export const yAxis = makeYAxis()
export const horizontalGrid = yAxis.tickPositions.map(tick => { export const horizontalGrid = yAxis.tickPositions.map(tick => {
return ( return (
<View <View
position='absolute'
width='100%'
top={tick} top={tick}
{...styles.horizontalGrid} {...styles.horizontalGrid}
key={tick} key={tick}