react-native-gifted-chat 2.8.0 → 2.8.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -5
- package/lib/Bubble/index.d.ts +3 -27
- package/lib/Bubble/index.js +138 -125
- package/lib/Bubble/index.js.map +1 -1
- package/lib/Bubble/types.d.ts +3 -3
- package/lib/GiftedChat/index.js +19 -4
- package/lib/GiftedChat/index.js.map +1 -1
- package/lib/GiftedChat/types.d.ts +5 -10
- package/lib/Message/index.js +7 -12
- package/lib/Message/index.js.map +1 -1
- package/lib/Message/types.d.ts +2 -2
- package/lib/MessageContainer/components/Item/index.js +3 -1
- package/lib/MessageContainer/components/Item/index.js.map +1 -1
- package/lib/MessageContainer/index.js +69 -46
- package/lib/MessageContainer/index.js.map +1 -1
- package/lib/MessageContainer/styles.d.ts +3 -2
- package/lib/MessageContainer/styles.js +3 -2
- package/lib/MessageContainer/styles.js.map +1 -1
- package/lib/MessageContainer/types.d.ts +6 -9
- package/lib/MessageText.d.ts +11 -7
- package/lib/MessageText.js +57 -96
- package/lib/MessageText.js.map +1 -1
- package/lib/SystemMessage.d.ts +2 -1
- package/lib/SystemMessage.js +3 -2
- package/lib/SystemMessage.js.map +1 -1
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +66 -0
- package/lib/utils.js.map +1 -1
- package/package.json +37 -30
- package/src/Bubble/index.tsx +171 -172
- package/src/Bubble/types.ts +3 -3
- package/src/GiftedChat/index.tsx +23 -3
- package/src/GiftedChat/types.ts +6 -4
- package/src/Message/index.tsx +10 -16
- package/src/Message/types.ts +2 -2
- package/src/MessageContainer/components/Item/index.tsx +1 -0
- package/src/MessageContainer/index.tsx +93 -58
- package/src/MessageContainer/styles.ts +3 -2
- package/src/MessageContainer/types.ts +6 -9
- package/src/MessageText.tsx +86 -121
- package/src/SystemMessage.tsx +4 -1
- package/src/__tests__/DayAnimated.test.tsx +54 -0
- package/src/__tests__/GiftedChat.test.tsx +25 -0
- package/src/__tests__/__snapshots__/DayAnimated.test.tsx.snap +5 -0
- package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +25 -0
- package/src/__tests__/__snapshots__/MessageContainer.test.tsx.snap +11 -9
- package/src/utils.ts +77 -1
package/README.md
CHANGED
|
@@ -78,6 +78,10 @@
|
|
|
78
78
|
<a href="https://bit.ly/ethorachat" target="_blank">Check out our GitHub</a>
|
|
79
79
|
</p>
|
|
80
80
|
</p>
|
|
81
|
+
<br>
|
|
82
|
+
<p align="center">
|
|
83
|
+
<a href="https://amzn.to/3ZmTyb2" target="_blank">React Key Concepts: Consolidate your knowledge of React’s core features (2nd ed. Edition)</a>
|
|
84
|
+
</p>
|
|
81
85
|
|
|
82
86
|
## Features
|
|
83
87
|
|
|
@@ -99,6 +103,14 @@
|
|
|
99
103
|
|
|
100
104
|
# Getting started
|
|
101
105
|
|
|
106
|
+
## 🚧👷 Important notice
|
|
107
|
+
|
|
108
|
+
There's currently WIP going on to make the library more performant, modern in terms of chat UI and easier to maintain. If you have any issues, please report them. If you want to contribute, please do so.
|
|
109
|
+
|
|
110
|
+
The most stable version is `2.6.5`. If you want to use the latest version, please be aware that it's a work in progress.
|
|
111
|
+
|
|
112
|
+
Readme for this version: [2.6.5 readme](https://github.com/FaridSafi/react-native-gifted-chat/blob/eebab3751fcbe07715135e6e7b2aa3f76a10d8ac/README.md)
|
|
113
|
+
|
|
102
114
|
## Installation
|
|
103
115
|
|
|
104
116
|
### Install dependencies
|
|
@@ -343,6 +355,7 @@ interface QuickReplies {
|
|
|
343
355
|
- **`messages`** _(Array)_ - Messages to display
|
|
344
356
|
- **`isTyping`** _(Bool)_ - Typing Indicator state; default `false`. If you use`renderFooter` it will override this.
|
|
345
357
|
- **`isKeyboardInternallyHandled`** _(Bool)_ - Determine whether to handle keyboard awareness inside the plugin. If you have your own keyboard handling outside the plugin set this to false; default is `true`
|
|
358
|
+
- **`disableKeyboardController`** _(Bool)_ - Completely disable react-native-keyboard-controller. Useful when using react-native-navigation or other conflicting keyboard libraries; default is `false`
|
|
346
359
|
- **`text`** _(String)_ - Input text; default is `undefined`, but if specified, it will override GiftedChat's internal state (e.g. for redux; [see notes below](#notes-for-redux))
|
|
347
360
|
- **`placeholder`** _(String)_ - Placeholder when `text` is empty; default is `'Type a message...'`
|
|
348
361
|
- **`messageIdGenerator`** _(Function)_ - Generate an id for new messages. Defaults to UUID v4, generated by [uuid](https://github.com/kelektiv/node-uuid)
|
|
@@ -352,7 +365,7 @@ interface QuickReplies {
|
|
|
352
365
|
- **`locale`** _(String)_ - Locale to localize the dates. You need first to import the locale you need (ie. `require('dayjs/locale/de')` or `import 'dayjs/locale/fr'`)
|
|
353
366
|
- **`timeFormat`** _(String)_ - Format to use for rendering times; default is `'LT'` (see [Day.js Format](https://day.js.org/docs/en/display/format))
|
|
354
367
|
- **`dateFormat`** _(String)_ - Format to use for rendering dates; default is `'D MMMM'` (see [Day.js Format](https://day.js.org/docs/en/display/format))
|
|
355
|
-
- **`dateFormatCalendar`** _(
|
|
368
|
+
- **`dateFormatCalendar`** _(Object)_ - Format to use for rendering relative times; default is `{ sameDay: '[Today]' }` (see [Day.js Calendar](https://day.js.org/docs/en/plugin/calendar))
|
|
356
369
|
- **`loadEarlier`** _(Bool)_ - Enables the "load earlier messages" button, required for `infiniteScroll`
|
|
357
370
|
- **`onLoadEarlier`** _(Function)_ - Callback when loading earlier messages
|
|
358
371
|
- **`isLoadingEarlier`** _(Bool)_ - Display an `ActivityIndicator` when loading earlier messages
|
|
@@ -402,13 +415,13 @@ interface QuickReplies {
|
|
|
402
415
|
- **`keyboardShouldPersistTaps`** _(Enum)_ - Determines whether the keyboard should stay visible after a tap; see [`<ScrollView>`](https://facebook.github.io/react-native/docs/scrollview.html) docs
|
|
403
416
|
- **`onInputTextChanged`** _(Function)_ - Callback when the input text changes
|
|
404
417
|
- **`maxInputLength`** _(Integer)_ - Max message composer TextInput length
|
|
405
|
-
- **`
|
|
418
|
+
- **`matchers`** _(Array)_ - Custom matchers for [react-native-autolink](https://github.com/joshswan/react-native-autolink) used to linking message content (like URLs and phone numbers), e.g.:
|
|
406
419
|
|
|
407
420
|
```js
|
|
408
421
|
<GiftedChat
|
|
409
|
-
|
|
410
|
-
{ type: 'phone', style: linkStyle, onPress:
|
|
411
|
-
{ pattern: /#(\w+)/, style:
|
|
422
|
+
matchers={[
|
|
423
|
+
{ type: 'phone', style: linkStyle, onPress: onPressPhoneNumber },
|
|
424
|
+
{ pattern: /#(\w+)/, style: [linkStyle, styles.hashtag], onPress: onPressHashtag },
|
|
412
425
|
]}
|
|
413
426
|
/>
|
|
414
427
|
```
|
package/lib/Bubble/index.d.ts
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { JSX } from 'react';
|
|
2
2
|
import { IMessage } from '../types';
|
|
3
3
|
import { BubbleProps } from './types';
|
|
4
4
|
export * from './types';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
onPress: () => void;
|
|
8
|
-
onLongPress: () => void;
|
|
9
|
-
styledBubbleToNext(): (import("react-native").StyleProp<import("react-native").ViewStyle> | {
|
|
10
|
-
borderBottomLeftRadius: number;
|
|
11
|
-
} | {
|
|
12
|
-
borderBottomRightRadius: number;
|
|
13
|
-
})[] | null;
|
|
14
|
-
styledBubbleToPrevious(): (import("react-native").StyleProp<import("react-native").ViewStyle> | {
|
|
15
|
-
borderTopLeftRadius: number;
|
|
16
|
-
} | {
|
|
17
|
-
borderTopRightRadius: number;
|
|
18
|
-
})[] | null;
|
|
19
|
-
renderQuickReplies(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
20
|
-
renderMessageText(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
21
|
-
renderMessageImage(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
22
|
-
renderMessageVideo(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
23
|
-
renderMessageAudio(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
24
|
-
renderTicks(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
25
|
-
renderTime(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
26
|
-
renderUsername(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
27
|
-
renderCustomView(): React.ReactNode;
|
|
28
|
-
renderBubbleContent(): React.JSX.Element;
|
|
29
|
-
render(): React.JSX.Element;
|
|
30
|
-
}
|
|
5
|
+
declare const Bubble: <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessage>) => JSX.Element;
|
|
6
|
+
export default Bubble;
|
package/lib/Bubble/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
import { Text, TouchableWithoutFeedback, View, } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { useChatContext } from '../GiftedChatContext';
|
|
4
4
|
import { QuickReplies } from '../QuickReplies';
|
|
5
5
|
import { MessageText } from '../MessageText';
|
|
6
6
|
import { MessageImage } from '../MessageImage';
|
|
@@ -11,33 +11,20 @@ import { isSameUser, isSameDay } from '../utils';
|
|
|
11
11
|
import stylesCommon from '../styles';
|
|
12
12
|
import styles from './styles';
|
|
13
13
|
export * from './types';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return;
|
|
29
|
-
const options = optionTitles;
|
|
30
|
-
const cancelButtonIndex = options.length - 1;
|
|
31
|
-
this.context.actionSheet().showActionSheetWithOptions({
|
|
32
|
-
options,
|
|
33
|
-
cancelButtonIndex,
|
|
34
|
-
}, (buttonIndex) => {
|
|
35
|
-
console.log('onLongPress', { buttonIndex });
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
styledBubbleToNext() {
|
|
40
|
-
const { currentMessage, nextMessage, position, containerToNextStyle } = this.props;
|
|
14
|
+
const Bubble = (props) => {
|
|
15
|
+
const { currentMessage, nextMessage, position, containerToNextStyle, previousMessage, containerToPreviousStyle, onQuickReply, renderQuickReplySend, quickReplyStyle, quickReplyTextStyle, quickReplyContainerStyle, containerStyle, wrapperStyle, bottomContainerStyle, onPress: onPressProp, onLongPress: onLongPressProp, } = props;
|
|
16
|
+
const context = useChatContext();
|
|
17
|
+
const onPress = useCallback(() => {
|
|
18
|
+
onPressProp?.(context, currentMessage);
|
|
19
|
+
}, [onPressProp, context, currentMessage]);
|
|
20
|
+
const onLongPress = useCallback(() => {
|
|
21
|
+
onLongPressProp?.(context, currentMessage);
|
|
22
|
+
}, [
|
|
23
|
+
currentMessage,
|
|
24
|
+
context,
|
|
25
|
+
onLongPressProp,
|
|
26
|
+
]);
|
|
27
|
+
const styledBubbleToNext = useCallback(() => {
|
|
41
28
|
if (currentMessage &&
|
|
42
29
|
nextMessage &&
|
|
43
30
|
position &&
|
|
@@ -48,9 +35,13 @@ class Bubble extends React.Component {
|
|
|
48
35
|
containerToNextStyle?.[position],
|
|
49
36
|
];
|
|
50
37
|
return null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
38
|
+
}, [
|
|
39
|
+
currentMessage,
|
|
40
|
+
nextMessage,
|
|
41
|
+
position,
|
|
42
|
+
containerToNextStyle,
|
|
43
|
+
]);
|
|
44
|
+
const styledBubbleToPrevious = useCallback(() => {
|
|
54
45
|
if (currentMessage &&
|
|
55
46
|
previousMessage &&
|
|
56
47
|
position &&
|
|
@@ -58,76 +49,89 @@ class Bubble extends React.Component {
|
|
|
58
49
|
isSameDay(currentMessage, previousMessage))
|
|
59
50
|
return [
|
|
60
51
|
styles[position].containerToPrevious,
|
|
61
|
-
containerToPreviousStyle
|
|
52
|
+
containerToPreviousStyle?.[position],
|
|
62
53
|
];
|
|
63
54
|
return null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
}, [
|
|
56
|
+
currentMessage,
|
|
57
|
+
previousMessage,
|
|
58
|
+
position,
|
|
59
|
+
containerToPreviousStyle,
|
|
60
|
+
]);
|
|
61
|
+
const renderQuickReplies = useCallback(() => {
|
|
67
62
|
if (currentMessage?.quickReplies) {
|
|
68
63
|
const {
|
|
69
64
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
70
65
|
containerStyle, wrapperStyle,
|
|
71
66
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
72
|
-
...quickReplyProps } =
|
|
73
|
-
if (
|
|
74
|
-
return
|
|
67
|
+
...quickReplyProps } = props;
|
|
68
|
+
if (props.renderQuickReplies)
|
|
69
|
+
return props.renderQuickReplies(quickReplyProps);
|
|
75
70
|
return (<QuickReplies currentMessage={currentMessage} onQuickReply={onQuickReply} renderQuickReplySend={renderQuickReplySend} quickReplyStyle={quickReplyStyle} quickReplyTextStyle={quickReplyTextStyle} quickReplyContainerStyle={quickReplyContainerStyle} nextMessage={nextMessage}/>);
|
|
76
71
|
}
|
|
77
72
|
return null;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
}, [
|
|
74
|
+
currentMessage,
|
|
75
|
+
onQuickReply,
|
|
76
|
+
renderQuickReplySend,
|
|
77
|
+
quickReplyStyle,
|
|
78
|
+
quickReplyTextStyle,
|
|
79
|
+
quickReplyContainerStyle,
|
|
80
|
+
nextMessage,
|
|
81
|
+
props,
|
|
82
|
+
]);
|
|
83
|
+
const renderMessageText = useCallback(() => {
|
|
84
|
+
if (currentMessage?.text) {
|
|
81
85
|
const {
|
|
82
86
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
83
|
-
containerStyle, wrapperStyle,
|
|
87
|
+
containerStyle, wrapperStyle,
|
|
84
88
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
85
|
-
...messageTextProps } =
|
|
86
|
-
if (
|
|
87
|
-
return
|
|
89
|
+
...messageTextProps } = props;
|
|
90
|
+
if (props.renderMessageText)
|
|
91
|
+
return props.renderMessageText(messageTextProps);
|
|
88
92
|
return <MessageText {...messageTextProps}/>;
|
|
89
93
|
}
|
|
90
94
|
return null;
|
|
91
|
-
}
|
|
92
|
-
renderMessageImage() {
|
|
93
|
-
if (
|
|
95
|
+
}, [props, currentMessage]);
|
|
96
|
+
const renderMessageImage = useCallback(() => {
|
|
97
|
+
if (currentMessage?.image) {
|
|
94
98
|
const {
|
|
95
99
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
96
100
|
containerStyle, wrapperStyle,
|
|
97
101
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
98
|
-
...messageImageProps } =
|
|
99
|
-
if (
|
|
100
|
-
return
|
|
102
|
+
...messageImageProps } = props;
|
|
103
|
+
if (props.renderMessageImage)
|
|
104
|
+
return props.renderMessageImage(messageImageProps);
|
|
101
105
|
return <MessageImage {...messageImageProps}/>;
|
|
102
106
|
}
|
|
103
107
|
return null;
|
|
104
|
-
}
|
|
105
|
-
renderMessageVideo() {
|
|
106
|
-
if (!
|
|
108
|
+
}, [props, currentMessage]);
|
|
109
|
+
const renderMessageVideo = useCallback(() => {
|
|
110
|
+
if (!currentMessage?.video)
|
|
107
111
|
return null;
|
|
108
112
|
const {
|
|
109
113
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
110
114
|
containerStyle, wrapperStyle,
|
|
111
115
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
112
|
-
...messageVideoProps } =
|
|
113
|
-
if (
|
|
114
|
-
return
|
|
116
|
+
...messageVideoProps } = props;
|
|
117
|
+
if (props.renderMessageVideo)
|
|
118
|
+
return props.renderMessageVideo(messageVideoProps);
|
|
115
119
|
return <MessageVideo />;
|
|
116
|
-
}
|
|
117
|
-
renderMessageAudio() {
|
|
118
|
-
if (!
|
|
120
|
+
}, [props, currentMessage]);
|
|
121
|
+
const renderMessageAudio = useCallback(() => {
|
|
122
|
+
if (!currentMessage?.audio)
|
|
119
123
|
return null;
|
|
120
124
|
const {
|
|
121
125
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
122
126
|
containerStyle, wrapperStyle,
|
|
123
127
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
124
|
-
...messageAudioProps } =
|
|
125
|
-
if (
|
|
126
|
-
return
|
|
128
|
+
...messageAudioProps } = props;
|
|
129
|
+
if (props.renderMessageAudio)
|
|
130
|
+
return props.renderMessageAudio(messageAudioProps);
|
|
127
131
|
return <MessageAudio />;
|
|
128
|
-
}
|
|
129
|
-
renderTicks() {
|
|
130
|
-
const {
|
|
132
|
+
}, [props, currentMessage]);
|
|
133
|
+
const renderTicks = useCallback(() => {
|
|
134
|
+
const { renderTicks, user, } = props;
|
|
131
135
|
if (renderTicks && currentMessage)
|
|
132
136
|
return renderTicks(currentMessage);
|
|
133
137
|
if (user &&
|
|
@@ -137,93 +141,102 @@ class Bubble extends React.Component {
|
|
|
137
141
|
if (currentMessage &&
|
|
138
142
|
(currentMessage.sent || currentMessage.received || currentMessage.pending))
|
|
139
143
|
return (<View style={styles.content.tickView}>
|
|
140
|
-
{!!currentMessage.sent && (<Text style={[styles.content.tick,
|
|
144
|
+
{!!currentMessage.sent && (<Text style={[styles.content.tick, props.tickStyle]}>
|
|
141
145
|
{'✓'}
|
|
142
146
|
</Text>)}
|
|
143
|
-
{!!currentMessage.received && (<Text style={[styles.content.tick,
|
|
147
|
+
{!!currentMessage.received && (<Text style={[styles.content.tick, props.tickStyle]}>
|
|
144
148
|
{'✓'}
|
|
145
149
|
</Text>)}
|
|
146
|
-
{!!currentMessage.pending && (<Text style={[styles.content.tick,
|
|
150
|
+
{!!currentMessage.pending && (<Text style={[styles.content.tick, props.tickStyle]}>
|
|
147
151
|
{'🕓'}
|
|
148
152
|
</Text>)}
|
|
149
153
|
</View>);
|
|
150
154
|
return null;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
155
|
+
}, [
|
|
156
|
+
props,
|
|
157
|
+
currentMessage,
|
|
158
|
+
]);
|
|
159
|
+
const renderTime = useCallback(() => {
|
|
160
|
+
if (currentMessage?.createdAt) {
|
|
154
161
|
const {
|
|
155
162
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
156
163
|
containerStyle, wrapperStyle, textStyle,
|
|
157
164
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
158
|
-
...timeProps } =
|
|
159
|
-
if (
|
|
160
|
-
return
|
|
165
|
+
...timeProps } = props;
|
|
166
|
+
if (props.renderTime)
|
|
167
|
+
return props.renderTime(timeProps);
|
|
161
168
|
return <Time {...timeProps}/>;
|
|
162
169
|
}
|
|
163
170
|
return null;
|
|
164
|
-
}
|
|
165
|
-
renderUsername() {
|
|
166
|
-
const {
|
|
167
|
-
if (
|
|
171
|
+
}, [props, currentMessage]);
|
|
172
|
+
const renderUsername = useCallback(() => {
|
|
173
|
+
const { user, renderUsername, } = props;
|
|
174
|
+
if (props.renderUsernameOnMessage && currentMessage) {
|
|
168
175
|
if (user && currentMessage.user._id === user._id)
|
|
169
176
|
return null;
|
|
170
177
|
if (renderUsername)
|
|
171
178
|
return renderUsername(currentMessage.user);
|
|
172
179
|
return (<View style={styles.content.usernameView}>
|
|
173
|
-
<Text style={[styles.content.username,
|
|
180
|
+
<Text style={[styles.content.username, props.usernameStyle]}>
|
|
174
181
|
{'~ '}
|
|
175
182
|
{currentMessage.user.name}
|
|
176
183
|
</Text>
|
|
177
184
|
</View>);
|
|
178
185
|
}
|
|
179
186
|
return null;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
187
|
+
}, [
|
|
188
|
+
currentMessage,
|
|
189
|
+
props,
|
|
190
|
+
]);
|
|
191
|
+
const renderCustomView = useCallback(() => {
|
|
192
|
+
if (props.renderCustomView)
|
|
193
|
+
return props.renderCustomView(props);
|
|
184
194
|
return null;
|
|
185
|
-
}
|
|
186
|
-
renderBubbleContent() {
|
|
195
|
+
}, [props]);
|
|
196
|
+
const renderBubbleContent = useCallback(() => {
|
|
187
197
|
return (<View>
|
|
188
|
-
{!
|
|
189
|
-
{
|
|
190
|
-
{
|
|
191
|
-
{
|
|
192
|
-
{
|
|
193
|
-
{
|
|
198
|
+
{!props.isCustomViewBottom && renderCustomView()}
|
|
199
|
+
{renderMessageImage()}
|
|
200
|
+
{renderMessageVideo()}
|
|
201
|
+
{renderMessageAudio()}
|
|
202
|
+
{renderMessageText()}
|
|
203
|
+
{props.isCustomViewBottom && renderCustomView()}
|
|
194
204
|
</View>);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
205
|
+
}, [
|
|
206
|
+
renderCustomView,
|
|
207
|
+
renderMessageImage,
|
|
208
|
+
renderMessageVideo,
|
|
209
|
+
renderMessageAudio,
|
|
210
|
+
renderMessageText,
|
|
211
|
+
props.isCustomViewBottom,
|
|
212
|
+
]);
|
|
213
|
+
return (<View style={[
|
|
214
|
+
stylesCommon.fill,
|
|
215
|
+
styles[position].container,
|
|
216
|
+
containerStyle && containerStyle[position],
|
|
217
|
+
]}>
|
|
218
|
+
<View style={[
|
|
219
|
+
styles[position].wrapper,
|
|
220
|
+
styledBubbleToNext(),
|
|
221
|
+
styledBubbleToPrevious(),
|
|
222
|
+
wrapperStyle && wrapperStyle[position],
|
|
223
|
+
]}>
|
|
224
|
+
<TouchableWithoutFeedback onPress={onPress} onLongPress={onLongPress} accessibilityRole='text' {...props.touchableProps}>
|
|
225
|
+
<View>
|
|
226
|
+
{renderBubbleContent()}
|
|
227
|
+
<View style={[
|
|
228
|
+
styles[position].bottom,
|
|
229
|
+
bottomContainerStyle?.[position],
|
|
230
|
+
]}>
|
|
231
|
+
{renderUsername()}
|
|
232
|
+
{renderTime()}
|
|
233
|
+
{renderTicks()}
|
|
220
234
|
</View>
|
|
221
|
-
</
|
|
222
|
-
</
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
Bubble.contextType = GiftedChatContext;
|
|
235
|
+
</View>
|
|
236
|
+
</TouchableWithoutFeedback>
|
|
237
|
+
</View>
|
|
238
|
+
{renderQuickReplies()}
|
|
239
|
+
</View>);
|
|
240
|
+
};
|
|
228
241
|
export default Bubble;
|
|
229
242
|
//# sourceMappingURL=index.js.map
|
package/lib/Bubble/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Bubble/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Bubble/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,MAAM,OAAO,CAAA;AAC/C,OAAO,EACL,IAAI,EACJ,wBAAwB,EACxB,IAAI,GACL,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAE9B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAIhD,OAAO,YAAY,MAAM,WAAW,CAAA;AACpC,OAAO,MAAM,MAAM,UAAU,CAAA;AAE7B,cAAc,SAAS,CAAA;AAEvB,MAAM,MAAM,GAAG,CAAuC,KAA4B,EAAe,EAAE;IACjG,MAAM,EACJ,cAAc,EACd,WAAW,EACX,QAAQ,EACR,oBAAoB,EACpB,eAAe,EACf,wBAAwB,EACxB,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,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vB,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,iBAAiB,CAAC,MAAM,CACxB,IAAI,KAAK,CAAC,cAAc,CAAC,CAEzB;UAAA,CAAC,IAAI,CACH;YAAA,CAAC,mBAAmB,EAAE,CACtB;YAAA,CAAC,IAAI,CACH,KAAK,CAAC,CAAC;YACL,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM;YACvB,oBAAoB,EAAE,CAAC,QAAQ,CAAC;SACjC,CAAC,CAEF;cAAA,CAAC,cAAc,EAAE,CACjB;cAAA,CAAC,UAAU,EAAE,CACb;cAAA,CAAC,WAAW,EAAE,CAChB;YAAA,EAAE,IAAI,CACR;UAAA,EAAE,IAAI,CACR;QAAA,EAAE,wBAAwB,CAC5B;MAAA,EAAE,IAAI,CACN;MAAA,CAAC,kBAAkB,EAAE,CACvB;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/lib/Bubble/types.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
3
3
|
import { QuickRepliesProps } from '../QuickReplies';
|
|
4
|
-
import { MessageTextProps } from '../MessageText';
|
|
4
|
+
import { MessageTextProps, MessageOption } from '../MessageText';
|
|
5
5
|
import { MessageImageProps } from '../MessageImage';
|
|
6
6
|
import { TimeProps } from '../Time';
|
|
7
7
|
import { User, IMessage, LeftRightStyle, Reply, Omit, MessageVideoProps, MessageAudioProps } from '../types';
|
|
8
8
|
export type RenderMessageImageProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageImageProps<TMessage>;
|
|
9
9
|
export type RenderMessageVideoProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageVideoProps<TMessage>;
|
|
10
10
|
export type RenderMessageAudioProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageAudioProps<TMessage>;
|
|
11
|
-
export type RenderMessageTextProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageTextProps<TMessage>;
|
|
11
|
+
export type RenderMessageTextProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle' | 'options'> & MessageTextProps<TMessage>;
|
|
12
12
|
export interface BubbleProps<TMessage extends IMessage> {
|
|
13
13
|
user?: User;
|
|
14
14
|
touchableProps?: object;
|
|
@@ -19,7 +19,7 @@ export interface BubbleProps<TMessage extends IMessage> {
|
|
|
19
19
|
currentMessage: TMessage;
|
|
20
20
|
nextMessage?: TMessage;
|
|
21
21
|
previousMessage?: TMessage;
|
|
22
|
-
|
|
22
|
+
options?: MessageOption[];
|
|
23
23
|
containerStyle?: LeftRightStyle<ViewStyle>;
|
|
24
24
|
wrapperStyle?: LeftRightStyle<ViewStyle>;
|
|
25
25
|
textStyle?: LeftRightStyle<TextStyle>;
|
package/lib/GiftedChat/index.js
CHANGED
|
@@ -35,7 +35,7 @@ function GiftedChat(props) {
|
|
|
35
35
|
ios: 'never',
|
|
36
36
|
android: 'always',
|
|
37
37
|
default: 'never',
|
|
38
|
-
}), onInputTextChanged = null, maxInputLength = null, inverted = true, minComposerHeight = MIN_COMPOSER_HEIGHT, maxComposerHeight = MAX_COMPOSER_HEIGHT, isKeyboardInternallyHandled = true, } = props;
|
|
38
|
+
}), onInputTextChanged = null, maxInputLength = null, inverted = true, minComposerHeight = MIN_COMPOSER_HEIGHT, maxComposerHeight = MAX_COMPOSER_HEIGHT, isKeyboardInternallyHandled = true, disableKeyboardController = false, } = props;
|
|
39
39
|
const actionSheetRef = useRef(null);
|
|
40
40
|
const messageContainerRef = useMemo(() => props.messageContainerRef || createRef(), [props.messageContainerRef]);
|
|
41
41
|
const textInputRef = useMemo(() => props.textInputRef || createRef(), [props.textInputRef]);
|
|
@@ -44,7 +44,14 @@ function GiftedChat(props) {
|
|
|
44
44
|
const [composerHeight, setComposerHeight] = useState(minComposerHeight);
|
|
45
45
|
const [text, setText] = useState(() => props.text || '');
|
|
46
46
|
const [isTypingDisabled, setIsTypingDisabled] = useState(false);
|
|
47
|
-
|
|
47
|
+
// Always call the hook, but conditionally use its data
|
|
48
|
+
const keyboardControllerData = useReanimatedKeyboardAnimation();
|
|
49
|
+
// Create a mock keyboard object when disabled
|
|
50
|
+
const keyboard = useMemo(() => {
|
|
51
|
+
if (disableKeyboardController)
|
|
52
|
+
return { height: { value: 0 } };
|
|
53
|
+
return keyboardControllerData;
|
|
54
|
+
}, [disableKeyboardController, keyboardControllerData]);
|
|
48
55
|
const trackingKeyboardMovement = useSharedValue(false);
|
|
49
56
|
const debounceEnableTypingTimeoutId = useRef(undefined);
|
|
50
57
|
const keyboardOffsetBottom = useSharedValue(0);
|
|
@@ -231,7 +238,11 @@ function GiftedChat(props) {
|
|
|
231
238
|
if (props.text != null)
|
|
232
239
|
setText(props.text);
|
|
233
240
|
}, [props.text]);
|
|
234
|
-
|
|
241
|
+
// Only set up keyboard animation when keyboard controller is enabled
|
|
242
|
+
useAnimatedReaction(() => disableKeyboardController ? 0 : -keyboard.height.value, (value, prevValue) => {
|
|
243
|
+
// Skip keyboard handling when disabled
|
|
244
|
+
if (disableKeyboardController)
|
|
245
|
+
return;
|
|
235
246
|
if (prevValue !== null && value !== prevValue) {
|
|
236
247
|
const isKeyboardMovingUp = value > prevValue;
|
|
237
248
|
if (isKeyboardMovingUp !== trackingKeyboardMovement.value) {
|
|
@@ -264,12 +275,13 @@ function GiftedChat(props) {
|
|
|
264
275
|
disableTyping,
|
|
265
276
|
debounceEnableTyping,
|
|
266
277
|
bottomOffset,
|
|
278
|
+
disableKeyboardController,
|
|
267
279
|
]);
|
|
268
280
|
return (<GiftedChatContext.Provider value={contextValues}>
|
|
269
281
|
<ActionSheetProvider ref={actionSheetRef}>
|
|
270
282
|
<View testID={TEST_ID.WRAPPER} style={[stylesCommon.fill, styles.contentContainer]} onLayout={onInitialLayoutViewLayout}>
|
|
271
283
|
{isInitialized
|
|
272
|
-
? (<Animated.View style={[stylesCommon.fill, isKeyboardInternallyHandled && contentStyleAnim]}>
|
|
284
|
+
? (<Animated.View style={[stylesCommon.fill, (isKeyboardInternallyHandled && !disableKeyboardController) && contentStyleAnim]}>
|
|
273
285
|
{renderMessages}
|
|
274
286
|
{inputToolbarFragment}
|
|
275
287
|
</Animated.View>)
|
|
@@ -279,6 +291,9 @@ function GiftedChat(props) {
|
|
|
279
291
|
</GiftedChatContext.Provider>);
|
|
280
292
|
}
|
|
281
293
|
function GiftedChatWrapper(props) {
|
|
294
|
+
// Don't use KeyboardProvider when keyboard controller is disabled
|
|
295
|
+
if (props.disableKeyboardController)
|
|
296
|
+
return <GiftedChat {...props}/>;
|
|
282
297
|
return (<KeyboardProvider>
|
|
283
298
|
<GiftedChat {...props}/>
|
|
284
299
|
</KeyboardProvider>);
|