react-native-gifted-chat-flashlist
Version:
React Native Gifted Chat with FlashList optimization for better performance
125 lines (124 loc) • 6.01 kB
TypeScript
import React from 'react';
import { ActionSheetOptions } from '@expo/react-native-action-sheet';
import { StyleProp, TextInput, TextStyle, ViewStyle } from 'react-native';
import { FlashList } from '@shopify/flash-list';
import { LightboxProps } from 'react-native-lightbox-v2';
import { Actions, ActionsProps } from './Actions';
import { Avatar, AvatarProps } from './Avatar';
import Bubble from './Bubble';
import { Composer, ComposerProps } from './Composer';
import { Day, DayProps } from './Day';
import { GiftedAvatar } from './GiftedAvatar';
import { InputToolbar, InputToolbarProps } from './InputToolbar';
import { LoadEarlier, LoadEarlierProps } from './LoadEarlier';
import Message from './Message';
import MessageContainer from './MessageContainer';
import { MessageImage, MessageImageProps } from './MessageImage';
import { MessageText, MessageTextProps } from './MessageText';
import { IMessage, LeftRightStyle, MessageAudioProps, MessageVideoProps, Reply, User } from './Models';
import { QuickRepliesProps } from './QuickReplies';
import { Send, SendProps } from './Send';
import { SystemMessage, SystemMessageProps } from './SystemMessage';
import { Time, TimeProps } from './Time';
import * as utils from './utils';
export interface GiftedChatProps<TMessage extends IMessage = IMessage> {
messageContainerRef?: React.RefObject<FlashList<IMessage>>;
textInputRef?: React.RefObject<TextInput>;
messages?: TMessage[];
isTyping?: boolean;
renderUsernameOnMessage?: boolean;
messagesContainerStyle?: StyleProp<ViewStyle>;
text?: string;
alignTop?: boolean;
scrollToBottom?: boolean;
scrollToBottomStyle?: StyleProp<ViewStyle>;
initialText?: string;
placeholder?: string;
disableComposer?: boolean;
user?: User;
locale?: string;
timeFormat?: string;
dateFormat?: string;
loadEarlier?: boolean;
isLoadingEarlier?: boolean;
showUserAvatar?: boolean;
showAvatarForEveryMessage?: boolean;
renderAvatarOnTop?: boolean;
inverted?: boolean;
imageProps?: Message<TMessage>['props'];
lightboxProps?: LightboxProps;
bottomOffset?: number;
minInputToolbarHeight?: number;
listViewProps?: object;
textInputProps?: object;
keyboardShouldPersistTaps?: 'always' | 'never' | 'handled';
maxInputLength?: number;
alwaysShowSend?: boolean;
imageStyle?: StyleProp<ViewStyle>;
extraData?: object;
minComposerHeight?: number;
maxComposerHeight?: number;
options?: {
[key: string]: () => void;
};
optionTintColor?: string;
quickReplyStyle?: StyleProp<ViewStyle>;
quickReplyTextStyle?: StyleProp<TextStyle>;
quickReplyContainerStyle?: StyleProp<ViewStyle>;
isCustomViewBottom?: boolean;
infiniteScroll?: boolean;
timeTextStyle?: LeftRightStyle<TextStyle>;
actionSheet?(): {
showActionSheetWithOptions: (options: ActionSheetOptions, callback: (buttonIndex: number) => void | Promise<void>) => void;
};
onPressAvatar?(user: User): void;
onLongPressAvatar?(user: User): void;
messageIdGenerator?(message?: TMessage): string;
onSend?(messages: TMessage[]): void;
onLoadEarlier?(): void;
renderLoading?(): React.ReactNode;
renderLoadEarlier?(props: LoadEarlierProps): React.ReactNode;
renderAvatar?: null | ((props: AvatarProps<TMessage>) => React.ReactNode);
renderBubble?(props: Bubble<TMessage>['props']): React.ReactNode;
renderSystemMessage?(props: SystemMessageProps<TMessage>): React.ReactNode;
onPress?(context: unknown, message: TMessage): void;
onLongPress?(context: unknown, message: TMessage): void;
renderUsername?(user: User): React.ReactNode;
renderMessage?(message: Message<TMessage>['props']): React.ReactElement;
renderMessageText?(messageText: MessageTextProps<TMessage>): React.ReactNode;
renderMessageImage?(props: MessageImageProps<TMessage>): React.ReactNode;
renderMessageVideo?(props: MessageVideoProps<TMessage>): React.ReactNode;
renderMessageAudio?(props: MessageAudioProps<TMessage>): React.ReactNode;
renderCustomView?(props: Bubble<TMessage>['props']): React.ReactNode;
renderDay?(props: DayProps<TMessage>): React.ReactNode;
renderTime?(props: TimeProps<TMessage>): React.ReactNode;
renderFooter?(): React.ReactNode;
renderChatEmpty?(): React.ReactNode;
renderChatFooter?(): React.ReactNode;
renderInputToolbar?(props: InputToolbarProps<TMessage>): React.ReactNode;
renderComposer?(props: ComposerProps): React.ReactNode;
renderActions?(props: ActionsProps): React.ReactNode;
renderSend?(props: SendProps<TMessage>): React.ReactNode;
renderAccessory?(props: InputToolbarProps<TMessage>): React.ReactNode;
onPressActionButton?(): void;
onInputTextChanged?(text: string): void;
parsePatterns?: (linkStyle?: TextStyle) => {
type?: string;
pattern?: RegExp;
style?: StyleProp<TextStyle> | object;
onPress?: unknown;
renderText?: unknown;
}[];
onQuickReply?(replies: Reply[]): void;
renderQuickReplies?(quickReplies: QuickRepliesProps<TMessage>): React.ReactNode;
renderQuickReplySend?(): React.ReactNode;
scrollToBottomComponent?(): React.ReactNode;
shouldUpdateMessage?(props: Message<TMessage>['props'], nextProps: Message<TMessage>['props']): boolean;
}
declare function GiftedChat<TMessage extends IMessage = IMessage>(props: GiftedChatProps): React.JSX.Element;
declare namespace GiftedChat {
var append: <TMessage extends IMessage>(currentMessages: TMessage[] | undefined, messages: TMessage[], inverted?: boolean) => TMessage[];
var prepend: <TMessage extends IMessage>(currentMessages: TMessage[] | undefined, messages: TMessage[], inverted?: boolean) => TMessage[];
}
export * from './Models';
export { GiftedChat, Actions, Avatar, Bubble, SystemMessage, MessageImage, MessageText, Composer, Day, InputToolbar, LoadEarlier, Message, MessageContainer, Send, Time, GiftedAvatar, utils };