Merge branch '244-improve-chart-scroll' into 'master'

Resolve "improve chart scroll"

Closes #244

See merge request bloodyhealth/drip!106
This commit is contained in:
Julia Friesel
2018-11-07 10:19:16 +00:00
2 changed files with 19 additions and 2 deletions
+14 -2
View File
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
import { View, FlatList } from 'react-native'
import { View, FlatList, ActivityIndicator } from 'react-native'
import range from 'date-range'
import { LocalDate } from 'js-joda'
import Svg, { G } from 'react-native-svg'
@@ -196,9 +196,11 @@ export default class CycleChart extends Component {
renderItem={this.renderColumn}
keyExtractor={item => item}
initialNumToRender={15}
maxToRenderPerBatch={5}
windowSize={30}
onLayout={() => this.setState({chartLoaded: true})}
onEndReached={() => this.setState({end: true})}
ListFooterComponent={<LoadingMoreView end={this.state.end}/>}
updateCellsBatchingPeriod={800}
/>
}
</View>
@@ -206,6 +208,16 @@ export default class CycleChart extends Component {
}
}
function LoadingMoreView(props) {
return (
<View style={styles.loadingMore}>
{!props.end &&
<ActivityIndicator size={'large'} color={'white'}/>
}
</View>
)
}
function getTodayAndPreviousDays(n) {
const today = new Date()
today.setHours(0)
+5
View File
@@ -122,6 +122,11 @@ const styles = {
symptomRow: {
alignItems: 'center',
justifyContent: 'center',
},
loadingMore: {
height: '100%',
backgroundColor: 'lightgrey',
justifyContent: 'center'
}
}