From 048ce0244f3dbf005f332e37e75054f26ba95a7b Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 15 Jan 2024 15:58:57 -0600 Subject: [PATCH] Scrollable dialogs --- src/App.native.tsx | 6 +- src/App.web.tsx | 6 +- src/components/Dialog/index.tsx | 80 +++++++++++++++----------- src/components/Dialog/index.web.tsx | 7 ++- src/components/Prompt.tsx | 3 +- src/view/screens/Storybook/Dialogs.tsx | 13 +++-- src/view/shell/index.tsx | 2 + src/view/shell/index.web.tsx | 2 + 8 files changed, 67 insertions(+), 52 deletions(-) diff --git a/src/App.native.tsx b/src/App.native.tsx index 7042c6e098..b0aa4b182a 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -41,10 +41,7 @@ import { import {Provider as UnreadNotifsProvider} from 'state/queries/notifications/unread' import * as persisted from '#/state/persisted' import {Splash} from '#/Splash' -import { - Provider as PortalProvider, - Outlet as PortalOutlet, -} from '#/components/Portal' +import {Provider as PortalProvider} from '#/components/Portal' SplashScreen.preventAutoHideAsync() @@ -80,7 +77,6 @@ function InnerApp() { - diff --git a/src/App.web.tsx b/src/App.web.tsx index 546f5614df..756d4954eb 100644 --- a/src/App.web.tsx +++ b/src/App.web.tsx @@ -30,10 +30,7 @@ import { } from 'state/session' import {Provider as UnreadNotifsProvider} from 'state/queries/notifications/unread' import * as persisted from '#/state/persisted' -import { - Provider as PortalProvider, - Outlet as PortalOutlet, -} from '#/components/Portal' +import {Provider as PortalProvider} from '#/components/Portal' function InnerApp() { const {isInitialLoad, currentAccount} = useSession() @@ -62,7 +59,6 @@ function InnerApp() { - diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index de9d69edb2..89af99d66a 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -2,6 +2,7 @@ import React, {useImperativeHandle} from 'react' import {View, Dimensions} from 'react-native' import BottomSheet, { BottomSheetBackdrop, + BottomSheetScrollView, BottomSheetView, } from '@gorhom/bottom-sheet' import {useSafeAreaInsets} from 'react-native-safe-area-context' @@ -16,13 +17,6 @@ import { } from '#/components/Dialog/types' import {Context} from '#/components/Dialog/context' -/** - * Exports - */ -export { - BottomSheetScrollView as ScrollView, - BottomSheetTextInput as TextInput, -} from '@gorhom/bottom-sheet' export {useDialogControl, useDialogContext} from '#/components/Dialog/context' export * from '#/components/Dialog/types' @@ -34,6 +28,8 @@ export function Outer({ }: 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) @@ -58,15 +54,15 @@ export function Outer({ return ( ( - - - - {children} - - + + + {children} + ) @@ -103,7 +97,7 @@ export function Outer({ export function Inner(props: DialogInnerProps) { const insets = useSafeAreaInsets() return ( - {props.children} - + + ) +} + +export function ScrollableInner(props: DialogInnerProps) { + const insets = useSafeAreaInsets() + return ( + + {props.children} + ) } @@ -126,12 +139,13 @@ export function Handle() { a.absolute, a.rounded_sm, a.z_10, - t.atoms.bg_contrast_200, { - top: 12, - width: 50, - height: 6, + top: a.pt_lg.paddingTop, + width: 35, + height: 4, alignSelf: 'center', + backgroundColor: t.palette.contrast_900, + opacity: 0.5, }, ]} /> diff --git a/src/components/Dialog/index.web.tsx b/src/components/Dialog/index.web.tsx index 88b29e13a8..b98ddae5e8 100644 --- a/src/components/Dialog/index.web.tsx +++ b/src/components/Dialog/index.web.tsx @@ -11,7 +11,6 @@ import {Button} from '#/components/Button' import {DialogOuterProps, DialogInnerProps} from '#/components/Dialog/types' import {Context, useDialogContext} from '#/components/Dialog/context' -export {ScrollView, TextInput} from 'react-native' export {useDialogControl, useDialogContext} from '#/components/Dialog/context' export * from '#/components/Dialog/types' @@ -91,7 +90,7 @@ export function Outer({ style={[ web(a.fixed), a.inset_0, - t.atoms.bg_contrast_300, + t.atoms.bg_contrast_100, {opacity: 0.8}, ]} /> @@ -145,7 +144,7 @@ export function Inner({ a.border, gtMobile ? a.p_xl : a.p_lg, t.atoms.bg, - {maxWidth: 600, borderColor: t.palette.contrast_300}, + {maxWidth: 600, borderColor: t.palette.contrast_200}, ...(Array.isArray(style) ? style : [style || {}]), ]}> {children} @@ -154,6 +153,8 @@ export function Inner({ ) } +export const ScrollableInner = Inner + export function Handle() { return null } diff --git a/src/components/Prompt.tsx b/src/components/Prompt.tsx index 4617943829..5e1f88453f 100644 --- a/src/components/Prompt.tsx +++ b/src/components/Prompt.tsx @@ -34,11 +34,12 @@ export function Outer({ return ( + + - {children} diff --git a/src/view/screens/Storybook/Dialogs.tsx b/src/view/screens/Storybook/Dialogs.tsx index f34fca8b85..9dd76be40a 100644 --- a/src/view/screens/Storybook/Dialogs.tsx +++ b/src/view/screens/Storybook/Dialogs.tsx @@ -45,15 +45,18 @@ export function Dialogs() { - - + + + - -

Dialog

Description

+