From d0149a96bc07f4dfad6e778511f0ace91a27eead Mon Sep 17 00:00:00 2001 From: Hailey Date: Tue, 1 Oct 2024 15:10:43 -0700 Subject: [PATCH] get scrollview working --- package.json | 1 + src/components/Dialog/index.tsx | 125 +++++++++++++++----------------- yarn.lock | 8 +- 3 files changed, 64 insertions(+), 70 deletions(-) diff --git a/package.json b/package.json index 4ab196b6aa..7b972e662f 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "@fortawesome/free-regular-svg-icons": "^6.1.1", "@fortawesome/free-solid-svg-icons": "^6.1.1", "@fortawesome/react-native-fontawesome": "^0.3.2", + "@haileyok/bluesky-bottom-sheet": "^0.1.1-alpha.7", "@haileyok/bluesky-video": "0.1.10", "@lingui/react": "^4.5.0", "@mattermost/react-native-paste-input": "^0.7.1", diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 2a59ac7f67..1180997352 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -1,15 +1,14 @@ import React, {useImperativeHandle} from 'react' -import {Dimensions, Keyboard, StyleProp, View, ViewStyle} from 'react-native' +import {ScrollView, StyleProp, View, ViewStyle} from 'react-native' import {useSafeAreaInsets} from 'react-native-safe-area-context' -import BottomSheet, { +import { BottomSheetFlatList, BottomSheetFlatListMethods, - BottomSheetScrollView, - BottomSheetScrollViewMethods, BottomSheetTextInput, BottomSheetView, } from '@discord/bottom-sheet/src' import {BottomSheetFlatListProps} from '@discord/bottom-sheet/src/components/bottomSheetScrollable/types' +import {BlueskyBottomSheetView} from '@haileyok/bluesky-bottom-sheet' import {logger} from '#/logger' import {useDialogStateControlContext} from '#/state/dialogs' @@ -37,7 +36,7 @@ export function Outer({ testID, }: React.PropsWithChildren) { const t = useTheme() - const sheet = React.useRef(null) + const ref = React.useRef(null) const insets = useSafeAreaInsets() const closeCallbacks = React.useRef<(() => void)[]>([]) const {setDialogIsOpen} = useDialogStateControlContext() @@ -61,7 +60,7 @@ export function Outer({ callQueuedCallbacks() setIsOpen(true) setDialogIsOpen(control.id, true) - // sheet.current?.open() // @TODO DIALOG REFACTOR + ref.current?.present() }, [setDialogIsOpen, control.id, callQueuedCallbacks]) // This is the function that we call when we want to dismiss the dialog. @@ -70,7 +69,7 @@ export function Outer({ if (typeof cb === 'function') { closeCallbacks.current.push(cb) } - // sheet.current?.close() // @TODO DIALOG REFACTOR + ref.current?.dismiss() }, []) // This is the actual thing we are doing once we "confirm" the dialog. We want the dialog's close animation to @@ -102,39 +101,36 @@ export function Outer({ const context = React.useMemo(() => ({close}), [close]) return ( - isOpen && ( - - Keyboard.dismiss()}> - - - - {children} - - - - - ) + + + { + if (e.nativeEvent.state === 'closed') { + onCloseAnimationComplete() + } + }}> + + {/**/} + {children} + + + + ) } @@ -158,32 +154,29 @@ export function Inner({children, style}: DialogInnerProps) { ) } -export const ScrollableInner = React.forwardRef< - BottomSheetScrollViewMethods, - DialogInnerProps ->(function ScrollableInner({children, style}, ref) { - const insets = useSafeAreaInsets() - return ( - - {children} - - - ) -}) +export const ScrollableInner = React.forwardRef( + function ScrollableInner({children, style}, ref) { + const insets = useSafeAreaInsets() + return ( + + {children} + + + ) + }, +) export const InnerFlatList = React.forwardRef< BottomSheetFlatListMethods, diff --git a/yarn.lock b/yarn.lock index e3dc084342..2512608e7e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4120,10 +4120,10 @@ resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== -"@haileyok/bluesky-bottom-sheet@^0.1.1-alpha.4": - version "0.1.1-alpha.4" - resolved "https://registry.yarnpkg.com/@haileyok/bluesky-bottom-sheet/-/bluesky-bottom-sheet-0.1.1-alpha.4.tgz#19717e57e63d70e79b8bd86984903c448deb83bc" - integrity sha512-bEZRbErsI6OJCgmFolbr9Ta5LxNvyaltzRPFOVtwsykIwL8tqNJeNlmfxP8EdJa5lSu2kK1MauQcygmCIouzwg== +"@haileyok/bluesky-bottom-sheet@^0.1.1-alpha.7": + version "0.1.1-alpha.7" + resolved "https://registry.yarnpkg.com/@haileyok/bluesky-bottom-sheet/-/bluesky-bottom-sheet-0.1.1-alpha.7.tgz#a5845cd2ac386b78716db5940b65b3e78b392042" + integrity sha512-Ps2nsNmfjqUmP/LPAM94/2dWZerwZEjnvSUfi/ipFNHlNp/McIYIObxDaPJaZ0ZLxUcRXxdhmC3UonK25sJKSw== "@haileyok/bluesky-video@0.1.10": version "0.1.10"