import React, {useImperativeHandle} from 'react' import {View, Dimensions} from 'react-native' import BottomSheet, { BottomSheetBackdrop, BottomSheetScrollView, BottomSheetTextInput, BottomSheetView, } from '@gorhom/bottom-sheet' import {useSafeAreaInsets} from 'react-native-safe-area-context' import {useTheme, atoms as a} from '#/alf' import {Portal} from '#/components/Portal' import {createInput} from '#/components/forms/TextField' import { DialogOuterProps, DialogControlProps, DialogInnerProps, } from '#/components/Dialog/types' import {Context} from '#/components/Dialog/context' export {useDialogControl, useDialogContext} from '#/components/Dialog/context' export * from '#/components/Dialog/types' // @ts-ignore export const Input = createInput(BottomSheetTextInput) export function Outer({ children, control, onClose, nativeOptions, }: React.PropsWithChildren) { const t = useTheme() const sheet = React.useRef(null) const sheetOptions = nativeOptions?.sheet || {} const hasSnapPoints = !!sheetOptions.snapPoints const open = React.useCallback((i = 0) => { sheet.current?.snapToIndex(i) }, []) const close = React.useCallback(() => { sheet.current?.close() onClose?.() }, [onClose]) useImperativeHandle( control.ref, () => ({ open, close, }), [open, close], ) const context = React.useMemo(() => ({close}), [close]) return ( ( )} handleIndicatorStyle={{backgroundColor: t.palette.primary_500}} handleStyle={{display: 'none'}} onClose={onClose}> {children} ) } // TODO a11y props here, or is that handled by the sheet? export function Inner(props: DialogInnerProps) { const insets = useSafeAreaInsets() return ( {props.children} ) } export function ScrollableInner(props: DialogInnerProps) { const insets = useSafeAreaInsets() return ( {props.children} ) } export function Handle() { const t = useTheme() return ( ) } export function Close() { return null }