add dismiss all
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
|
import {BottomSheet} from './src/BottomSheet'
|
||||||
import {
|
import {
|
||||||
BottomSheetSnapPoint,
|
BottomSheetSnapPoint,
|
||||||
BottomSheetState,
|
BottomSheetState,
|
||||||
BottomSheetViewProps,
|
BottomSheetViewProps,
|
||||||
} from './src/BottomSheet.types'
|
} from './src/BottomSheet.types'
|
||||||
import {BottomSheetView} from './src/BottomSheetView'
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
BottomSheet,
|
||||||
BottomSheetSnapPoint,
|
BottomSheetSnapPoint,
|
||||||
type BottomSheetState,
|
type BottomSheetState,
|
||||||
BottomSheetView,
|
|
||||||
type BottomSheetViewProps,
|
type BottomSheetViewProps,
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-1
@@ -8,6 +8,7 @@ import {
|
|||||||
View,
|
View,
|
||||||
ViewStyle,
|
ViewStyle,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
|
import {requireNativeModule} from 'expo'
|
||||||
import {requireNativeViewManager} from 'expo-modules-core'
|
import {requireNativeViewManager} from 'expo-modules-core'
|
||||||
|
|
||||||
import {BottomSheetState, BottomSheetViewProps} from './BottomSheet.types'
|
import {BottomSheetState, BottomSheetViewProps} from './BottomSheet.types'
|
||||||
@@ -21,7 +22,9 @@ const NativeView: React.ComponentType<
|
|||||||
}
|
}
|
||||||
> = requireNativeViewManager('BottomSheet')
|
> = requireNativeViewManager('BottomSheet')
|
||||||
|
|
||||||
export class BottomSheetView extends React.Component<
|
const NativeModule = requireNativeModule('BottomSheet')
|
||||||
|
|
||||||
|
export class BottomSheet extends React.Component<
|
||||||
BottomSheetViewProps,
|
BottomSheetViewProps,
|
||||||
{
|
{
|
||||||
open: boolean
|
open: boolean
|
||||||
@@ -68,6 +71,10 @@ export class BottomSheetView extends React.Component<
|
|||||||
this.ref.current?.updateLayout()
|
this.ref.current?.updateLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static dismissAll = async () => {
|
||||||
|
await NativeModule.dismissAll()
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {children, ...rest} = this.props
|
const {children, ...rest} = this.props
|
||||||
const topInset = rest.topInset ?? 0
|
const topInset = rest.topInset ?? 0
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
import {BottomSheetViewProps} from './BottomSheet.types'
|
import {BottomSheetViewProps} from './BottomSheet.types'
|
||||||
|
|
||||||
export function BottomSheetView(_: BottomSheetViewProps) {
|
export function BottomSheet(_: BottomSheetViewProps) {
|
||||||
throw new Error('BottomSheetView is not available on web')
|
throw new Error('BottomSheetView is not available on web')
|
||||||
}
|
}
|
||||||
@@ -17,10 +17,7 @@ import {
|
|||||||
} from '#/components/Dialog/types'
|
} from '#/components/Dialog/types'
|
||||||
import {createInput} from '#/components/forms/TextField'
|
import {createInput} from '#/components/forms/TextField'
|
||||||
import {Portal as DefaultPortal} from '#/components/Portal'
|
import {Portal as DefaultPortal} from '#/components/Portal'
|
||||||
import {
|
import {BottomSheet, BottomSheetSnapPoint} from '../../../modules/bottom-sheet'
|
||||||
BottomSheetSnapPoint,
|
|
||||||
BottomSheetView,
|
|
||||||
} from '../../../modules/bottom-sheet'
|
|
||||||
|
|
||||||
export {useDialogContext, useDialogControl} from '#/components/Dialog/context'
|
export {useDialogContext, useDialogControl} from '#/components/Dialog/context'
|
||||||
export * from '#/components/Dialog/types'
|
export * from '#/components/Dialog/types'
|
||||||
@@ -37,7 +34,7 @@ export function Outer({
|
|||||||
Portal = DefaultPortal,
|
Portal = DefaultPortal,
|
||||||
}: React.PropsWithChildren<DialogOuterProps>) {
|
}: React.PropsWithChildren<DialogOuterProps>) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const ref = React.useRef<BottomSheetView>(null)
|
const ref = React.useRef<BottomSheet>(null)
|
||||||
const insets = useSafeAreaInsets()
|
const insets = useSafeAreaInsets()
|
||||||
const closeCallbacks = React.useRef<(() => void)[]>([])
|
const closeCallbacks = React.useRef<(() => void)[]>([])
|
||||||
const {setDialogIsOpen} = useDialogStateControlContext()
|
const {setDialogIsOpen} = useDialogStateControlContext()
|
||||||
@@ -102,7 +99,7 @@ export function Outer({
|
|||||||
return (
|
return (
|
||||||
<Portal>
|
<Portal>
|
||||||
<Context.Provider value={context}>
|
<Context.Provider value={context}>
|
||||||
<BottomSheetView
|
<BottomSheet
|
||||||
ref={ref}
|
ref={ref}
|
||||||
topInset={30}
|
topInset={30}
|
||||||
bottomInset={insets.bottom}
|
bottomInset={insets.bottom}
|
||||||
@@ -119,7 +116,7 @@ export function Outer({
|
|||||||
<Wrapper testID={testID} style={[t.atoms.bg]}>
|
<Wrapper testID={testID} style={[t.atoms.bg]}>
|
||||||
{children}
|
{children}
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
</BottomSheetView>
|
</BottomSheet>
|
||||||
</Context.Provider>
|
</Context.Provider>
|
||||||
</Portal>
|
</Portal>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import React from 'react'
|
|||||||
import {isWeb} from '#/platform/detection'
|
import {isWeb} from '#/platform/detection'
|
||||||
import {DialogControlRefProps} from '#/components/Dialog'
|
import {DialogControlRefProps} from '#/components/Dialog'
|
||||||
import {Provider as GlobalDialogsProvider} from '#/components/dialogs/Context'
|
import {Provider as GlobalDialogsProvider} from '#/components/dialogs/Context'
|
||||||
|
import {BottomSheet} from '../../../modules/bottom-sheet'
|
||||||
|
|
||||||
interface IDialogContext {
|
interface IDialogContext {
|
||||||
/**
|
/**
|
||||||
@@ -51,8 +52,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
|
|
||||||
return openDialogs.current.size > 0
|
return openDialogs.current.size > 0
|
||||||
} else {
|
} else {
|
||||||
// @TODO DIALOGS REFACTOR
|
BottomSheet.dismissAll()
|
||||||
console.error('HAILEY FIX THIS 🥺📋')
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|||||||
Reference in New Issue
Block a user