import React from 'react'; import { ImageStyle, Text, TextStyle, TouchableOpacity, View, ViewStyle } from 'react-native'; import { useTheme, useCompTheme } from '../../theme/hook'; import { CometChatTheme } from '../../theme/type'; import { deepMerge } from '../helper/helperFunctions'; import { Icon } from '../icons/Icon'; export interface CometChatComposerErrorBannerProps { /** Message to show; `null`/empty hides the banner. */ message: string | null; /** Called when the ✕ is tapped. */ onDismiss: () => void; /** Per-instance style overrides (applied over the tokenized defaults) — same pattern as the * bubbles (e.g. CometChatFilesBubble / CometChatAudiosBubble). A developer can also override * globally via `theme.composerErrorBannerStyles` or at the component level via the theme provider. */ style?: CometChatTheme["composerErrorBannerStyles"]; } /** * A red error/info bar shown just ABOVE the composer's attachment tray — e.g. "File exceeds 100 MB" * when an oversized file is rejected. Lives inside the composer (not a screen-bottom toast) so it * reads as part of the compose surface. The composer owns the message + auto-dismiss timer; the ✕ * dismisses it immediately. * * Styling follows the standard component pattern: tokenized defaults are computed inline, then the * merged overrides (theme → component theme → per-instance `style`) are layered on top. */ export function CometChatComposerErrorBanner({ message, onDismiss, style }: CometChatComposerErrorBannerProps) { const theme = useTheme(); const compTheme = useCompTheme(); const s = deepMerge( theme.composerErrorBannerStyles ?? {}, compTheme.composerErrorBannerStyles ?? {}, style ?? {} ); if (!message) return null; const S = theme.spacing; return ( {message} ); }