import React, { useState } from 'react'; import { View, ScrollView, ActivityIndicator, RefreshControl, RefreshControlProps, } from 'react-native'; import { px2dp, Utils } from '../../tools'; const Pagination: React.FC = ({ loadFunctionMore, requestFunctionData, tintColor, title, titleColor, colors, progressBackgroundColor, }) => { const [refreshBottom, setRefreshBottom] = useState(false); const [refreshing, setRefreshing] = useState(false); const onMomentumScrollEnd = (event: { nativeEvent: { contentSize: { height: any }; layoutMeasurement: { height: any }; contentOffset: { y: any }; }; }) => { const contentHeight = event.nativeEvent.contentSize.height; const scrollViewHeight = event.nativeEvent.layoutMeasurement.height; const scrollOffset = event.nativeEvent.contentOffset.y; const isEndReached = scrollOffset + scrollViewHeight + 45 >= contentHeight; // 是否滑动到底部 const isContentFillPage = contentHeight >= scrollViewHeight; // 内容高度是否大于列表高度 if (isContentFillPage && isEndReached) { setRefreshBottom(true); loadFunctionMore(); setTimeout(() => { setRefreshBottom(false); }, 800); } }; const renderRactivityIndicator = () => ( <> {Utils.platform() ? ( ) : ( )} ); const onRefresh = () => { setRefreshing(true); setTimeout(() => { requestFunctionData(); setRefreshing(true); }, 1000); }; return ( }> {refreshBottom ? renderRactivityIndicator() : <>} ); }; export default Pagination;