diff --git a/modules/bottom-sheet/index.ts b/modules/bottom-sheet/index.ts index 2eae5bfc2f..1fe3dac0eb 100644 --- a/modules/bottom-sheet/index.ts +++ b/modules/bottom-sheet/index.ts @@ -1,13 +1,13 @@ +import {BottomSheet} from './src/BottomSheet' import { BottomSheetSnapPoint, BottomSheetState, BottomSheetViewProps, } from './src/BottomSheet.types' -import {BottomSheetView} from './src/BottomSheetView' export { + BottomSheet, BottomSheetSnapPoint, type BottomSheetState, - BottomSheetView, type BottomSheetViewProps, } diff --git a/modules/bottom-sheet/src/BottomSheetView.tsx b/modules/bottom-sheet/src/BottomSheet.tsx similarity index 91% rename from modules/bottom-sheet/src/BottomSheetView.tsx rename to modules/bottom-sheet/src/BottomSheet.tsx index b42c97587c..7a402e7a8e 100644 --- a/modules/bottom-sheet/src/BottomSheetView.tsx +++ b/modules/bottom-sheet/src/BottomSheet.tsx @@ -8,6 +8,7 @@ import { View, ViewStyle, } from 'react-native' +import {requireNativeModule} from 'expo' import {requireNativeViewManager} from 'expo-modules-core' import {BottomSheetState, BottomSheetViewProps} from './BottomSheet.types' @@ -21,7 +22,9 @@ const NativeView: React.ComponentType< } > = requireNativeViewManager('BottomSheet') -export class BottomSheetView extends React.Component< +const NativeModule = requireNativeModule('BottomSheet') + +export class BottomSheet extends React.Component< BottomSheetViewProps, { open: boolean @@ -68,6 +71,10 @@ export class BottomSheetView extends React.Component< this.ref.current?.updateLayout() } + static dismissAll = async () => { + await NativeModule.dismissAll() + } + render() { const {children, ...rest} = this.props const topInset = rest.topInset ?? 0 diff --git a/modules/bottom-sheet/src/BottomSheetView.web.tsx b/modules/bottom-sheet/src/BottomSheet.web.tsx similarity index 67% rename from modules/bottom-sheet/src/BottomSheetView.web.tsx rename to modules/bottom-sheet/src/BottomSheet.web.tsx index 17cfe1e66a..4573604eb2 100644 --- a/modules/bottom-sheet/src/BottomSheetView.web.tsx +++ b/modules/bottom-sheet/src/BottomSheet.web.tsx @@ -1,5 +1,5 @@ import {BottomSheetViewProps} from './BottomSheet.types' -export function BottomSheetView(_: BottomSheetViewProps) { +export function BottomSheet(_: BottomSheetViewProps) { throw new Error('BottomSheetView is not available on web') } diff --git a/src/components/BottomSheetButton.tsx b/src/components/BottomSheetButton.tsx deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index bdbfb24d01..82cf894b93 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -17,10 +17,7 @@ import { } from '#/components/Dialog/types' import {createInput} from '#/components/forms/TextField' import {Portal as DefaultPortal} from '#/components/Portal' -import { - BottomSheetSnapPoint, - BottomSheetView, -} from '../../../modules/bottom-sheet' +import {BottomSheet, BottomSheetSnapPoint} from '../../../modules/bottom-sheet' export {useDialogContext, useDialogControl} from '#/components/Dialog/context' export * from '#/components/Dialog/types' @@ -37,7 +34,7 @@ export function Outer({ Portal = DefaultPortal, }: React.PropsWithChildren) { const t = useTheme() - const ref = React.useRef(null) + const ref = React.useRef(null) const insets = useSafeAreaInsets() const closeCallbacks = React.useRef<(() => void)[]>([]) const {setDialogIsOpen} = useDialogStateControlContext() @@ -102,7 +99,7 @@ export function Outer({ return ( - {children} - + ) diff --git a/src/state/dialogs/index.tsx b/src/state/dialogs/index.tsx index db933b98c8..315ab412c5 100644 --- a/src/state/dialogs/index.tsx +++ b/src/state/dialogs/index.tsx @@ -3,6 +3,7 @@ import React from 'react' import {isWeb} from '#/platform/detection' import {DialogControlRefProps} from '#/components/Dialog' import {Provider as GlobalDialogsProvider} from '#/components/dialogs/Context' +import {BottomSheet} from '../../../modules/bottom-sheet' interface IDialogContext { /** @@ -51,8 +52,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) { return openDialogs.current.size > 0 } else { - // @TODO DIALOGS REFACTOR - console.error('HAILEY FIX THIS πŸ₯ΊπŸ“‹') + BottomSheet.dismissAll() return false } }, [])