-
-
Notifications
You must be signed in to change notification settings - Fork 744
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: introduce focus hook to reset scrollable ref
- Loading branch information
Showing
10 changed files
with
247 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import type { Component, EffectCallback, DependencyList } from 'react'; | ||
import type { FlatListProps as RNFlatListProps } from 'react-native'; | ||
|
||
type BottomSheetFlatListProps<T> = Omit< | ||
RNFlatListProps<T>, | ||
| 'overScrollMode' | ||
| 'bounces' | ||
| 'decelerationRate' | ||
| 'onScrollBeginDrag' | ||
| 'scrollEventThrottle' | ||
> & { | ||
focusHook?: (effect: EffectCallback, deps?: DependencyList) => void; | ||
}; | ||
|
||
export class BottomSheetFlatList<T = any> extends Component< | ||
BottomSheetFlatListProps<T> | ||
> { | ||
/** | ||
* Scrolls to the end of the content. May be janky without `getItemLayout` prop. | ||
*/ | ||
scrollToEnd: (params?: { animated?: boolean | null }) => void; | ||
|
||
/** | ||
* Scrolls to the item at the specified index such that it is positioned in the viewable area | ||
* such that viewPosition 0 places it at the top, 1 at the bottom, and 0.5 centered in the middle. | ||
* Cannot scroll to locations outside the render window without specifying the getItemLayout prop. | ||
*/ | ||
scrollToIndex: (params: { | ||
animated?: boolean | null; | ||
index: number; | ||
viewOffset?: number; | ||
viewPosition?: number; | ||
}) => void; | ||
|
||
/** | ||
* Requires linear scan through data - use `scrollToIndex` instead if possible. | ||
* May be janky without `getItemLayout` prop. | ||
*/ | ||
scrollToItem: (params: { | ||
animated?: boolean | null; | ||
item: ItemT; | ||
viewPosition?: number; | ||
}) => void; | ||
|
||
/** | ||
* Scroll to a specific content pixel offset, like a normal `ScrollView`. | ||
*/ | ||
scrollToOffset: (params: { | ||
animated?: boolean | null; | ||
offset: number; | ||
}) => void; | ||
|
||
/** | ||
* Tells the list an interaction has occured, which should trigger viewability calculations, | ||
* e.g. if waitForInteractions is true and the user has not scrolled. This is typically called | ||
* by taps on items or by navigation actions. | ||
*/ | ||
recordInteraction: () => void; | ||
|
||
/** | ||
* Displays the scroll indicators momentarily. | ||
*/ | ||
flashScrollIndicators: () => void; | ||
|
||
/** | ||
* Provides a handle to the underlying scroll responder. | ||
*/ | ||
getScrollResponder: () => JSX.Element | null | undefined; | ||
|
||
/** | ||
* Provides a reference to the underlying host component | ||
*/ | ||
getNativeScrollRef: () => | ||
| React.RefObject<View> | ||
| React.RefObject<ScrollViewComponent> | ||
| null | ||
| undefined; | ||
|
||
getScrollableNode: () => any; | ||
|
||
// TODO: use `unknown` instead of `any` for Typescript >= 3.0 | ||
setNativeProps: (props: { [key: string]: any }) => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.