UNPKG

8.28 kBTypeScriptView Raw
1import PropTypes from 'prop-types';
2import React from 'react';
3import { StyleProp, ViewStyle, TextStyle } from 'react-native';
4import { QuickRepliesProps } from './QuickReplies';
5import { MessageTextProps } from './MessageText';
6import { MessageImageProps } from './MessageImage';
7import { TimeProps } from './Time';
8import { User, IMessage, LeftRightStyle, Reply, Omit, MessageVideoProps, MessageAudioProps } from './Models';
9export type RenderMessageImageProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageImageProps<TMessage>;
10export type RenderMessageVideoProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageVideoProps<TMessage>;
11export type RenderMessageAudioProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageAudioProps<TMessage>;
12export type RenderMessageTextProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageTextProps<TMessage>;
13export interface BubbleProps<TMessage extends IMessage> {
14 user?: User;
15 touchableProps?: object;
16 renderUsernameOnMessage?: boolean;
17 isCustomViewBottom?: boolean;
18 inverted?: boolean;
19 position: 'left' | 'right';
20 currentMessage: TMessage;
21 nextMessage?: TMessage;
22 previousMessage?: TMessage;
23 optionTitles?: string[];
24 containerStyle?: LeftRightStyle<ViewStyle>;
25 wrapperStyle?: LeftRightStyle<ViewStyle>;
26 textStyle?: LeftRightStyle<TextStyle>;
27 bottomContainerStyle?: LeftRightStyle<ViewStyle>;
28 tickStyle?: StyleProp<TextStyle>;
29 containerToNextStyle?: LeftRightStyle<ViewStyle>;
30 containerToPreviousStyle?: LeftRightStyle<ViewStyle>;
31 usernameStyle?: TextStyle;
32 quickReplyStyle?: StyleProp<ViewStyle>;
33 quickReplyTextStyle?: StyleProp<TextStyle>;
34 quickReplyContainerStyle?: StyleProp<ViewStyle>;
35 onPress?(context?: unknown, message?: unknown): void;
36 onLongPress?(context?: unknown, message?: unknown): void;
37 onQuickReply?(replies: Reply[]): void;
38 renderMessageImage?(props: RenderMessageImageProps<TMessage>): React.ReactNode;
39 renderMessageVideo?(props: RenderMessageVideoProps<TMessage>): React.ReactNode;
40 renderMessageAudio?(props: RenderMessageAudioProps<TMessage>): React.ReactNode;
41 renderMessageText?(props: RenderMessageTextProps<TMessage>): React.ReactNode;
42 renderCustomView?(bubbleProps: BubbleProps<TMessage>): React.ReactNode;
43 renderTime?(timeProps: TimeProps<TMessage>): React.ReactNode;
44 renderTicks?(currentMessage: TMessage): React.ReactNode;
45 renderUsername?(user?: TMessage['user']): React.ReactNode;
46 renderQuickReplySend?(): React.ReactNode;
47 renderQuickReplies?(quickReplies: QuickRepliesProps<TMessage>): React.ReactNode;
48}
49export default class Bubble<TMessage extends IMessage = IMessage> extends React.Component<BubbleProps<TMessage>> {
50 static contextType: React.Context<import("./GiftedChatContext").IGiftedChatContext>;
51 static defaultProps: {
52 touchableProps: {};
53 onPress: null;
54 onLongPress: null;
55 renderMessageImage: null;
56 renderMessageVideo: null;
57 renderMessageAudio: null;
58 renderMessageText: null;
59 renderCustomView: null;
60 renderUsername: null;
61 renderTicks: null;
62 renderTime: null;
63 renderQuickReplies: null;
64 onQuickReply: null;
65 position: string;
66 currentMessage: {
67 text: null;
68 createdAt: null;
69 image: null;
70 };
71 nextMessage: {};
72 previousMessage: {};
73 containerStyle: {};
74 wrapperStyle: {};
75 bottomContainerStyle: {};
76 tickStyle: {};
77 usernameStyle: {};
78 containerToNextStyle: {};
79 containerToPreviousStyle: {};
80 };
81 static propTypes: {
82 user: PropTypes.Validator<object>;
83 touchableProps: PropTypes.Requireable<object>;
84 onLongPress: PropTypes.Requireable<(...args: any[]) => any>;
85 renderMessageImage: PropTypes.Requireable<(...args: any[]) => any>;
86 renderMessageVideo: PropTypes.Requireable<(...args: any[]) => any>;
87 renderMessageAudio: PropTypes.Requireable<(...args: any[]) => any>;
88 renderMessageText: PropTypes.Requireable<(...args: any[]) => any>;
89 renderCustomView: PropTypes.Requireable<(...args: any[]) => any>;
90 isCustomViewBottom: PropTypes.Requireable<boolean>;
91 renderUsernameOnMessage: PropTypes.Requireable<boolean>;
92 renderUsername: PropTypes.Requireable<(...args: any[]) => any>;
93 renderTime: PropTypes.Requireable<(...args: any[]) => any>;
94 renderTicks: PropTypes.Requireable<(...args: any[]) => any>;
95 renderQuickReplies: PropTypes.Requireable<(...args: any[]) => any>;
96 onQuickReply: PropTypes.Requireable<(...args: any[]) => any>;
97 position: PropTypes.Requireable<string>;
98 optionTitles: PropTypes.Requireable<(string | null | undefined)[]>;
99 currentMessage: PropTypes.Requireable<object>;
100 nextMessage: PropTypes.Requireable<object>;
101 previousMessage: PropTypes.Requireable<object>;
102 containerStyle: PropTypes.Requireable<PropTypes.InferProps<{
103 left: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
104 right: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
105 }>>;
106 wrapperStyle: PropTypes.Requireable<PropTypes.InferProps<{
107 left: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
108 right: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
109 }>>;
110 bottomContainerStyle: PropTypes.Requireable<PropTypes.InferProps<{
111 left: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
112 right: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
113 }>>;
114 tickStyle: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
115 usernameStyle: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
116 containerToNextStyle: PropTypes.Requireable<PropTypes.InferProps<{
117 left: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
118 right: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
119 }>>;
120 containerToPreviousStyle: PropTypes.Requireable<PropTypes.InferProps<{
121 left: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
122 right: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
123 }>>;
124 };
125 onPress: () => void;
126 onLongPress: () => void;
127 styledBubbleToNext(): (StyleProp<ViewStyle> | {
128 borderBottomLeftRadius: number;
129 } | {
130 borderBottomRightRadius: number;
131 })[] | null;
132 styledBubbleToPrevious(): (StyleProp<ViewStyle> | {
133 borderTopLeftRadius: number;
134 } | {
135 borderTopRightRadius: number;
136 })[] | null;
137 renderQuickReplies(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
138 renderMessageText(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
139 renderMessageImage(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
140 renderMessageVideo(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
141 renderMessageAudio(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
142 renderTicks(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
143 renderTime(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
144 renderUsername(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
145 renderCustomView(): React.ReactNode;
146 renderBubbleContent(): React.JSX.Element;
147 render(): React.JSX.Element;
148}