react-native-gifted-chat 2.8.2-alpha.1 → 2.8.2-alpha.3
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 +68 -27
- package/package.json +10 -11
- package/src/Actions.tsx +14 -16
- package/src/Avatar.tsx +1 -1
- package/src/Bubble/index.tsx +13 -10
- package/src/Bubble/types.ts +5 -4
- package/src/Composer.tsx +1 -1
- package/src/Day/index.tsx +3 -3
- package/src/GiftedAvatar.tsx +2 -2
- package/src/GiftedChat/index.tsx +53 -46
- package/src/GiftedChat/styles.ts +3 -0
- package/src/GiftedChat/types.ts +15 -18
- package/src/InputToolbar.tsx +10 -10
- package/src/LoadEarlier.tsx +7 -7
- package/src/LoadEarlierMessages.tsx +97 -0
- package/src/Message/index.tsx +4 -18
- package/src/Message/types.ts +2 -2
- package/src/MessageAudio.tsx +1 -1
- package/src/MessageContainer/components/DayAnimated/index.tsx +9 -9
- package/src/MessageContainer/components/DayAnimated/types.ts +1 -1
- package/src/MessageContainer/components/Item/index.tsx +3 -3
- package/src/MessageContainer/components/Item/types.ts +1 -1
- package/src/MessageContainer/index.tsx +22 -27
- package/src/MessageContainer/types.ts +6 -12
- package/src/MessageImage.tsx +119 -17
- package/src/MessageText.tsx +10 -45
- package/src/MessageVideo.tsx +1 -1
- package/src/QuickReplies.tsx +2 -2
- package/src/Send.tsx +3 -4
- package/src/SystemMessage.tsx +1 -1
- package/src/Time.tsx +1 -1
- package/src/TypingIndicator/index.tsx +2 -2
- package/src/__tests__/DayAnimated.test.tsx +4 -4
- package/src/__tests__/GiftedChat.test.tsx +3 -3
- package/src/__tests__/LoadEarlier.test.tsx +3 -3
- package/src/__tests__/__snapshots__/Actions.test.tsx.snap +39 -7
- package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +20 -22
- package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +38 -7
- package/src/__tests__/__snapshots__/MessageImage.test.tsx.snap +34 -15
- package/src/__tests__/__snapshots__/Send.test.tsx.snap +70 -10
- package/src/components/TouchableOpacity.tsx +45 -0
- package/src/types.ts +1 -3
- package/src/utils.ts +2 -2
package/README.md
CHANGED
|
@@ -26,10 +26,7 @@
|
|
|
26
26
|
</p>
|
|
27
27
|
|
|
28
28
|
<p align="center">
|
|
29
|
-
<a href="https://
|
|
30
|
-
</p>
|
|
31
|
-
<p align="center">
|
|
32
|
-
<a href="https://snack.expo.io/@xcarpentier/giftedchat-playground" target="_blank">Snack GiftedChat playground</a>
|
|
29
|
+
<a href="https://snack.expo.dev/@kesha-antonov/gifted-chat-playground" target="_blank">Snack GiftedChat playground</a>
|
|
33
30
|
<img height="18" src="https://snack.expo.io/favicon.ico" />
|
|
34
31
|
</p>
|
|
35
32
|
|
|
@@ -85,21 +82,19 @@
|
|
|
85
82
|
|
|
86
83
|
## Features
|
|
87
84
|
|
|
88
|
-
- 🎉 **_`react-native-web`able_ (since 0.10.0)** [web configuration](#react-native-web)
|
|
89
|
-
- Write with **TypeScript** (since 0.8.0)
|
|
90
85
|
- Fully customizable components
|
|
91
86
|
- Composer actions (to attach photos, etc.)
|
|
92
87
|
- Load earlier messages
|
|
93
88
|
- Copy messages to clipboard
|
|
94
|
-
- Touchable links using [react-native-
|
|
89
|
+
- Touchable links using [react-native-autolink](https://github.com/joshswan/react-native-autolink)
|
|
95
90
|
- Avatar as user's initials
|
|
96
91
|
- Localized dates
|
|
97
92
|
- Multi-line TextInput
|
|
98
93
|
- InputToolbar avoiding keyboard
|
|
99
|
-
- Redux support
|
|
100
94
|
- System message
|
|
101
95
|
- Quick Reply messages (bot)
|
|
102
96
|
- Typing indicator
|
|
97
|
+
- react-native-web [web configuration](#react-native-web)
|
|
103
98
|
|
|
104
99
|
# Getting started
|
|
105
100
|
|
|
@@ -117,18 +112,18 @@ Readme for this version: [2.6.5 readme](https://github.com/FaridSafi/react-nativ
|
|
|
117
112
|
|
|
118
113
|
Yarn:
|
|
119
114
|
```bash
|
|
120
|
-
yarn add react-native-gifted-chat react-native-reanimated react-native-keyboard-controller
|
|
115
|
+
yarn add react-native-gifted-chat react-native-reanimated react-native-keyboard-controller react-native-gesture-handler react-native-safe-area-context
|
|
121
116
|
```
|
|
122
117
|
|
|
123
118
|
Npm:
|
|
124
119
|
|
|
125
120
|
```bash
|
|
126
|
-
npm install --save react-native-gifted-chat react-native-reanimated react-native-keyboard-controller
|
|
121
|
+
npm install --save react-native-gifted-chat react-native-reanimated react-native-keyboard-controller react-native-gesture-handler react-native-safe-area-context
|
|
127
122
|
```
|
|
128
123
|
|
|
129
124
|
Expo
|
|
130
125
|
```bash
|
|
131
|
-
npx expo install react-native-gifted-chat react-native-reanimated react-native-keyboard-controller
|
|
126
|
+
npx expo install react-native-gifted-chat react-native-reanimated react-native-keyboard-controller react-native-gesture-handler react-native-safe-area-context
|
|
132
127
|
```
|
|
133
128
|
|
|
134
129
|
### Non-expo users
|
|
@@ -173,9 +168,15 @@ fireEvent(loadingWrapper, 'layout', {
|
|
|
173
168
|
```jsx
|
|
174
169
|
import React, { useState, useCallback, useEffect } from 'react'
|
|
175
170
|
import { GiftedChat } from 'react-native-gifted-chat'
|
|
171
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
176
172
|
|
|
177
173
|
export function Example() {
|
|
178
174
|
const [messages, setMessages] = useState([])
|
|
175
|
+
const insets = useSafeAreaInsets()
|
|
176
|
+
|
|
177
|
+
// If you have a tab bar, include its height
|
|
178
|
+
const tabbarHeight = 50
|
|
179
|
+
const keyboardBottomOffset = insets.bottom + tabbarHeight
|
|
179
180
|
|
|
180
181
|
useEffect(() => {
|
|
181
182
|
setMessages([
|
|
@@ -205,6 +206,7 @@ export function Example() {
|
|
|
205
206
|
user={{
|
|
206
207
|
_id: 1,
|
|
207
208
|
}}
|
|
209
|
+
keyboardBottomOffset={keyboardBottomOffset}
|
|
208
210
|
/>
|
|
209
211
|
)
|
|
210
212
|
}
|
|
@@ -212,7 +214,7 @@ export function Example() {
|
|
|
212
214
|
|
|
213
215
|
## Advanced example
|
|
214
216
|
|
|
215
|
-
See [`
|
|
217
|
+
See [`examples`](example) for a working demo!
|
|
216
218
|
|
|
217
219
|
## "Slack" example
|
|
218
220
|
|
|
@@ -353,10 +355,12 @@ interface QuickReplies {
|
|
|
353
355
|
- **`messageContainerRef`** _(FlatList ref)_ - Ref to the flatlist
|
|
354
356
|
- **`textInputRef`** _(TextInput ref)_ - Ref to the text input
|
|
355
357
|
- **`messages`** _(Array)_ - Messages to display
|
|
358
|
+
- **`messagesContainerStyle`** _(Object)_ - Custom style for the messages container
|
|
356
359
|
- **`isTyping`** _(Bool)_ - Typing Indicator state; default `false`. If you use`renderFooter` it will override this.
|
|
360
|
+
- **`keyboardBottomOffset`** _(Integer)_ - Distance between the bottom of the screen and bottom of the `GiftedChat` component. Useful when you have a tab bar or navigation bar; default is `0`. Needed for correct keyboard avoiding behavior. Without it you might see gap between the keyboard and the input toolbar if you have a tab bar, navigation bar, or safe area.
|
|
357
361
|
- **`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`
|
|
359
362
|
- **`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))
|
|
363
|
+
- **`initialText`** _(String)_ - Initial text to display in the input field
|
|
360
364
|
- **`onInputTextChanged`** _(Function)_ - Callback when the input text changes
|
|
361
365
|
- **`messageIdGenerator`** _(Function)_ - Generate an id for new messages. Defaults to UUID v4, generated by [uuid](https://github.com/kelektiv/node-uuid)
|
|
362
366
|
- **`user`** _(Object)_ - User sending the messages: `{ _id, name, avatar }`
|
|
@@ -366,9 +370,18 @@ interface QuickReplies {
|
|
|
366
370
|
- **`timeFormat`** _(String)_ - Format to use for rendering times; default is `'LT'` (see [Day.js Format](https://day.js.org/docs/en/display/format))
|
|
367
371
|
- **`dateFormat`** _(String)_ - Format to use for rendering dates; default is `'D MMMM'` (see [Day.js Format](https://day.js.org/docs/en/display/format))
|
|
368
372
|
- **`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))
|
|
369
|
-
- **`
|
|
370
|
-
-
|
|
371
|
-
-
|
|
373
|
+
- **`loadEarlierMessagesProps`** _(Object)_ - Props to pass to the LoadEarlierMessages component. The button is only visible when `isAvailable` is `true`. Supports the following props:
|
|
374
|
+
- `isAvailable` - Controls button visibility (default: false)
|
|
375
|
+
- `onPress` - Callback when button is pressed
|
|
376
|
+
- `isLoading` - Display loading indicator (default: false)
|
|
377
|
+
- `isInfiniteScrollEnabled` - Enable infinite scroll up when reaching the top of messages container, automatically calls `onPress` (not yet supported for web)
|
|
378
|
+
- `label` - Override the default "Load earlier messages" text
|
|
379
|
+
- `containerStyle` - Custom style for the button container
|
|
380
|
+
- `wrapperStyle` - Custom style for the button wrapper
|
|
381
|
+
- `textStyle` - Custom style for the button text
|
|
382
|
+
- `activityIndicatorStyle` - Custom style for the loading indicator
|
|
383
|
+
- `activityIndicatorColor` - Color of the loading indicator (default: 'white')
|
|
384
|
+
- `activityIndicatorSize` - Size of the loading indicator (default: 'small')
|
|
372
385
|
- **`renderLoading`** _(Function)_ - Render a loading view when initializing
|
|
373
386
|
- **`renderLoadEarlier`** _(Function)_ - Custom "Load earlier messages" button
|
|
374
387
|
- **`renderAvatar`** _(Function)_ - Custom message avatar; set to `null` to not render any avatar for the message
|
|
@@ -389,14 +402,17 @@ interface QuickReplies {
|
|
|
389
402
|
- **`renderMessageText`** _(Function)_ - Custom message text
|
|
390
403
|
- **`renderMessageImage`** _(Function)_ - Custom message image
|
|
391
404
|
- **`renderMessageVideo`** _(Function)_ - Custom message video
|
|
405
|
+
- **`renderMessageAudio`** _(Function)_ - Custom message audio
|
|
392
406
|
- **`imageProps`** _(Object)_ - Extra props to be passed to the [`<Image>`](https://reactnative.dev/docs/image.html) component created by the default `renderMessageImage`
|
|
407
|
+
- **`imageStyle`** _(Object)_ - Custom style for message images
|
|
393
408
|
- **`videoProps`** _(Object)_ - Extra props to be passed to the video component created by the required `renderMessageVideo`
|
|
394
|
-
- **`lightboxProps`** _(Object)_ - Extra props to be passed to the `MessageImage`'s [Lightbox](https://github.com/oblador/react-native-lightbox)
|
|
395
409
|
- **`isCustomViewBottom`** _(Bool)_ - Determine whether renderCustomView is displayed before or after the text, image and video views; default is `false`
|
|
396
410
|
- **`renderCustomView`** _(Function)_ - Custom view inside the bubble
|
|
397
411
|
- **`renderDay`** _(Function)_ - Custom day above a message
|
|
398
412
|
- **`renderTime`** _(Function)_ - Custom time inside a message
|
|
413
|
+
- **`timeTextStyle`** _(Object)_ - Custom text style for time inside messages (supports left/right styles)
|
|
399
414
|
- **`renderFooter`** _(Function)_ - Custom footer component on the ListView, e.g. `'User is typing...'`; see [App.tsx](/example/App.tsx) for an example. Overrides default typing indicator that triggers when `isTyping` is true.
|
|
415
|
+
- **`renderTypingIndicator`** _(Function)_ - Custom typing indicator component
|
|
400
416
|
- **`renderChatEmpty`** _(Function)_ - Custom component to render in the ListView when messages are empty
|
|
401
417
|
- **`renderChatFooter`** _(Function)_ - Custom component to render below the MessageContainer (separate from the ListView)
|
|
402
418
|
- **`renderInputToolbar`** _(Function)_ - Custom message composer container
|
|
@@ -405,22 +421,45 @@ interface QuickReplies {
|
|
|
405
421
|
- **`renderSend`** _(Function)_ - Custom send button; you can pass children to the original `Send` component quite easily, for example, to use a custom icon ([example](https://github.com/FaridSafi/react-native-gifted-chat/pull/487))
|
|
406
422
|
- **`renderAccessory`** _(Function)_ - Custom second line of actions below the message composer
|
|
407
423
|
- **`onPressActionButton`** _(Function)_ - Callback when the Action button is pressed (if set, the default `actionSheet` will not be used)
|
|
408
|
-
- **`
|
|
424
|
+
- **`actionSheet`** _(Function)_ - Custom action sheet interface for showing action options
|
|
425
|
+
- **`actions`** _(Array)_ - Custom action options for the input toolbar action button; array of objects with `title` (string) and `action` (function) properties
|
|
426
|
+
- **`actionSheetOptionTintColor`** _(String)_ - Tint color for action sheet options
|
|
409
427
|
- **`focusOnInputWhenOpeningKeyboard`** _(Bool)_ - Focus on <TextInput> automatically when opening the keyboard; default `true`
|
|
410
428
|
- **`minInputToolbarHeight`** _(Integer)_ - Minimum height of the input toolbar; default is `44`
|
|
411
429
|
- **`listProps`** _(Object)_ - Extra props to be passed to the messages [`<FlatList>`](https://reactnative.dev/docs/flatlist.html); some props can't be overridden, see the code in `MessageContainer.render()` for details
|
|
412
430
|
- **`textInputProps`** _(Object)_ - props to be passed to the [`<TextInput>`](https://reactnative.dev/docs/textinput.html).
|
|
413
|
-
- **`
|
|
431
|
+
- **`messageTextProps`** _(Object)_ - Extra props to be passed to the MessageText component. Useful for customizing link parsing behavior, text styles, and matchers. Supports all [react-native-autolink](https://github.com/joshswan/react-native-autolink) props including:
|
|
432
|
+
- `matchers` - Custom matchers for linking message content (like URLs, phone numbers, hashtags, mentions)
|
|
433
|
+
- `linkStyle` - Custom style for links
|
|
434
|
+
- `email` - Enable/disable email parsing (default: true)
|
|
435
|
+
- `phone` - Enable/disable phone number parsing (default: true)
|
|
436
|
+
- `url` - Enable/disable URL parsing (default: true)
|
|
437
|
+
|
|
438
|
+
Example:
|
|
414
439
|
|
|
415
440
|
```js
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
441
|
+
<GiftedChat
|
|
442
|
+
messageTextProps={{
|
|
443
|
+
matchers: [
|
|
444
|
+
{
|
|
445
|
+
pattern: /#(\w+)/g,
|
|
446
|
+
style: { color: '#0084ff', fontWeight: 'bold' },
|
|
447
|
+
onPress: (match) => console.log('Hashtag:', match.getAnchorText()),
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
pattern: /(?<![\.\w])@(?!__ELEMENT-)([\w-]+)/g,
|
|
451
|
+
style: { color: '#0084ff', fontWeight: 'bold' },
|
|
452
|
+
onPress: (match) => console.log('Mention:', match.getAnchorText()),
|
|
453
|
+
},
|
|
454
|
+
],
|
|
455
|
+
linkStyle: { left: { color: 'blue' }, right: { color: 'lightblue' } },
|
|
456
|
+
phone: false,
|
|
457
|
+
}}
|
|
458
|
+
/>
|
|
422
459
|
```
|
|
423
460
|
|
|
461
|
+
- **`matchers`** _(Array)_ - **Deprecated:** Use `messageTextProps.matchers` instead. Custom matchers for [react-native-autolink](https://github.com/joshswan/react-native-autolink) used to linking message content (like URLs and phone numbers).
|
|
462
|
+
|
|
424
463
|
- **`extraData`** _(Object)_ - Extra props for re-rendering FlatList on demand. This will be useful for rendering footer etc.
|
|
425
464
|
- **`minComposerHeight`** _(Object)_ - Custom min-height of the composer.
|
|
426
465
|
- **`maxComposerHeight`** _(Object)_ - Custom max height of the composer.
|
|
@@ -433,10 +472,12 @@ interface QuickReplies {
|
|
|
433
472
|
* **`onQuickReply`** _(Function)_ - Callback when sending a quick reply (to backend server)
|
|
434
473
|
* **`renderQuickReplies`** _(Function)_ - Custom all quick reply view
|
|
435
474
|
* **`quickReplyStyle`** _(StyleProp<ViewStyle>)_ - Custom quick reply view style
|
|
475
|
+
* **`quickReplyTextStyle`** _(StyleProp<TextStyle>)_ - Custom text style for quick reply buttons
|
|
476
|
+
* **`quickReplyContainerStyle`** _(StyleProp<ViewStyle>)_ - Custom container style for quick replies
|
|
436
477
|
* **`renderQuickReplySend`** _(Function)_ - Custom quick reply **send** view
|
|
437
478
|
* **`shouldUpdateMessage`** _(Function)_ - Lets the message component know when to update outside of normal cases.
|
|
438
|
-
* **`infiniteScroll`** _(Bool)_ - infinite scroll up when reach the top of messages container, automatically call onLoadEarlier function if exist (not yet supported for the web). You need to add `loadEarlier` prop too.
|
|
439
479
|
* **`typingIndicatorStyle`** _(StyleProp<ViewStyle>)_ - Custom style for the TypingIndicator component.
|
|
480
|
+
* **`handleOnScroll`** _(Function)_ - Custom scroll event handler for the message list
|
|
440
481
|
|
|
441
482
|
## Notes for [Redux](https://github.com/reactjs/redux)
|
|
442
483
|
|
|
@@ -514,7 +555,7 @@ If you use React Navigation, additional handling may be required to account for
|
|
|
514
555
|
module.exports = function override(config, env) {
|
|
515
556
|
config.module.rules.push({
|
|
516
557
|
test: /\.js$/,
|
|
517
|
-
exclude: /node_modules[/\\](?!react-native-gifted-chat
|
|
558
|
+
exclude: /node_modules[/\\](?!react-native-gifted-chat)/,
|
|
518
559
|
use: {
|
|
519
560
|
loader: 'babel-loader',
|
|
520
561
|
options: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-chat",
|
|
3
|
-
"version": "2.8.2-alpha.
|
|
3
|
+
"version": "2.8.2-alpha.3",
|
|
4
4
|
"description": "The most complete chat UI for React Native",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"android",
|
|
@@ -53,8 +53,7 @@
|
|
|
53
53
|
"dayjs": "^1.11.19",
|
|
54
54
|
"lodash.isequal": "^4.5.0",
|
|
55
55
|
"react-native-autolink": "^4.2.0",
|
|
56
|
-
"react-native-
|
|
57
|
-
"react-native-lightbox-v2": "^0.9.2"
|
|
56
|
+
"react-native-zoom-reanimated": "^1.4.10"
|
|
58
57
|
},
|
|
59
58
|
"devDependencies": {
|
|
60
59
|
"@babel/core": "^7.28.5",
|
|
@@ -80,16 +79,12 @@
|
|
|
80
79
|
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
|
81
80
|
"@typescript-eslint/parser": "^8.46.4",
|
|
82
81
|
"babel-jest": "^29.7.0",
|
|
83
|
-
"eslint": "^
|
|
84
|
-
"eslint-config-standard": "^17.1.0",
|
|
85
|
-
"eslint-config-standard-jsx": "^11.0.0",
|
|
82
|
+
"eslint": "^9.18.0",
|
|
86
83
|
"eslint-plugin-import": "^2.32.0",
|
|
87
84
|
"eslint-plugin-jest": "^28.11.0",
|
|
88
|
-
"eslint-plugin-
|
|
89
|
-
"eslint-plugin-n": "^17.23.1",
|
|
90
|
-
"eslint-plugin-node": "^11.1.0",
|
|
91
|
-
"eslint-plugin-promise": "^7.2.1",
|
|
85
|
+
"eslint-plugin-perfectionist": "^4.15.1",
|
|
92
86
|
"eslint-plugin-react": "^7.37.5",
|
|
87
|
+
"eslint-plugin-react-hooks": "^5.1.0",
|
|
93
88
|
"husky": "^9.1.7",
|
|
94
89
|
"jest": "^29.7.0",
|
|
95
90
|
"json": "^11.0.0",
|
|
@@ -97,16 +92,20 @@
|
|
|
97
92
|
"react": "19.1.0",
|
|
98
93
|
"react-dom": "19.1.0",
|
|
99
94
|
"react-native": "0.81.5",
|
|
95
|
+
"react-native-gesture-handler": "^2.29.1",
|
|
100
96
|
"react-native-keyboard-controller": "^1.19.5",
|
|
101
97
|
"react-native-reanimated": "^3.19.4",
|
|
98
|
+
"react-native-safe-area-context": "^5.6.2",
|
|
102
99
|
"react-test-renderer": "19.1.0",
|
|
103
100
|
"typescript": "^5.9.3"
|
|
104
101
|
},
|
|
105
102
|
"peerDependencies": {
|
|
106
103
|
"react": ">=18.0.0",
|
|
107
104
|
"react-native": "*",
|
|
105
|
+
"react-native-gesture-handler": ">=2.0.0",
|
|
108
106
|
"react-native-keyboard-controller": ">=1.0.0",
|
|
109
|
-
"react-native-reanimated": ">=3.0.0 || ^4.0.0"
|
|
107
|
+
"react-native-reanimated": ">=3.0.0 || ^4.0.0",
|
|
108
|
+
"react-native-safe-area-context": ">=5.0.0"
|
|
110
109
|
},
|
|
111
110
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
|
|
112
111
|
"engines": {
|
package/src/Actions.tsx
CHANGED
|
@@ -2,20 +2,20 @@ import React, { ReactNode, useCallback } from 'react'
|
|
|
2
2
|
import {
|
|
3
3
|
StyleSheet,
|
|
4
4
|
Text,
|
|
5
|
-
TouchableOpacity,
|
|
6
5
|
View,
|
|
7
6
|
StyleProp,
|
|
8
7
|
ViewStyle,
|
|
9
8
|
TextStyle,
|
|
10
9
|
} from 'react-native'
|
|
11
10
|
import Color from './Color'
|
|
11
|
+
import { TouchableOpacity } from './components/TouchableOpacity'
|
|
12
12
|
import { useChatContext } from './GiftedChatContext'
|
|
13
13
|
|
|
14
14
|
import stylesCommon from './styles'
|
|
15
15
|
|
|
16
16
|
export interface ActionsProps {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
actions?: Array<{ title: string, action: () => void }>
|
|
18
|
+
actionSheetOptionTintColor?: string
|
|
19
19
|
icon?: () => ReactNode
|
|
20
20
|
wrapperStyle?: StyleProp<ViewStyle>
|
|
21
21
|
iconTextStyle?: StyleProp<TextStyle>
|
|
@@ -24,8 +24,8 @@ export interface ActionsProps {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export function Actions ({
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
actions,
|
|
28
|
+
actionSheetOptionTintColor = Color.optionTintColor,
|
|
29
29
|
icon,
|
|
30
30
|
wrapperStyle,
|
|
31
31
|
iconTextStyle,
|
|
@@ -35,28 +35,26 @@ export function Actions ({
|
|
|
35
35
|
const { actionSheet } = useChatContext()
|
|
36
36
|
|
|
37
37
|
const onActionsPress = useCallback(() => {
|
|
38
|
-
if (!
|
|
38
|
+
if (!actions?.length)
|
|
39
39
|
return
|
|
40
40
|
|
|
41
|
-
const
|
|
42
|
-
const cancelButtonIndex = optionKeys.indexOf('Cancel')
|
|
41
|
+
const titles = actions.map(item => item.title)
|
|
43
42
|
|
|
44
43
|
actionSheet().showActionSheetWithOptions(
|
|
45
44
|
{
|
|
46
|
-
options:
|
|
47
|
-
cancelButtonIndex,
|
|
48
|
-
tintColor:
|
|
45
|
+
options: titles,
|
|
46
|
+
cancelButtonIndex: titles.length - 1,
|
|
47
|
+
tintColor: actionSheetOptionTintColor,
|
|
49
48
|
},
|
|
50
|
-
(buttonIndex
|
|
49
|
+
(buttonIndex?: number) => {
|
|
51
50
|
if (buttonIndex === undefined)
|
|
52
51
|
return
|
|
53
52
|
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
options[key]()
|
|
53
|
+
const item = actions[buttonIndex]
|
|
54
|
+
item.action?.()
|
|
57
55
|
}
|
|
58
56
|
)
|
|
59
|
-
}, [actionSheet,
|
|
57
|
+
}, [actionSheet, actions, actionSheetOptionTintColor])
|
|
60
58
|
|
|
61
59
|
const renderIcon = useCallback(() => {
|
|
62
60
|
if (icon)
|
package/src/Avatar.tsx
CHANGED
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
ViewStyle,
|
|
8
8
|
} from 'react-native'
|
|
9
9
|
import { GiftedAvatar } from './GiftedAvatar'
|
|
10
|
-
import { isSameUser, isSameDay } from './utils'
|
|
11
10
|
import { IMessage, LeftRightStyle, User } from './types'
|
|
11
|
+
import { isSameUser, isSameDay } from './utils'
|
|
12
12
|
|
|
13
13
|
interface Styles {
|
|
14
14
|
left: {
|
package/src/Bubble/index.tsx
CHANGED
|
@@ -6,19 +6,19 @@ import {
|
|
|
6
6
|
} from 'react-native'
|
|
7
7
|
|
|
8
8
|
import { useChatContext } from '../GiftedChatContext'
|
|
9
|
-
import {
|
|
10
|
-
import { MessageText } from '../MessageText'
|
|
9
|
+
import { MessageAudio } from '../MessageAudio'
|
|
11
10
|
import { MessageImage } from '../MessageImage'
|
|
11
|
+
import { MessageText } from '../MessageText'
|
|
12
12
|
import { MessageVideo } from '../MessageVideo'
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
13
|
+
import { QuickReplies } from '../QuickReplies'
|
|
14
|
+
import stylesCommon from '../styles'
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { Time } from '../Time'
|
|
17
17
|
import { IMessage } from '../types'
|
|
18
|
-
import {
|
|
18
|
+
import { isSameUser, isSameDay } from '../utils'
|
|
19
19
|
|
|
20
|
-
import stylesCommon from '../styles'
|
|
21
20
|
import styles from './styles'
|
|
21
|
+
import { BubbleProps, RenderMessageTextProps } from './types'
|
|
22
22
|
|
|
23
23
|
export * from './types'
|
|
24
24
|
|
|
@@ -142,14 +142,17 @@ const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessag
|
|
|
142
142
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
143
143
|
containerStyle,
|
|
144
144
|
wrapperStyle,
|
|
145
|
+
messageTextProps,
|
|
145
146
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
146
|
-
...
|
|
147
|
+
...messageTextPropsRest
|
|
147
148
|
} = props
|
|
148
149
|
|
|
150
|
+
const combinedProps = { ...messageTextPropsRest, ...messageTextProps } as RenderMessageTextProps<TMessage>
|
|
151
|
+
|
|
149
152
|
if (props.renderMessageText)
|
|
150
|
-
return props.renderMessageText(
|
|
153
|
+
return props.renderMessageText(combinedProps)
|
|
151
154
|
|
|
152
|
-
return <MessageText {...
|
|
155
|
+
return <MessageText {...combinedProps} />
|
|
153
156
|
}
|
|
154
157
|
|
|
155
158
|
return null
|
package/src/Bubble/types.ts
CHANGED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
ViewStyle,
|
|
5
5
|
TextStyle,
|
|
6
6
|
} from 'react-native'
|
|
7
|
-
import { QuickRepliesProps } from '../QuickReplies'
|
|
8
|
-
import { MessageTextProps, MessageOption } from '../MessageText'
|
|
9
7
|
import { MessageImageProps } from '../MessageImage'
|
|
8
|
+
import { MessageTextProps, MessageOption } from '../MessageText'
|
|
9
|
+
import { QuickRepliesProps } from '../QuickReplies'
|
|
10
10
|
import { TimeProps } from '../Time'
|
|
11
11
|
import {
|
|
12
12
|
User,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
MessageAudioProps,
|
|
19
19
|
} from '../types'
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
export type RenderMessageImageProps<TMessage extends IMessage> = Omit<
|
|
23
23
|
BubbleProps<TMessage>,
|
|
24
24
|
'containerStyle' | 'wrapperStyle'
|
|
@@ -42,7 +42,7 @@ export type RenderMessageTextProps<TMessage extends IMessage> = Omit<
|
|
|
42
42
|
'containerStyle' | 'wrapperStyle' | 'options'
|
|
43
43
|
> &
|
|
44
44
|
MessageTextProps<TMessage>
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
|
|
47
47
|
export interface BubbleProps<TMessage extends IMessage> {
|
|
48
48
|
user?: User
|
|
@@ -66,6 +66,7 @@ export interface BubbleProps<TMessage extends IMessage> {
|
|
|
66
66
|
quickReplyStyle?: StyleProp<ViewStyle>
|
|
67
67
|
quickReplyTextStyle?: StyleProp<TextStyle>
|
|
68
68
|
quickReplyContainerStyle?: StyleProp<ViewStyle>
|
|
69
|
+
messageTextProps?: Partial<MessageTextProps<TMessage>>
|
|
69
70
|
onPressMessage?(context?: unknown, message?: unknown): void
|
|
70
71
|
onLongPressMessage?(context?: unknown, message?: unknown): void
|
|
71
72
|
onQuickReply?(replies: Reply[]): void
|
package/src/Composer.tsx
CHANGED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
TextInputContentSizeChangeEventData,
|
|
9
9
|
useColorScheme,
|
|
10
10
|
} from 'react-native'
|
|
11
|
-
import { MIN_COMPOSER_HEIGHT } from './Constant'
|
|
12
11
|
import Color from './Color'
|
|
12
|
+
import { MIN_COMPOSER_HEIGHT } from './Constant'
|
|
13
13
|
import stylesCommon from './styles'
|
|
14
14
|
|
|
15
15
|
export interface ComposerProps {
|
package/src/Day/index.tsx
CHANGED
|
@@ -4,15 +4,15 @@ import {
|
|
|
4
4
|
View,
|
|
5
5
|
} from 'react-native'
|
|
6
6
|
import dayjs from 'dayjs'
|
|
7
|
-
import relativeTime from 'dayjs/plugin/relativeTime'
|
|
8
7
|
import calendar from 'dayjs/plugin/calendar'
|
|
8
|
+
import relativeTime from 'dayjs/plugin/relativeTime'
|
|
9
9
|
|
|
10
10
|
import { DATE_FORMAT } from '../Constant'
|
|
11
|
-
import { DayProps } from './types'
|
|
12
|
-
|
|
13
11
|
import { useChatContext } from '../GiftedChatContext'
|
|
12
|
+
|
|
14
13
|
import stylesCommon from '../styles'
|
|
15
14
|
import styles from './styles'
|
|
15
|
+
import { DayProps } from './types'
|
|
16
16
|
|
|
17
17
|
export * from './types'
|
|
18
18
|
|
package/src/GiftedAvatar.tsx
CHANGED
|
@@ -2,7 +2,6 @@ import React, { useCallback, useMemo } from 'react'
|
|
|
2
2
|
import {
|
|
3
3
|
Image,
|
|
4
4
|
Text,
|
|
5
|
-
TouchableOpacity,
|
|
6
5
|
View,
|
|
7
6
|
StyleSheet,
|
|
8
7
|
StyleProp,
|
|
@@ -10,8 +9,9 @@ import {
|
|
|
10
9
|
TextStyle,
|
|
11
10
|
} from 'react-native'
|
|
12
11
|
import Color from './Color'
|
|
13
|
-
import {
|
|
12
|
+
import { TouchableOpacity } from './components/TouchableOpacity'
|
|
14
13
|
import stylesCommon from './styles'
|
|
14
|
+
import { User } from './types'
|
|
15
15
|
|
|
16
16
|
const {
|
|
17
17
|
carrot,
|