This commit is contained in:
Eric Bailey
2024-02-19 15:49:22 -06:00
parent a52b840c19
commit 04dd8f9eef
2 changed files with 18 additions and 1 deletions
+9
View File
@@ -35,11 +35,20 @@ export function Outer({
const sheetOptions = nativeOptions?.sheet || {}
const hasSnapPoints = !!sheetOptions.snapPoints
const insets = useSafeAreaInsets()
/*
* Used to manage open/closed, but index is otherwise handled internally by `BottomSheet`
*/
const [openIndex, setOpenIndex] = React.useState(-1)
/*
* `openIndex` is the index of the snap point to open the bottom sheet to. If >0, the bottom sheet is open.
*/
const isOpen = openIndex > -1
const open = React.useCallback<DialogControlProps['open']>(
({index} = {}) => {
// can be set to any index of `snapPoints`, but `0` is the first i.e. "open"
setOpenIndex(index || 0)
},
[setOpenIndex],
+9 -1
View File
@@ -10,7 +10,15 @@ export type DialogContextProps = {
close: () => void
}
export type DialogControlOpenOptions = {index?: number}
export type DialogControlOpenOptions = {
/**
* NATIVE ONLY
*
* Optional index of the snap point to open the bottom sheet to. Defaults to
* 0, which is the first snap point (i.e. "open").
*/
index?: number
}
export type DialogControlProps = {
open: (options?: DialogControlOpenOptions) => void