Add RefreshControl
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
import {forwardRef, useMemo} from 'react'
|
import {forwardRef, useMemo} from 'react'
|
||||||
import {type FlatList, type FlatListProps, type ViewToken} from 'react-native'
|
import {
|
||||||
|
type FlatList,
|
||||||
|
type FlatListProps,
|
||||||
|
RefreshControl,
|
||||||
|
type ViewToken,
|
||||||
|
} from 'react-native'
|
||||||
import Animated, {
|
import Animated, {
|
||||||
type FlatListPropsWithLayout,
|
type FlatListPropsWithLayout,
|
||||||
useAnimatedScrollHandler,
|
useAnimatedScrollHandler,
|
||||||
@@ -87,6 +92,20 @@ export const List = forwardRef(function List<Item>(
|
|||||||
]
|
]
|
||||||
}, [props.onItemSeen])
|
}, [props.onItemSeen])
|
||||||
|
|
||||||
|
let refreshControl
|
||||||
|
if (props.refreshing !== undefined || props.onRefresh !== undefined) {
|
||||||
|
refreshControl = (
|
||||||
|
<RefreshControl
|
||||||
|
key={t.atoms.text.color}
|
||||||
|
refreshing={props.refreshing ?? false}
|
||||||
|
onRefresh={props.onRefresh ?? undefined}
|
||||||
|
tintColor={t.atoms.text.color}
|
||||||
|
titleColor={t.atoms.text.color}
|
||||||
|
progressViewOffset={props.progressViewOffset ?? props.headerOffset}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Animated.FlatList
|
<Animated.FlatList
|
||||||
ref={ref}
|
ref={ref}
|
||||||
@@ -129,6 +148,7 @@ export const List = forwardRef(function List<Item>(
|
|||||||
props.headerOffset ? {x: 0, y: props.headerOffset * -1} : undefined
|
props.headerOffset ? {x: 0, y: props.headerOffset * -1} : undefined
|
||||||
}
|
}
|
||||||
scrollsToTop={!activeLightbox}
|
scrollsToTop={!activeLightbox}
|
||||||
|
refreshControl={refreshControl}
|
||||||
{...(props as FlatListPropsWithLayout<Item>)}
|
{...(props as FlatListPropsWithLayout<Item>)}
|
||||||
style={[
|
style={[
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user