1 | import PropTypes from 'prop-types';
|
2 | import React from 'react';
|
3 | import { ViewStyle, LayoutChangeEvent } from 'react-native';
|
4 | import { AvatarProps } from './Avatar';
|
5 | import Bubble from './Bubble';
|
6 | import { SystemMessageProps } from './SystemMessage';
|
7 | import { DayProps } from './Day';
|
8 | import { IMessage, User, LeftRightStyle } from './Models';
|
9 | export interface MessageProps<TMessage extends IMessage> {
|
10 | showUserAvatar?: boolean;
|
11 | position: 'left' | 'right';
|
12 | currentMessage: TMessage;
|
13 | nextMessage?: TMessage;
|
14 | previousMessage?: TMessage;
|
15 | user: User;
|
16 | inverted?: boolean;
|
17 | containerStyle?: LeftRightStyle<ViewStyle>;
|
18 | renderBubble?(props: Bubble['props']): React.ReactNode;
|
19 | renderDay?(props: DayProps<TMessage>): React.ReactNode;
|
20 | renderSystemMessage?(props: SystemMessageProps<TMessage>): React.ReactNode;
|
21 | renderAvatar?(props: AvatarProps<TMessage>): React.ReactNode;
|
22 | shouldUpdateMessage?(props: MessageProps<IMessage>, nextProps: MessageProps<IMessage>): boolean;
|
23 | onMessageLayout?(event: LayoutChangeEvent): void;
|
24 | }
|
25 | export default class Message<TMessage extends IMessage = IMessage> extends React.Component<MessageProps<TMessage>> {
|
26 | static defaultProps: {
|
27 | renderAvatar: undefined;
|
28 | renderBubble: null;
|
29 | renderDay: null;
|
30 | renderSystemMessage: null;
|
31 | position: string;
|
32 | currentMessage: {};
|
33 | nextMessage: {};
|
34 | previousMessage: {};
|
35 | user: {};
|
36 | containerStyle: {};
|
37 | showUserAvatar: boolean;
|
38 | inverted: boolean;
|
39 | shouldUpdateMessage: undefined;
|
40 | onMessageLayout: undefined;
|
41 | };
|
42 | static propTypes: {
|
43 | renderAvatar: PropTypes.Requireable<(...args: any[]) => any>;
|
44 | showUserAvatar: PropTypes.Requireable<boolean>;
|
45 | renderBubble: PropTypes.Requireable<(...args: any[]) => any>;
|
46 | renderDay: PropTypes.Requireable<(...args: any[]) => any>;
|
47 | renderSystemMessage: PropTypes.Requireable<(...args: any[]) => any>;
|
48 | position: PropTypes.Requireable<string>;
|
49 | currentMessage: PropTypes.Requireable<object>;
|
50 | nextMessage: PropTypes.Requireable<object>;
|
51 | previousMessage: PropTypes.Requireable<object>;
|
52 | user: PropTypes.Requireable<object>;
|
53 | inverted: PropTypes.Requireable<boolean>;
|
54 | containerStyle: PropTypes.Requireable<PropTypes.InferProps<{
|
55 | left: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
|
56 | right: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
|
57 | }>>;
|
58 | shouldUpdateMessage: PropTypes.Requireable<(...args: any[]) => any>;
|
59 | onMessageLayout: PropTypes.Requireable<(...args: any[]) => any>;
|
60 | };
|
61 | shouldComponentUpdate(nextProps: MessageProps<TMessage>): boolean;
|
62 | renderDay(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
63 | renderBubble(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
64 | renderSystemMessage(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
65 | renderAvatar(): React.JSX.Element | null;
|
66 | render(): React.JSX.Element | null;
|
67 | }
|