import React from 'react'; import { Animated, Text, StyleSheet } from 'react-native'; import { RefreshObserverType, RefreshType } from 'react-native-head-tab-view' interface Props { style: any, refreshType: RefreshType, progressAnimated: Animated.AnimatedSubtraction; addProgressListener: (observer: RefreshObserverType) => void; removeProgressListener: (observer: RefreshObserverType) => void; } class RefreshControlAnimated extends React.PureComponent { onProgress = (progress: number) => { } componentDidMount() { this.props.addProgressListener && this.props.addProgressListener(this.onProgress) } componentWillUnmount() { this.props.removeProgressListener && this.props.removeProgressListener(this.onProgress) } render() { const { progressAnimated } = this.props; return ( {this.getText()} ) } getText() { const { refreshType } = this.props if (refreshType === 'RefreshTypePrepare') { return 'Pull down to refresh' } else if (refreshType === 'RefreshTypeEnough') { return "Enough to refresh"; } else if (refreshType === 'RefreshTypeRefreshing') { return "Refreshing ..."; } } } export default RefreshControlAnimated const styles = StyleSheet.create({ circle: { width: 20, height: 20, borderRadius: 10, backgroundColor: '#FFD321' }, text: { color: '#333', fontSize: 17, marginTop: 10 } })