Comments
This commit is contained in:
@@ -35,11 +35,20 @@ export function Outer({
|
|||||||
const sheetOptions = nativeOptions?.sheet || {}
|
const sheetOptions = nativeOptions?.sheet || {}
|
||||||
const hasSnapPoints = !!sheetOptions.snapPoints
|
const hasSnapPoints = !!sheetOptions.snapPoints
|
||||||
const insets = useSafeAreaInsets()
|
const insets = useSafeAreaInsets()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Used to manage open/closed, but index is otherwise handled internally by `BottomSheet`
|
||||||
|
*/
|
||||||
const [openIndex, setOpenIndex] = React.useState(-1)
|
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 isOpen = openIndex > -1
|
||||||
|
|
||||||
const open = React.useCallback<DialogControlProps['open']>(
|
const open = React.useCallback<DialogControlProps['open']>(
|
||||||
({index} = {}) => {
|
({index} = {}) => {
|
||||||
|
// can be set to any index of `snapPoints`, but `0` is the first i.e. "open"
|
||||||
setOpenIndex(index || 0)
|
setOpenIndex(index || 0)
|
||||||
},
|
},
|
||||||
[setOpenIndex],
|
[setOpenIndex],
|
||||||
|
|||||||
@@ -10,7 +10,15 @@ export type DialogContextProps = {
|
|||||||
close: () => void
|
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 = {
|
export type DialogControlProps = {
|
||||||
open: (options?: DialogControlOpenOptions) => void
|
open: (options?: DialogControlOpenOptions) => void
|
||||||
|
|||||||
Reference in New Issue
Block a user