import { BottomSheetModal } from '@gorhom/bottom-sheet' import React, { useRef } from 'react' import { StyleSheet, Text, TextStyle, View, ViewStyle } from 'react-native' import { ScrollView } from 'react-native-gesture-handler' import BottomSheetBase from 'src/components/BottomSheetBase' import BottomSheetScrollView from 'src/components/BottomSheetScrollView' import { typeScale } from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' interface Props { forwardedRef: React.RefObject title?: string | null titleStyle?: TextStyle description?: string | null children?: React.ReactNode | React.ReactNode[] onClose?: () => void onOpen?: () => void snapPoints?: (string | number)[] contentContainerStyle?: ViewStyle stickyTitle?: boolean stickyHeaderComponent?: React.ReactNode testId?: string } export type BottomSheetModalRefType = BottomSheetModal const BottomSheet = ({ forwardedRef, title, titleStyle = typeScale.titleSmall, description, children, onClose, onOpen, snapPoints, stickyTitle, stickyHeaderComponent, testId, }: Props) => { const scrollViewRef = useRef(null) const hasStickyHeader = stickyTitle || stickyHeaderComponent return ( {!!hasStickyHeader && ( {stickyTitle && {title}} {stickyHeaderComponent} )} {!stickyTitle && !!title && ( {title} )} {!!description && {description}} {children} ) } const styles = StyleSheet.create({ headerContentSpacing: { paddingBottom: Spacing.Small12, }, stickyHeaderContainer: { padding: Spacing.Thick24, }, description: { ...typeScale.bodySmall, marginBottom: Spacing.Smallest8, }, }) export default BottomSheet