diff --git a/README.md b/README.md index ec96ea487..e3534c8cc 100644 --- a/README.md +++ b/README.md @@ -22,14 +22,16 @@ A performant interactive bottom sheet with fully configurable options 🚀 - [React Navigation Integration](./docs/react-navigation.md) - [Touchables](./docs/touchables.md) 4. [Props](#props) -5. [Scrollables](#scrollables) +5. [Methods](#methods) +6. [Hooks](#hooks) +7. [Scrollables](#scrollables) - [BottomSheetFlatList](./docs/flatlist.md) - [BottomSheetSectionList](./docs/sectionlist.md) - [BottomSheetScrollView](./docs/scrollview.md) - [BottomSheetView](./docs/flatlist.md) -6. [To Do](#to-do) -7. [Credits](#built-with) -8. [License](#license) +8. [To Do](#to-do) +9. [Credits](#built-with) +10. [License](#license) ## Features @@ -160,6 +162,28 @@ A scrollable node or normal view. > `required:` YES | `type:` React.ReactNode[] | React.ReactNode +## Methods + +#### `snapTo` + +Snap to one of the provided points from `snapPoints`. + +> `type:` (index: number) => void + +#### `close` + +Close the bottom sheet. + +> `type:` () => void + +## Hooks + +#### `useBottomSheet` + +The library provide `useBottomSheet` hook to provide the bottom sheet methods, anywhere inside the sheet content. + +> `type:` { snapTo: () => void, close: () => void } + ## Scrollables This library provides a pre-integrated views that utilise an internal functionalities with the bottom sheet to allow smooth interactions. These views i called them `Scrollables` and they are: diff --git a/src/components/bottomSheet/BottomSheet.tsx b/src/components/bottomSheet/BottomSheet.tsx index 835b85d72..747aa3785 100644 --- a/src/components/bottomSheet/BottomSheet.tsx +++ b/src/components/bottomSheet/BottomSheet.tsx @@ -57,7 +57,15 @@ import type { BottomSheetProps } from './types'; import { styles } from './styles'; interface BottomSheet { + /** + * Snap to one of the provided points from `snapPoints`. + * @type (index: number) => void + */ snapTo: (index: number) => void; + /** + * Close the bottom sheet. + * @type () => void + */ close: () => void; } diff --git a/src/context.ts b/src/context.ts index df6ed191b..43ca5d7ef 100644 --- a/src/context.ts +++ b/src/context.ts @@ -23,7 +23,15 @@ export const BottomSheetInternalContext = createContext< export const BottomSheetInternalProvider = BottomSheetInternalContext.Provider; export interface BottomSheetContextType { + /** + * Snap to one of the provided points from `snapPoints`. + * @type (index: number) => void + */ snapTo: (index: number) => void; + /** + * Close the bottom sheet. + * @type () => void + */ close: () => void; }