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