nesting support
This commit is contained in:
@@ -29,6 +29,26 @@ export function Outer({
|
|||||||
onClose,
|
onClose,
|
||||||
nativeOptions,
|
nativeOptions,
|
||||||
testID,
|
testID,
|
||||||
|
}: React.PropsWithChildren<DialogOuterProps>) {
|
||||||
|
return (
|
||||||
|
<Portal>
|
||||||
|
<OuterWithoutPortal
|
||||||
|
control={control}
|
||||||
|
onClose={onClose}
|
||||||
|
nativeOptions={nativeOptions}
|
||||||
|
testID={testID}>
|
||||||
|
{children}
|
||||||
|
</OuterWithoutPortal>
|
||||||
|
</Portal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function OuterWithoutPortal({
|
||||||
|
children,
|
||||||
|
control,
|
||||||
|
onClose,
|
||||||
|
nativeOptions,
|
||||||
|
testID,
|
||||||
}: React.PropsWithChildren<DialogOuterProps>) {
|
}: React.PropsWithChildren<DialogOuterProps>) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const ref = React.useRef<BlueskyBottomSheetView>(null)
|
const ref = React.useRef<BlueskyBottomSheetView>(null)
|
||||||
@@ -93,7 +113,6 @@ export function Outer({
|
|||||||
const context = React.useMemo(() => ({close}), [close])
|
const context = React.useMemo(() => ({close}), [close])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Portal>
|
|
||||||
<Context.Provider value={context}>
|
<Context.Provider value={context}>
|
||||||
<BlueskyBottomSheetView
|
<BlueskyBottomSheetView
|
||||||
// handleIndicatorStyle={{backgroundColor: t.palette.primary_500}} // @TODO DIALOG REFACTOR need to add this to lib!*/
|
// handleIndicatorStyle={{backgroundColor: t.palette.primary_500}} // @TODO DIALOG REFACTOR need to add this to lib!*/
|
||||||
@@ -112,7 +131,6 @@ export function Outer({
|
|||||||
</View>
|
</View>
|
||||||
</BlueskyBottomSheetView>
|
</BlueskyBottomSheetView>
|
||||||
</Context.Provider>
|
</Context.Provider>
|
||||||
</Portal>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {PressableEvent} from 'react-native-gesture-handler/lib/typescript/compon
|
|||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {isNative} from '#/platform/detection'
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {BottomSheetButton} from '#/components/BottomSheetButton'
|
import {BottomSheetButton} from '#/components/BottomSheetButton'
|
||||||
import {ButtonColor, ButtonText} from '#/components/Button'
|
import {ButtonColor, ButtonText} from '#/components/Button'
|
||||||
@@ -27,9 +28,11 @@ export function Outer({
|
|||||||
children,
|
children,
|
||||||
control,
|
control,
|
||||||
testID,
|
testID,
|
||||||
|
withoutPortal,
|
||||||
}: React.PropsWithChildren<{
|
}: React.PropsWithChildren<{
|
||||||
control: Dialog.DialogControlProps
|
control: Dialog.DialogControlProps
|
||||||
testID?: string
|
testID?: string
|
||||||
|
withoutPortal?: boolean
|
||||||
}>) {
|
}>) {
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
const titleId = React.useId()
|
const titleId = React.useId()
|
||||||
@@ -40,8 +43,11 @@ export function Outer({
|
|||||||
[titleId, descriptionId],
|
[titleId, descriptionId],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const Wrapper =
|
||||||
|
withoutPortal && isNative ? Dialog.OuterWithoutPortal : Dialog.Outer
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog.Outer control={control} testID={testID}>
|
<Wrapper control={control} testID={testID}>
|
||||||
<Context.Provider value={context}>
|
<Context.Provider value={context}>
|
||||||
<Dialog.ScrollableInner
|
<Dialog.ScrollableInner
|
||||||
accessibilityLabelledBy={titleId}
|
accessibilityLabelledBy={titleId}
|
||||||
@@ -52,7 +58,7 @@ export function Outer({
|
|||||||
{children}
|
{children}
|
||||||
</Dialog.ScrollableInner>
|
</Dialog.ScrollableInner>
|
||||||
</Context.Provider>
|
</Context.Provider>
|
||||||
</Dialog.Outer>
|
</Wrapper>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +187,7 @@ export function Basic({
|
|||||||
onConfirm,
|
onConfirm,
|
||||||
confirmButtonColor,
|
confirmButtonColor,
|
||||||
showCancel = true,
|
showCancel = true,
|
||||||
|
withoutPortal,
|
||||||
}: React.PropsWithChildren<{
|
}: React.PropsWithChildren<{
|
||||||
control: Dialog.DialogOuterProps['control']
|
control: Dialog.DialogOuterProps['control']
|
||||||
title: string
|
title: string
|
||||||
@@ -197,9 +204,13 @@ export function Basic({
|
|||||||
onConfirm: (e: PressableEvent) => void
|
onConfirm: (e: PressableEvent) => void
|
||||||
confirmButtonColor?: ButtonColor
|
confirmButtonColor?: ButtonColor
|
||||||
showCancel?: boolean
|
showCancel?: boolean
|
||||||
|
withoutPortal?: boolean
|
||||||
}>) {
|
}>) {
|
||||||
return (
|
return (
|
||||||
<Outer control={control} testID="confirmModal">
|
<Outer
|
||||||
|
control={control}
|
||||||
|
testID="confirmModal"
|
||||||
|
withoutPortal={withoutPortal}>
|
||||||
<TitleText>{title}</TitleText>
|
<TitleText>{title}</TitleText>
|
||||||
<DescriptionText>{description}</DescriptionText>
|
<DescriptionText>{description}</DescriptionText>
|
||||||
<Actions>
|
<Actions>
|
||||||
|
|||||||
@@ -861,6 +861,7 @@ export const ComposePost = ({
|
|||||||
onConfirm={onClose}
|
onConfirm={onClose}
|
||||||
confirmButtonCta={_(msg`Discard`)}
|
confirmButtonCta={_(msg`Discard`)}
|
||||||
confirmButtonColor="negative"
|
confirmButtonColor="negative"
|
||||||
|
withoutPortal={true}
|
||||||
/>
|
/>
|
||||||
</KeyboardAvoidingView>
|
</KeyboardAvoidingView>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user