UNPKG

4.41 kBTypeScriptView Raw
1import PropTypes from 'prop-types';
2import React, { RefObject } from 'react';
3import { FlatList, ListViewProps, ListRenderItemInfo, NativeSyntheticEvent, NativeScrollEvent, StyleProp, ViewStyle } from 'react-native';
4import LoadEarlier from './LoadEarlier';
5import Message from './Message';
6import { User, IMessage, Reply } from './Models';
7export interface MessageContainerProps<TMessage extends IMessage> {
8 messages?: TMessage[];
9 isTyping?: boolean;
10 user?: User;
11 listViewProps: Partial<ListViewProps>;
12 inverted?: boolean;
13 loadEarlier?: boolean;
14 alignTop?: boolean;
15 scrollToBottom?: boolean;
16 scrollToBottomStyle?: StyleProp<ViewStyle>;
17 invertibleScrollViewProps?: any;
18 extraData?: any;
19 scrollToBottomOffset?: number;
20 forwardRef?: RefObject<FlatList<IMessage>>;
21 renderChatEmpty?(): React.ReactNode;
22 renderFooter?(props: MessageContainerProps<TMessage>): React.ReactNode;
23 renderMessage?(props: Message['props']): React.ReactNode;
24 renderLoadEarlier?(props: LoadEarlier['props']): React.ReactNode;
25 scrollToBottomComponent?(): React.ReactNode;
26 onLoadEarlier?(): void;
27 onQuickReply?(replies: Reply[]): void;
28 infiniteScroll?: boolean;
29 isLoadingEarlier?: boolean;
30}
31interface State {
32 showScrollBottom: boolean;
33}
34export default class MessageContainer<TMessage extends IMessage = IMessage> extends React.PureComponent<MessageContainerProps<TMessage>, State> {
35 static defaultProps: {
36 messages: never[];
37 user: {};
38 isTyping: boolean;
39 renderChatEmpty: null;
40 renderFooter: null;
41 renderMessage: null;
42 onLoadEarlier: () => void;
43 onQuickReply: () => void;
44 inverted: boolean;
45 loadEarlier: boolean;
46 listViewProps: {};
47 invertibleScrollViewProps: {};
48 extraData: null;
49 scrollToBottom: boolean;
50 scrollToBottomOffset: number;
51 alignTop: boolean;
52 scrollToBottomStyle: {};
53 infiniteScroll: boolean;
54 isLoadingEarlier: boolean;
55 };
56 static propTypes: {
57 messages: PropTypes.Requireable<(object | null | undefined)[]>;
58 isTyping: PropTypes.Requireable<boolean>;
59 user: PropTypes.Requireable<object>;
60 renderChatEmpty: PropTypes.Requireable<(...args: any[]) => any>;
61 renderFooter: PropTypes.Requireable<(...args: any[]) => any>;
62 renderMessage: PropTypes.Requireable<(...args: any[]) => any>;
63 renderLoadEarlier: PropTypes.Requireable<(...args: any[]) => any>;
64 onLoadEarlier: PropTypes.Requireable<(...args: any[]) => any>;
65 listViewProps: PropTypes.Requireable<object>;
66 inverted: PropTypes.Requireable<boolean>;
67 loadEarlier: PropTypes.Requireable<boolean>;
68 invertibleScrollViewProps: PropTypes.Requireable<object>;
69 extraData: PropTypes.Requireable<any[]>;
70 scrollToBottom: PropTypes.Requireable<boolean>;
71 scrollToBottomOffset: PropTypes.Requireable<number>;
72 scrollToBottomComponent: PropTypes.Requireable<(...args: any[]) => any>;
73 alignTop: PropTypes.Requireable<boolean>;
74 scrollToBottomStyle: PropTypes.Requireable<number | boolean | object>;
75 infiniteScroll: PropTypes.Requireable<boolean>;
76 };
77 state: {
78 showScrollBottom: boolean;
79 };
80 componentDidMount(): void;
81 componentWillUnmount(): void;
82 componentDidUpdate(prevProps: MessageContainerProps<TMessage>): void;
83 attachKeyboardListeners: () => void;
84 detachKeyboardListeners: () => void;
85 renderTypingIndicator: () => JSX.Element | null;
86 renderFooter: () => {} | null | undefined;
87 renderLoadEarlier: () => {} | null | undefined;
88 scrollTo(options: {
89 animated?: boolean;
90 offset: number;
91 }): void;
92 scrollToBottom: (animated?: boolean) => void;
93 handleOnScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
94 renderRow: ({ item, index }: ListRenderItemInfo<TMessage>) => {} | null | undefined;
95 renderChatEmpty: () => {} | null | undefined;
96 renderHeaderWrapper: () => JSX.Element;
97 renderScrollBottomComponent(): {} | null | undefined;
98 renderScrollToBottomWrapper(): JSX.Element;
99 onLayoutList: () => void;
100 onEndReached: ({ distanceFromEnd }: {
101 distanceFromEnd: number;
102 }) => void;
103 keyExtractor: (item: TMessage) => string;
104 render(): JSX.Element;
105}
106export {};