diff options
author | dan <dan.abramov@gmail.com> | 2023-12-14 02:48:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-13 18:48:20 -0800 |
commit | 7fd79702371e3d7829be2188c2212c090bf76670 (patch) | |
tree | dd2e7543284a5a0d43e2c371feefe465fabf3d1c /src/view/com/util/ViewSelector.tsx | |
parent | fa3ccafa8028933f11802eace3dca6f6dc7c4dba (diff) | |
download | voidsky-7fd79702371e3d7829be2188c2212c090bf76670.tar.zst |
Make scroll handling contextual (#2200)
* Add an intermediate List component * Fix type * Add onScrolledDownChange * Port pager to use onScrolledDownChange * Fix on mobile * Don't pass down onScroll (replacement TBD) * Remove resetMainScroll * Replace onMainScroll with MainScrollProvider * Hook ScrollProvider to pager * Fix the remaining special case * Optimize a bit * Enforce that onScroll cannot be passed * Keep value updated even if no handler * Also memo it
Diffstat (limited to 'src/view/com/util/ViewSelector.tsx')
-rw-r--r-- | src/view/com/util/ViewSelector.tsx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/view/com/util/ViewSelector.tsx b/src/view/com/util/ViewSelector.tsx index 935d93033..ee993c564 100644 --- a/src/view/com/util/ViewSelector.tsx +++ b/src/view/com/util/ViewSelector.tsx @@ -1,13 +1,14 @@ import React, {useEffect, useState} from 'react' import { + NativeSyntheticEvent, + NativeScrollEvent, Pressable, RefreshControl, StyleSheet, View, ScrollView, } from 'react-native' -import {FlatList} from './Views' -import {OnScrollCb} from 'lib/hooks/useOnMainScroll' +import {FlatList_INTERNAL} from './Views' import {useColorSchemeStyle} from 'lib/hooks/useColorSchemeStyle' import {Text} from './text/Text' import {usePalette} from 'lib/hooks/usePalette' @@ -38,7 +39,7 @@ export const ViewSelector = React.forwardRef< | null | undefined onSelectView?: (viewIndex: number) => void - onScroll?: OnScrollCb + onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void onRefresh?: () => void onEndReached?: (info: {distanceFromEnd: number}) => void } @@ -59,7 +60,7 @@ export const ViewSelector = React.forwardRef< ) { const pal = usePalette('default') const [selectedIndex, setSelectedIndex] = useState<number>(0) - const flatListRef = React.useRef<FlatList>(null) + const flatListRef = React.useRef<FlatList_INTERNAL>(null) // events // = @@ -110,7 +111,7 @@ export const ViewSelector = React.forwardRef< [items], ) return ( - <FlatList + <FlatList_INTERNAL ref={flatListRef} data={data} keyExtractor={keyExtractor} |