This commit is contained in:
Hailey
2024-10-01 15:57:19 -07:00
parent d0149a96bc
commit 40030ba0da
+7 -32
View File
@@ -1,5 +1,5 @@
import React, {useImperativeHandle} from 'react' import React, {useImperativeHandle} from 'react'
import {ScrollView, StyleProp, View, ViewStyle} from 'react-native' import {StyleProp, View, ViewStyle} from 'react-native'
import {useSafeAreaInsets} from 'react-native-safe-area-context' import {useSafeAreaInsets} from 'react-native-safe-area-context'
import { import {
BottomSheetFlatList, BottomSheetFlatList,
@@ -12,6 +12,7 @@ import {BlueskyBottomSheetView} from '@haileyok/bluesky-bottom-sheet'
import {logger} from '#/logger' import {logger} from '#/logger'
import {useDialogStateControlContext} from '#/state/dialogs' import {useDialogStateControlContext} from '#/state/dialogs'
import {ScrollView} from '#/view/com/util/Views'
import {atoms as a, flatten, useTheme} from '#/alf' import {atoms as a, flatten, useTheme} from '#/alf'
import {Context} from '#/components/Dialog/context' import {Context} from '#/components/Dialog/context'
import { import {
@@ -41,7 +42,6 @@ export function Outer({
const closeCallbacks = React.useRef<(() => void)[]>([]) const closeCallbacks = React.useRef<(() => void)[]>([])
const {setDialogIsOpen} = useDialogStateControlContext() const {setDialogIsOpen} = useDialogStateControlContext()
// @TODO DIALOG REFACTOR - can i get rid of this? seems pointless tbh // @TODO DIALOG REFACTOR - can i get rid of this? seems pointless tbh
const [isOpen, setIsOpen] = React.useState(false)
const callQueuedCallbacks = React.useCallback(() => { const callQueuedCallbacks = React.useCallback(() => {
for (const cb of closeCallbacks.current) { for (const cb of closeCallbacks.current) {
@@ -58,14 +58,12 @@ export function Outer({
const open = React.useCallback<DialogControlProps['open']>(() => { const open = React.useCallback<DialogControlProps['open']>(() => {
// Run any leftover callbacks that might have been queued up before calling `.open()` // Run any leftover callbacks that might have been queued up before calling `.open()`
callQueuedCallbacks() callQueuedCallbacks()
setIsOpen(true)
setDialogIsOpen(control.id, true) setDialogIsOpen(control.id, true)
ref.current?.present() ref.current?.present()
}, [setDialogIsOpen, control.id, callQueuedCallbacks]) }, [setDialogIsOpen, control.id, callQueuedCallbacks])
// This is the function that we call when we want to dismiss the dialog. // This is the function that we call when we want to dismiss the dialog.
const close = React.useCallback<DialogControlProps['close']>(cb => { const close = React.useCallback<DialogControlProps['close']>(cb => {
setIsOpen(false)
if (typeof cb === 'function') { if (typeof cb === 'function') {
closeCallbacks.current.push(cb) closeCallbacks.current.push(cb)
} }
@@ -106,26 +104,15 @@ export function Outer({
<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!*/
ref={ref} ref={ref}
topInset={insets.top} topInset={30}
bottomInset={insets.bottom} bottomInset={insets.bottom}
onStateChange={e => { onStateChange={e => {
if (e.nativeEvent.state === 'closed') { if (e.nativeEvent.state === 'closed') {
onCloseAnimationComplete() onCloseAnimationComplete()
} }
}}> }}
cornerRadius={20}>
<View testID={testID} style={[t.atoms.bg]}> <View testID={testID} style={[t.atoms.bg]}>
{/*<View*/}
{/* style={[*/}
{/* a.absolute,*/}
{/* a.inset_0,*/}
{/* t.atoms.bg,*/}
{/* {*/}
{/* borderTopLeftRadius: 40,*/}
{/* borderTopRightRadius: 40,*/}
{/* height: Dimensions.get('window').height * 2,*/}
{/* },*/}
{/* ]}*/}
{/*/>*/}
{children} {children}
</View> </View>
</BlueskyBottomSheetView> </BlueskyBottomSheetView>
@@ -158,22 +145,10 @@ export const ScrollableInner = React.forwardRef<ScrollView, DialogInnerProps>(
function ScrollableInner({children, style}, ref) { function ScrollableInner({children, style}, ref) {
const insets = useSafeAreaInsets() const insets = useSafeAreaInsets()
return ( return (
<View <ScrollView style={[a.px_xl, style]} ref={ref}>
// style={[
// a.p_xl,
// a.h_full,
// {
// paddingTop: 40,
// borderTopLeftRadius: 40,
// borderTopRightRadius: 40,
// },
// style,
// ]}
// ref={ref}
>
{children} {children}
<View style={{height: insets.bottom + a.pt_5xl.paddingTop}} /> <View style={{height: insets.bottom + a.pt_5xl.paddingTop}} />
</View> </ScrollView>
) )
}, },
) )