feat: integrate UI components into Works List with pagination and refresh
- Add useWorksList hook for data fetching with pagination support - Integrate RefreshControl for pull-to-refresh functionality - Add LoadingState for initial loading display - Add ErrorState with retry functionality - Add PaginationLoader for load more indication - Update WorksGallery to support refresh control and pagination - Add comprehensive tests for worksList screen and hook - Use useMemo for performance optimization TODO: Replace mock API with actual backend endpoint when available Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,9 @@ interface WorksGalleryProps {
|
||||
onCategoryChange: (category: Category) => void
|
||||
groupedWorks: Record<string, WorkItem[]>
|
||||
onWorkPress: (id: number) => void
|
||||
refreshControl?: React.ReactElement
|
||||
onEndReached?: () => void
|
||||
ListFooterComponent?: React.ReactElement
|
||||
}
|
||||
|
||||
export default function WorksGallery({
|
||||
@@ -40,6 +43,9 @@ export default function WorksGallery({
|
||||
onCategoryChange,
|
||||
groupedWorks,
|
||||
onWorkPress,
|
||||
refreshControl,
|
||||
onEndReached,
|
||||
ListFooterComponent,
|
||||
}: WorksGalleryProps) {
|
||||
const { i18n } = useTranslation()
|
||||
|
||||
@@ -112,6 +118,15 @@ export default function WorksGallery({
|
||||
style={styles.scrollView}
|
||||
contentContainerStyle={styles.scrollContent}
|
||||
showsVerticalScrollIndicator={false}
|
||||
refreshControl={refreshControl}
|
||||
onScroll={(e) => {
|
||||
const { layoutMeasurement, contentOffset, contentSize } = e.nativeEvent
|
||||
const isCloseToBottom = layoutMeasurement.height + contentOffset.y >= contentSize.height - 100
|
||||
if (isCloseToBottom && onEndReached) {
|
||||
onEndReached()
|
||||
}
|
||||
}}
|
||||
scrollEventThrottle={400}
|
||||
>
|
||||
{Object.entries(groupedWorks).map(([dateKey, works]) => {
|
||||
// 从第一个作品获取日期对象
|
||||
@@ -151,6 +166,7 @@ export default function WorksGallery({
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
{ListFooterComponent}
|
||||
</ScrollView>
|
||||
</>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user