import React, { useContext } from 'react'; import { getDisplayName } from '../utils/getDisplayName'; import type { BottomSheetMethods } from '@gorhom/bottom-sheet/lib/typescript/types'; import type { AttachmentPickerContextValue } from '../attachmentPickerContext/AttachmentPickerContext'; import type { MessageOverlayContextValue } from '../messageOverlayContext/MessageOverlayContext'; import type { DeepPartial } from '../themeContext/ThemeContext'; import type { Theme } from '../themeContext/utils/theme'; import type { AttachmentPickerProps } from '../../components/AttachmentPicker/AttachmentPicker'; import type { ImageGalleryCustomComponents } from '../../components/ImageGallery/ImageGallery'; import type { DefaultAttachmentType, DefaultChannelType, DefaultCommandType, DefaultEventType, DefaultMessageType, DefaultReactionType, DefaultUserType, UnknownType, } from '../../types/types'; import type { Streami18n } from '../../utils/Streami18n'; export type BlurType = 'light' | 'dark' | undefined; export type Overlay = 'alert' | 'gallery' | 'message' | 'none'; export type OverlayContextValue = { overlay: Overlay; setBlurType: React.Dispatch>; setOverlay: React.Dispatch>; style?: DeepPartial; translucentStatusBar?: boolean; }; export const OverlayContext = React.createContext({} as OverlayContextValue); export type OverlayProviderProps< At extends UnknownType = DefaultAttachmentType, Ch extends UnknownType = DefaultChannelType, Co extends string = DefaultCommandType, Ev extends UnknownType = DefaultEventType, Me extends UnknownType = DefaultMessageType, Re extends UnknownType = DefaultReactionType, Us extends UnknownType = DefaultUserType, > = Partial & Partial< Pick< AttachmentPickerContextValue, | 'attachmentPickerBottomSheetHeight' | 'attachmentSelectionBarHeight' | 'bottomInset' | 'CameraSelectorIcon' | 'FileSelectorIcon' | 'ImageSelectorIcon' | 'topInset' > > & ImageGalleryCustomComponents & Partial< Pick< MessageOverlayContextValue, 'MessageActions' | 'OverlayReactionList' | 'OverlayReactions' > > & Pick & { closePicker?: (ref: React.RefObject) => void; /** https://github.com/GetStream/stream-chat-react-native/wiki/Internationalization-(i18n) */ i18nInstance?: Streami18n; imageGalleryGridHandleHeight?: number; imageGalleryGridSnapPoints?: [string | number, string | number]; numberOfImageGalleryGridColumns?: number; openPicker?: (ref: React.RefObject) => void; value?: Partial; }; export const useOverlayContext = () => useContext(OverlayContext); export const withOverlayContext =

( Component: React.ComponentType

, ): React.FC> => { const WithOverlayContextComponent = (props: Omit) => { const overlayContext = useOverlayContext(); return ; }; WithOverlayContextComponent.displayName = `WithOverlayContext${getDisplayName(Component)}`; return WithOverlayContextComponent; };