react-native-gifted-chat 0.16.1 → 1.0.0-beta-1
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 +69 -50
- package/lib/Actions.d.ts +13 -11
- package/lib/Actions.js +28 -34
- package/lib/Actions.js.map +1 -1
- package/lib/Avatar.d.ts +7 -7
- package/lib/Avatar.js +35 -40
- package/lib/Avatar.js.map +1 -1
- package/lib/Bubble.d.ts +11 -8
- package/lib/Bubble.js +13 -7
- package/lib/Bubble.js.map +1 -1
- package/lib/Composer.d.ts +5 -11
- package/lib/Composer.js +34 -40
- package/lib/Composer.js.map +1 -1
- package/lib/Day.d.ts +7 -10
- package/lib/Day.js +15 -19
- package/lib/Day.js.map +1 -1
- package/lib/GiftedAvatar.js +3 -3
- package/lib/GiftedAvatar.js.map +1 -1
- package/lib/GiftedChat.d.ts +47 -38
- package/lib/GiftedChat.js +61 -36
- package/lib/GiftedChat.js.flow +8 -0
- package/lib/GiftedChat.js.map +1 -1
- package/lib/GiftedChatContext.d.ts +9 -0
- package/lib/GiftedChatContext.js +9 -0
- package/lib/GiftedChatContext.js.map +1 -0
- package/lib/InputToolbar.d.ts +14 -28
- package/lib/InputToolbar.js +27 -83
- package/lib/InputToolbar.js.map +1 -1
- package/lib/LoadEarlier.d.ts +4 -5
- package/lib/LoadEarlier.js +12 -25
- package/lib/LoadEarlier.js.map +1 -1
- package/lib/Message.d.ts +10 -7
- package/lib/Message.js +11 -9
- package/lib/Message.js.map +1 -1
- package/lib/MessageAudio.d.ts +1 -3
- package/lib/MessageAudio.js +11 -9
- package/lib/MessageAudio.js.map +1 -1
- package/lib/MessageContainer.d.ts +3 -8
- package/lib/MessageContainer.js +3 -41
- package/lib/MessageContainer.js.map +1 -1
- package/lib/MessageImage.d.ts +4 -5
- package/lib/MessageImage.js +12 -15
- package/lib/MessageImage.js.map +1 -1
- package/lib/MessageText.d.ts +5 -13
- package/lib/MessageText.js +79 -82
- package/lib/MessageText.js.map +1 -1
- package/lib/MessageVideo.d.ts +1 -3
- package/lib/MessageVideo.js +11 -9
- package/lib/MessageVideo.js.map +1 -1
- package/lib/Models.d.ts +3 -4
- package/lib/Models.js +1 -0
- package/lib/QuickReplies.d.ts +5 -15
- package/lib/QuickReplies.js +67 -87
- package/lib/QuickReplies.js.map +1 -1
- package/lib/Send.d.ts +6 -7
- package/lib/Send.js +16 -21
- package/lib/Send.js.map +1 -1
- package/lib/SystemMessage.d.ts +4 -5
- package/lib/SystemMessage.js +10 -12
- package/lib/SystemMessage.js.map +1 -1
- package/lib/Time.d.ts +5 -9
- package/lib/Time.js +33 -33
- package/lib/Time.js.map +1 -1
- package/lib/TypingIndicator.d.ts +0 -1
- package/lib/TypingIndicator.js +1 -6
- package/lib/TypingIndicator.js.map +1 -1
- package/lib/hooks/useUpdateLayoutEffect.d.ts +3 -2
- package/lib/hooks/useUpdateLayoutEffect.js +1 -1
- package/lib/hooks/useUpdateLayoutEffect.js.map +1 -1
- package/package.json +28 -23
package/README.md
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
<a href="https://www.npmjs.com/package/react-native-gifted-chat">
|
|
17
17
|
<img alt="npm downloads" src="https://img.shields.io/npm/dm/react-native-gifted-chat.svg"/></a>
|
|
18
18
|
<a href="https://www.npmjs.com/package/react-native-gifted-chat"><img alt="npm version" src="https://badge.fury.io/js/react-native-gifted-chat.svg"/></a>
|
|
19
|
-
<a href="https://greenkeeper.io/"><img src="https://badges.greenkeeper.io/FaridSafi/react-native-gifted-chat.svg" alt="build"></a>
|
|
20
19
|
<a href="https://reactnative.gallery/FaridSafi/gifted-chat"><img src="https://img.shields.io/badge/reactnative.gallery-%F0%9F%8E%AC-green.svg"/></a>
|
|
21
20
|
|
|
22
21
|
</p>
|
|
@@ -81,11 +80,12 @@
|
|
|
81
80
|
</p>
|
|
82
81
|
</p>
|
|
83
82
|
|
|
83
|
+
## The future of GiftedChat 🎉
|
|
84
|
+
Please give us your advice: [Related PR](https://github.com/FaridSafi/react-native-gifted-chat/pull/1775)
|
|
85
|
+
|
|
84
86
|
## Please vote
|
|
85
87
|
|
|
86
88
|
**GiftedChat** depends on other packages and some needs a boost, please vote for PRs will improve it, thanks:
|
|
87
|
-
|
|
88
|
-
- https://github.com/taskrabbit/react-native-parsed-text/pull/58
|
|
89
89
|
- https://github.com/watadarkstar/react-native-typing-animation/issues/18
|
|
90
90
|
|
|
91
91
|
## Features
|
|
@@ -132,48 +132,40 @@
|
|
|
132
132
|
## Example
|
|
133
133
|
|
|
134
134
|
```jsx
|
|
135
|
-
import React from 'react'
|
|
135
|
+
import React, { useState, useCallback, useEffect } from 'react'
|
|
136
136
|
import { GiftedChat } from 'react-native-gifted-chat'
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
_id: 2,
|
|
152
|
-
name: 'React Native',
|
|
153
|
-
avatar: 'https://placeimg.com/140/140/any',
|
|
154
|
-
},
|
|
138
|
+
export function Example() {
|
|
139
|
+
const [messages, setMessages] = useState([]);
|
|
140
|
+
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
setMessages([
|
|
143
|
+
{
|
|
144
|
+
_id: 1,
|
|
145
|
+
text: 'Hello developer',
|
|
146
|
+
createdAt: new Date(),
|
|
147
|
+
user: {
|
|
148
|
+
_id: 2,
|
|
149
|
+
name: 'React Native',
|
|
150
|
+
avatar: 'https://placeimg.com/140/140/any',
|
|
155
151
|
},
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
onSend(messages = []) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}}
|
|
174
|
-
/>
|
|
175
|
-
)
|
|
176
|
-
}
|
|
152
|
+
},
|
|
153
|
+
])
|
|
154
|
+
}, [])
|
|
155
|
+
|
|
156
|
+
const onSend = useCallback((messages = []) => {
|
|
157
|
+
setMessages(previousMessages => GiftedChat.append(previousMessages, messages))
|
|
158
|
+
}, [])
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<GiftedChat
|
|
162
|
+
messages={messages}
|
|
163
|
+
onSend={messages => onSend(messages)}
|
|
164
|
+
user={{
|
|
165
|
+
_id: 1,
|
|
166
|
+
}}
|
|
167
|
+
/>
|
|
168
|
+
)
|
|
177
169
|
}
|
|
178
170
|
```
|
|
179
171
|
|
|
@@ -189,6 +181,23 @@ See the files in [`example-slack-message`](example-slack-message) for an example
|
|
|
189
181
|
|
|
190
182
|
> e.g. Chat Message
|
|
191
183
|
|
|
184
|
+
```ts
|
|
185
|
+
export interface IMessage {
|
|
186
|
+
_id: string | number
|
|
187
|
+
text: string
|
|
188
|
+
createdAt: Date | number
|
|
189
|
+
user: User
|
|
190
|
+
image?: string
|
|
191
|
+
video?: string
|
|
192
|
+
audio?: string
|
|
193
|
+
system?: boolean
|
|
194
|
+
sent?: boolean
|
|
195
|
+
received?: boolean
|
|
196
|
+
pending?: boolean
|
|
197
|
+
quickReplies?: QuickReplies
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
192
201
|
```js
|
|
193
202
|
{
|
|
194
203
|
_id: 1,
|
|
@@ -202,6 +211,12 @@ See the files in [`example-slack-message`](example-slack-message) for an example
|
|
|
202
211
|
image: 'https://facebook.github.io/react/img/logo_og.png',
|
|
203
212
|
// You can also add a video prop:
|
|
204
213
|
video: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4',
|
|
214
|
+
// Mark the message as sent, using one tick
|
|
215
|
+
sent: true,
|
|
216
|
+
// Mark the message as received, using two tick
|
|
217
|
+
received: true,
|
|
218
|
+
// Mark the message as pending with a clock loader
|
|
219
|
+
pending: true,
|
|
205
220
|
// Any additional custom parameters are passed through
|
|
206
221
|
}
|
|
207
222
|
```
|
|
@@ -305,7 +320,7 @@ interface QuickReplies {
|
|
|
305
320
|
- **`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'`)
|
|
306
321
|
- **`timeFormat`** _(String)_ - Format to use for rendering times; default is `'LT'`
|
|
307
322
|
- **`dateFormat`** _(String)_ - Format to use for rendering dates; default is `'ll'`
|
|
308
|
-
- **`loadEarlier`** _(Bool)_ - Enables the "load earlier messages" button
|
|
323
|
+
- **`loadEarlier`** _(Bool)_ - Enables the "load earlier messages" button, required for `infiniteScroll`
|
|
309
324
|
- **`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`
|
|
310
325
|
- **`onLoadEarlier`** _(Function)_ - Callback when loading earlier messages
|
|
311
326
|
- **`isLoadingEarlier`** _(Bool)_ - Display an `ActivityIndicator` when loading earlier messages
|
|
@@ -318,7 +333,9 @@ interface QuickReplies {
|
|
|
318
333
|
- **`onLongPressAvatar`** _(Function(`user`))_ - Callback when a message avatar is long-pressed
|
|
319
334
|
- **`renderAvatarOnTop`** _(Bool)_ - Render the message avatar at the top of consecutive messages, rather than the bottom; default is `false`
|
|
320
335
|
- **`renderBubble`** _(Function)_ - Custom message bubble
|
|
336
|
+
- **`renderTicks`** _(Function(`message`))_ - Custom ticks indicator to display message status
|
|
321
337
|
- **`renderSystemMessage`** _(Function)_ - Custom system message
|
|
338
|
+
- **`onPress`** _(Function(`context`, `message`))_ - Callback when a message bubble is pressed
|
|
322
339
|
- **`onLongPress`** _(Function(`context`, `message`))_ - Callback when a message bubble is long-pressed; default is to show an ActionSheet with "Copy Text" (see [example using `showActionSheetWithOptions()`](https://github.com/FaridSafi/react-native-gifted-chat/blob/master@%7B2017-09-25%7D/src/Bubble.js#L96-L119))
|
|
323
340
|
- **`inverted`** _(Bool)_ - Reverses display order of `messages`; default is `true`
|
|
324
341
|
- **`renderUsernameOnMessage`** _(Bool)_ - Indicate whether to show the user's username inside the message bubble; default is `false`
|
|
@@ -333,7 +350,7 @@ interface QuickReplies {
|
|
|
333
350
|
- **`renderCustomView`** _(Function)_ - Custom view inside the bubble
|
|
334
351
|
- **`renderDay`** _(Function)_ - Custom day above a message
|
|
335
352
|
- **`renderTime`** _(Function)_ - Custom time inside a message
|
|
336
|
-
- **`renderFooter`** _(Function)_ - Custom footer component on the ListView, e.g. `'User is typing...'`; see [
|
|
353
|
+
- **`renderFooter`** _(Function)_ - Custom footer component on the ListView, e.g. `'User is typing...'`; see [App.tsx](/App.tsx) for an example. Overrides default typing indicator that triggers when `isTyping` is true.
|
|
337
354
|
- **`renderChatEmpty`** _(Function)_ - Custom component to render in the ListView when messages are empty
|
|
338
355
|
- **`renderChatFooter`** _(Function)_ - Custom component to render below the MessageContainer (separate from the ListView)
|
|
339
356
|
- **`renderInputToolbar`** _(Function)_ - Custom message composer container
|
|
@@ -376,7 +393,7 @@ interface QuickReplies {
|
|
|
376
393
|
* **`quickReplyStyle`** _(StyleProp<ViewStyle>)_ - Custom quick reply view style
|
|
377
394
|
* **`renderQuickReplySend`** _(Function)_ - Custom quick reply **send** view
|
|
378
395
|
* **`shouldUpdateMessage`** _(Function)_ - Lets the message component know when to update outside of normal cases.
|
|
379
|
-
* **`infiniteScroll`** _(Bool)_ - infinite scroll up when reach the top of messages container, automatically call onLoadEarlier function if exist (not yet supported for the web)
|
|
396
|
+
* **`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.
|
|
380
397
|
|
|
381
398
|
## Imperative methods
|
|
382
399
|
|
|
@@ -435,15 +452,17 @@ If you use React Navigation, additional handling may be required to account for
|
|
|
435
452
|
|
|
436
453
|
### Native
|
|
437
454
|
|
|
438
|
-
1. Install `yarn add
|
|
439
|
-
2. `
|
|
455
|
+
1. Install `yarn global add expo-cli`
|
|
456
|
+
2. Install dependencies`yarn install`
|
|
457
|
+
3. `expo start`
|
|
440
458
|
|
|
441
459
|
### react-native-web
|
|
442
460
|
|
|
443
461
|
#### With expo
|
|
444
462
|
|
|
445
|
-
1. Install `yarn add
|
|
446
|
-
2. `
|
|
463
|
+
1. Install `yarn global add expo-cli`
|
|
464
|
+
2. Install dependencies`yarn install`
|
|
465
|
+
3. `expo start -w`
|
|
447
466
|
|
|
448
467
|
[Upgrade snack version](https://snackager.expo.io/bundle/react-native-gifted-chat@0.15.0?bypassCache=true)
|
|
449
468
|
|
|
@@ -509,4 +528,4 @@ Feel free to ask me questions on Twitter [@FaridSafi](https://www.twitter.com/Fa
|
|
|
509
528
|
|
|
510
529
|
## Hire an expert!
|
|
511
530
|
|
|
512
|
-
Looking for a ReactNative freelance expert with more than
|
|
531
|
+
Looking for a ReactNative freelance expert with more than 14 years of experience? Contact Xavier from his [website](https://xaviercarpentier.com)!
|
package/lib/Actions.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
import
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
3
|
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
4
4
|
export interface ActionsProps {
|
|
5
5
|
options?: {
|
|
@@ -12,9 +12,17 @@ export interface ActionsProps {
|
|
|
12
12
|
containerStyle?: StyleProp<ViewStyle>;
|
|
13
13
|
onPressActionButton?(): void;
|
|
14
14
|
}
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
export declare const Actions: {
|
|
16
|
+
({ options, optionTintColor, icon, wrapperStyle, iconTextStyle, onPressActionButton, containerStyle, }: ActionsProps): JSX.Element;
|
|
17
|
+
defaultProps: {
|
|
18
|
+
options: {};
|
|
19
|
+
optionTintColor: string;
|
|
20
|
+
icon: undefined;
|
|
21
|
+
containerStyle: {};
|
|
22
|
+
iconTextStyle: {};
|
|
23
|
+
wrapperStyle: {};
|
|
24
|
+
};
|
|
25
|
+
propTypes: {
|
|
18
26
|
onSend: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
27
|
options: PropTypes.Requireable<object>;
|
|
20
28
|
optionTintColor: PropTypes.Requireable<string>;
|
|
@@ -23,10 +31,4 @@ export default class Actions extends React.Component<ActionsProps> {
|
|
|
23
31
|
wrapperStyle: PropTypes.Requireable<number | boolean | object>;
|
|
24
32
|
containerStyle: PropTypes.Requireable<number | boolean | object>;
|
|
25
33
|
};
|
|
26
|
-
|
|
27
|
-
actionSheet: PropTypes.Requireable<(...args: any[]) => any>;
|
|
28
|
-
};
|
|
29
|
-
onActionsPress: () => void;
|
|
30
|
-
renderIcon(): {} | null | undefined;
|
|
31
|
-
render(): JSX.Element;
|
|
32
|
-
}
|
|
34
|
+
};
|
package/lib/Actions.js
CHANGED
|
@@ -3,39 +3,36 @@ import React from 'react';
|
|
|
3
3
|
import { StyleSheet, Text, TouchableOpacity, View, } from 'react-native';
|
|
4
4
|
import Color from './Color';
|
|
5
5
|
import { StylePropType } from './utils';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return this.props.icon();
|
|
6
|
+
import { useChatContext } from './GiftedChatContext';
|
|
7
|
+
import { useCallbackOne } from 'use-memo-one';
|
|
8
|
+
export const Actions = ({ options, optionTintColor, icon, wrapperStyle, iconTextStyle, onPressActionButton, containerStyle, }) => {
|
|
9
|
+
const { actionSheet } = useChatContext();
|
|
10
|
+
const onActionsPress = useCallbackOne(() => {
|
|
11
|
+
const optionKeys = Object.keys(options);
|
|
12
|
+
const cancelButtonIndex = optionKeys.indexOf('Cancel');
|
|
13
|
+
actionSheet().showActionSheetWithOptions({
|
|
14
|
+
options: optionKeys,
|
|
15
|
+
cancelButtonIndex,
|
|
16
|
+
tintColor: optionTintColor,
|
|
17
|
+
}, (buttonIndex) => {
|
|
18
|
+
const key = optionKeys[buttonIndex];
|
|
19
|
+
if (key) {
|
|
20
|
+
options[key]();
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}, []);
|
|
24
|
+
const renderIcon = useCallbackOne(() => {
|
|
25
|
+
if (icon) {
|
|
26
|
+
return icon();
|
|
28
27
|
}
|
|
29
|
-
return (<View style={[styles.wrapper,
|
|
30
|
-
<Text style={[styles.iconText,
|
|
28
|
+
return (<View style={[styles.wrapper, wrapperStyle]}>
|
|
29
|
+
<Text style={[styles.iconText, iconTextStyle]}>+</Text>
|
|
31
30
|
</View>);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
}
|
|
31
|
+
}, []);
|
|
32
|
+
return (<TouchableOpacity style={[styles.container, containerStyle]} onPress={onPressActionButton || onActionsPress}>
|
|
33
|
+
{renderIcon()}
|
|
34
|
+
</TouchableOpacity>);
|
|
35
|
+
};
|
|
39
36
|
Actions.defaultProps = {
|
|
40
37
|
options: {},
|
|
41
38
|
optionTintColor: Color.optionTintColor,
|
|
@@ -53,9 +50,6 @@ Actions.propTypes = {
|
|
|
53
50
|
wrapperStyle: StylePropType,
|
|
54
51
|
containerStyle: StylePropType,
|
|
55
52
|
};
|
|
56
|
-
Actions.contextTypes = {
|
|
57
|
-
actionSheet: PropTypes.func,
|
|
58
|
-
};
|
|
59
53
|
const styles = StyleSheet.create({
|
|
60
54
|
container: {
|
|
61
55
|
width: 26,
|
package/lib/Actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Actions.js","sourceRoot":"","sources":["../src/Actions.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,EACL,UAAU,EACV,IAAI,EACJ,gBAAgB,EAChB,IAAI,GAIL,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"Actions.js","sourceRoot":"","sources":["../src/Actions.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,EACL,UAAU,EACV,IAAI,EACJ,gBAAgB,EAChB,IAAI,GAIL,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAY7C,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EACtB,OAAO,EACP,eAAe,EACf,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,cAAc,GACD,EAAE,EAAE;IACjB,MAAM,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE,CAAA;IACxC,MAAM,cAAc,GAAG,cAAc,CAAC,GAAG,EAAE;QACzC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAQ,CAAC,CAAA;QACxC,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACtD,WAAW,EAAE,CAAC,0BAA0B,CACtC;YACE,OAAO,EAAE,UAAU;YACnB,iBAAiB;YACjB,SAAS,EAAE,eAAe;SAC3B,EACD,CAAC,WAAmB,EAAE,EAAE;YACtB,MAAM,GAAG,G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,EAAE,aAAa;IAC3B,cAAc,EAAE,aAAa;CAC9B,CAAA;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,EAAE;KACjB;IACD,OAAO,EAAE;QACP,YAAY,EAAE,EAAE;QAChB,WAAW,EAAE,KAAK,CAAC,YAAY;QAC/B,WAAW,EAAE,CAAC;QACd,IAAI,EAAE,CAAC;KACR;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,KAAK,CAAC,YAAY;QACzB,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,EAAE;QACZ,eAAe,EAAE,KAAK,CAAC,qBAAqB;QAC5C,SAAS,EAAE,QAAQ;KACpB;CACF,CAAC,CAAA"}
|
package/lib/Avatar.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
import
|
|
3
|
-
import { ImageStyle, ViewStyle } from 'react-native';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
|
4
4
|
import { Omit, IMessage, User, LeftRightStyle } from './Models';
|
|
5
5
|
export interface AvatarProps<TMessage extends IMessage> {
|
|
6
6
|
currentMessage?: TMessage;
|
|
@@ -11,12 +11,14 @@ export interface AvatarProps<TMessage extends IMessage> {
|
|
|
11
11
|
showAvatarForEveryMessage?: boolean;
|
|
12
12
|
imageStyle?: LeftRightStyle<ImageStyle>;
|
|
13
13
|
containerStyle?: LeftRightStyle<ViewStyle>;
|
|
14
|
+
textStyle?: TextStyle;
|
|
14
15
|
renderAvatar?(props: Omit<AvatarProps<TMessage>, 'renderAvatar'>): ReactNode;
|
|
15
16
|
onPressAvatar?(user: User): void;
|
|
16
17
|
onLongPressAvatar?(user: User): void;
|
|
17
18
|
}
|
|
18
|
-
export
|
|
19
|
-
|
|
19
|
+
export declare function Avatar<TMessage extends IMessage = IMessage>(props: AvatarProps<TMessage>): JSX.Element | null;
|
|
20
|
+
export declare namespace Avatar {
|
|
21
|
+
var defaultProps: {
|
|
20
22
|
renderAvatarOnTop: boolean;
|
|
21
23
|
showAvatarForEveryMessage: boolean;
|
|
22
24
|
position: string;
|
|
@@ -30,7 +32,7 @@ export default class Avatar<TMessage extends IMessage = IMessage> extends React.
|
|
|
30
32
|
onPressAvatar: () => void;
|
|
31
33
|
onLongPressAvatar: () => void;
|
|
32
34
|
};
|
|
33
|
-
|
|
35
|
+
var propTypes: {
|
|
34
36
|
renderAvatarOnTop: PropTypes.Requireable<boolean>;
|
|
35
37
|
showAvatarForEveryMessage: PropTypes.Requireable<boolean>;
|
|
36
38
|
position: PropTypes.Requireable<string>;
|
|
@@ -49,6 +51,4 @@ export default class Avatar<TMessage extends IMessage = IMessage> extends React.
|
|
|
49
51
|
right: PropTypes.Requireable<number | boolean | object>;
|
|
50
52
|
}>>;
|
|
51
53
|
};
|
|
52
|
-
renderAvatar(): {} | null | undefined;
|
|
53
|
-
render(): JSX.Element | null;
|
|
54
54
|
}
|
package/lib/Avatar.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { StyleSheet, View, } from 'react-native';
|
|
4
4
|
import GiftedAvatar from './GiftedAvatar';
|
|
5
5
|
import { StylePropType, isSameUser, isSameDay } from './utils';
|
|
6
6
|
const styles = {
|
|
@@ -33,53 +33,48 @@ const styles = {
|
|
|
33
33
|
},
|
|
34
34
|
}),
|
|
35
35
|
};
|
|
36
|
-
export
|
|
37
|
-
renderAvatar
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
if (this.props.currentMessage) {
|
|
43
|
-
return (<GiftedAvatar avatarStyle={[
|
|
44
|
-
styles[this.props.position].image,
|
|
45
|
-
this.props.imageStyle &&
|
|
46
|
-
this.props.imageStyle[this.props.position],
|
|
47
|
-
]} user={this.props.currentMessage.user} onPress={() => this.props.onPressAvatar &&
|
|
48
|
-
this.props.onPressAvatar(this.props.currentMessage.user)} onLongPress={() => this.props.onLongPressAvatar &&
|
|
49
|
-
this.props.onLongPressAvatar(this.props.currentMessage.user)}/>);
|
|
50
|
-
}
|
|
36
|
+
export function Avatar(props) {
|
|
37
|
+
const { renderAvatarOnTop, showAvatarForEveryMessage, containerStyle, position, currentMessage, renderAvatar, previousMessage, nextMessage, imageStyle, } = props;
|
|
38
|
+
const messageToCompare = renderAvatarOnTop ? previousMessage : nextMessage;
|
|
39
|
+
const computedStyle = renderAvatarOnTop ? 'onTop' : 'onBottom';
|
|
40
|
+
if (renderAvatar === null) {
|
|
51
41
|
return null;
|
|
52
42
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
if (!showAvatarForEveryMessage &&
|
|
61
|
-
currentMessage &&
|
|
62
|
-
messageToCompare &&
|
|
63
|
-
isSameUser(currentMessage, messageToCompare) &&
|
|
64
|
-
isSameDay(currentMessage, messageToCompare)) {
|
|
65
|
-
return (<View style={[
|
|
66
|
-
styles[position].container,
|
|
67
|
-
containerStyle && containerStyle[position],
|
|
68
|
-
]}>
|
|
69
|
-
<GiftedAvatar avatarStyle={[
|
|
70
|
-
styles[position].image,
|
|
71
|
-
imageStyle && imageStyle[position],
|
|
72
|
-
]}/>
|
|
73
|
-
</View>);
|
|
74
|
-
}
|
|
43
|
+
if (!showAvatarForEveryMessage &&
|
|
44
|
+
currentMessage &&
|
|
45
|
+
messageToCompare &&
|
|
46
|
+
isSameUser(currentMessage, messageToCompare) &&
|
|
47
|
+
isSameDay(currentMessage, messageToCompare)) {
|
|
75
48
|
return (<View style={[
|
|
76
49
|
styles[position].container,
|
|
77
|
-
styles[position][computedStyle],
|
|
78
50
|
containerStyle && containerStyle[position],
|
|
79
51
|
]}>
|
|
80
|
-
{
|
|
52
|
+
<GiftedAvatar avatarStyle={[
|
|
53
|
+
styles[position].image,
|
|
54
|
+
imageStyle && imageStyle[position],
|
|
55
|
+
]}/>
|
|
81
56
|
</View>);
|
|
82
57
|
}
|
|
58
|
+
const renderAvatarComponent = () => {
|
|
59
|
+
if (props.renderAvatar) {
|
|
60
|
+
const { renderAvatar, ...avatarProps } = props;
|
|
61
|
+
return props.renderAvatar(avatarProps);
|
|
62
|
+
}
|
|
63
|
+
if (props.currentMessage) {
|
|
64
|
+
return (<GiftedAvatar avatarStyle={[
|
|
65
|
+
styles[props.position].image,
|
|
66
|
+
props.imageStyle && props.imageStyle[props.position],
|
|
67
|
+
]} user={props.currentMessage.user} onPress={() => { var _a; return (_a = props.onPressAvatar) === null || _a === void 0 ? void 0 : _a.call(props, props.currentMessage.user); }} onLongPress={() => { var _a; return (_a = props.onLongPressAvatar) === null || _a === void 0 ? void 0 : _a.call(props, props.currentMessage.user); }}/>);
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
};
|
|
71
|
+
return (<View style={[
|
|
72
|
+
styles[position].container,
|
|
73
|
+
styles[position][computedStyle],
|
|
74
|
+
containerStyle && containerStyle[position],
|
|
75
|
+
]}>
|
|
76
|
+
{renderAvatarComponent()}
|
|
77
|
+
</View>);
|
|
83
78
|
}
|
|
84
79
|
Avatar.defaultProps = {
|
|
85
80
|
renderAvatarOnTop: false,
|
package/lib/Avatar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../src/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../src/Avatar.tsx"],"names":[],"mappings":"AAAA,OA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AC1B,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,aAAa;KACrB,CAAC;CACH,CAAA"}
|
package/lib/Bubble.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
4
|
+
import { QuickRepliesProps } from './QuickReplies';
|
|
5
|
+
import { MessageTextProps } from './MessageText';
|
|
6
|
+
import { MessageImageProps } from './MessageImage';
|
|
7
|
+
import { TimeProps } from './Time';
|
|
8
8
|
import { User, IMessage, LeftRightStyle, Reply, Omit, MessageVideoProps, MessageAudioProps } from './Models';
|
|
9
|
-
export declare type RenderMessageImageProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> &
|
|
9
|
+
export declare type RenderMessageImageProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageImageProps<TMessage>;
|
|
10
10
|
export declare type RenderMessageVideoProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageVideoProps<TMessage>;
|
|
11
11
|
export declare type RenderMessageAudioProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageAudioProps<TMessage>;
|
|
12
|
-
export declare type RenderMessageTextProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> &
|
|
12
|
+
export declare type RenderMessageTextProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageTextProps<TMessage>;
|
|
13
13
|
export interface BubbleProps<TMessage extends IMessage> {
|
|
14
14
|
user?: User;
|
|
15
15
|
touchableProps?: object;
|
|
@@ -30,6 +30,7 @@ export interface BubbleProps<TMessage extends IMessage> {
|
|
|
30
30
|
containerToPreviousStyle?: LeftRightStyle<ViewStyle>;
|
|
31
31
|
usernameStyle?: TextStyle;
|
|
32
32
|
quickReplyStyle?: StyleProp<ViewStyle>;
|
|
33
|
+
onPress?(context?: any, message?: any): void;
|
|
33
34
|
onLongPress?(context?: any, message?: any): void;
|
|
34
35
|
onQuickReply?(replies: Reply[]): void;
|
|
35
36
|
renderMessageImage?(props: RenderMessageImageProps<TMessage>): React.ReactNode;
|
|
@@ -37,11 +38,11 @@ export interface BubbleProps<TMessage extends IMessage> {
|
|
|
37
38
|
renderMessageAudio?(props: RenderMessageAudioProps<TMessage>): React.ReactNode;
|
|
38
39
|
renderMessageText?(props: RenderMessageTextProps<TMessage>): React.ReactNode;
|
|
39
40
|
renderCustomView?(bubbleProps: BubbleProps<TMessage>): React.ReactNode;
|
|
40
|
-
renderTime?(timeProps:
|
|
41
|
+
renderTime?(timeProps: TimeProps<TMessage>): React.ReactNode;
|
|
41
42
|
renderTicks?(currentMessage: TMessage): React.ReactNode;
|
|
42
43
|
renderUsername?(): React.ReactNode;
|
|
43
44
|
renderQuickReplySend?(): React.ReactNode;
|
|
44
|
-
renderQuickReplies?(quickReplies:
|
|
45
|
+
renderQuickReplies?(quickReplies: QuickRepliesProps): React.ReactNode;
|
|
45
46
|
}
|
|
46
47
|
export default class Bubble<TMessage extends IMessage = IMessage> extends React.Component<BubbleProps<TMessage>> {
|
|
47
48
|
static contextTypes: {
|
|
@@ -49,6 +50,7 @@ export default class Bubble<TMessage extends IMessage = IMessage> extends React.
|
|
|
49
50
|
};
|
|
50
51
|
static defaultProps: {
|
|
51
52
|
touchableProps: {};
|
|
53
|
+
onPress: null;
|
|
52
54
|
onLongPress: null;
|
|
53
55
|
renderMessageImage: null;
|
|
54
56
|
renderMessageVideo: null;
|
|
@@ -121,6 +123,7 @@ export default class Bubble<TMessage extends IMessage = IMessage> extends React.
|
|
|
121
123
|
right: PropTypes.Requireable<number | boolean | object>;
|
|
122
124
|
}>>;
|
|
123
125
|
};
|
|
126
|
+
onPress: () => void;
|
|
124
127
|
onLongPress: () => void;
|
|
125
128
|
styledBubbleToNext(): (false | ViewStyle | import("react-native").RegisteredStyle<ViewStyle> | import("react-native").RecursiveArray<false | ViewStyle | import("react-native").RegisteredStyle<ViewStyle> | null | undefined> | {
|
|
126
129
|
borderBottomLeftRadius: number;
|
package/lib/Bubble.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Text, Clipboard, StyleSheet, TouchableWithoutFeedback, View, } from 'react-native';
|
|
4
|
-
import QuickReplies from './QuickReplies';
|
|
5
|
-
import MessageText from './MessageText';
|
|
6
|
-
import MessageImage from './MessageImage';
|
|
7
|
-
import MessageVideo from './MessageVideo';
|
|
8
|
-
import MessageAudio from './MessageAudio';
|
|
9
|
-
import Time from './Time';
|
|
4
|
+
import { QuickReplies } from './QuickReplies';
|
|
5
|
+
import { MessageText } from './MessageText';
|
|
6
|
+
import { MessageImage } from './MessageImage';
|
|
7
|
+
import { MessageVideo } from './MessageVideo';
|
|
8
|
+
import { MessageAudio } from './MessageAudio';
|
|
9
|
+
import { Time } from './Time';
|
|
10
10
|
import Color from './Color';
|
|
11
11
|
import { StylePropType, isSameUser, isSameDay } from './utils';
|
|
12
12
|
const styles = {
|
|
@@ -83,6 +83,11 @@ const DEFAULT_OPTION_TITLES = ['Copy Text', 'Cancel'];
|
|
|
83
83
|
export default class Bubble extends React.Component {
|
|
84
84
|
constructor() {
|
|
85
85
|
super(...arguments);
|
|
86
|
+
this.onPress = () => {
|
|
87
|
+
if (this.props.onPress) {
|
|
88
|
+
this.props.onPress(this.context, this.props.currentMessage);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
86
91
|
this.onLongPress = () => {
|
|
87
92
|
const { currentMessage } = this.props;
|
|
88
93
|
if (this.props.onLongPress) {
|
|
@@ -272,7 +277,7 @@ export default class Bubble extends React.Component {
|
|
|
272
277
|
this.styledBubbleToPrevious(),
|
|
273
278
|
wrapperStyle && wrapperStyle[position],
|
|
274
279
|
]}>
|
|
275
|
-
<TouchableWithoutFeedback onLongPress={this.onLongPress}
|
|
280
|
+
<TouchableWithoutFeedback onPress={this.onPress} onLongPress={this.onLongPress} accessibilityRole='text' {...this.props.touchableProps}>
|
|
276
281
|
<View>
|
|
277
282
|
{this.renderBubbleContent()}
|
|
278
283
|
<View style={[
|
|
@@ -295,6 +300,7 @@ Bubble.contextTypes = {
|
|
|
295
300
|
};
|
|
296
301
|
Bubble.defaultProps = {
|
|
297
302
|
touchableProps: {},
|
|
303
|
+
onPress: null,
|
|
298
304
|
onLongPress: null,
|
|
299
305
|
renderMessageImage: null,
|
|
300
306
|
renderMessageVideo: null,
|