react-native-gifted-chat 0.16.3 → 1.0.0-beta-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/.eslintignore +2 -0
- package/.eslintrc.js +21 -0
- package/README.md +18 -15
- package/jest.config.js +15 -0
- package/lib/Actions.d.ts +4 -10
- package/lib/Actions.js +27 -41
- package/lib/Actions.js.map +1 -1
- package/lib/Avatar.d.ts +5 -6
- package/lib/Avatar.js +29 -34
- package/lib/Avatar.js.map +1 -1
- package/lib/Bubble.d.ts +24 -20
- package/lib/Bubble.js +26 -19
- package/lib/Bubble.js.map +1 -1
- package/lib/Composer.d.ts +4 -24
- package/lib/Composer.js +22 -44
- package/lib/Composer.js.map +1 -1
- package/lib/Day.d.ts +5 -19
- package/lib/Day.js +14 -29
- package/lib/Day.js.map +1 -1
- package/lib/GiftedAvatar.js +9 -9
- package/lib/GiftedAvatar.js.map +1 -1
- package/lib/GiftedChat.d.ts +54 -42
- package/lib/GiftedChat.js +69 -42
- 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 +13 -37
- package/lib/InputToolbar.js +27 -93
- package/lib/InputToolbar.js.map +1 -1
- package/lib/LoadEarlier.d.ts +3 -15
- package/lib/LoadEarlier.js +11 -36
- package/lib/LoadEarlier.js.map +1 -1
- package/lib/Message.d.ts +13 -10
- package/lib/Message.js +16 -14
- 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 +10 -13
- package/lib/MessageContainer.js +11 -48
- package/lib/MessageContainer.js.map +1 -1
- package/lib/MessageImage.d.ts +5 -14
- package/lib/MessageImage.js +11 -24
- package/lib/MessageImage.js.map +1 -1
- package/lib/MessageText.d.ts +4 -25
- package/lib/MessageText.js +77 -93
- 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 +5 -5
- package/lib/Models.js +1 -0
- package/lib/QuickReplies.d.ts +6 -27
- package/lib/QuickReplies.js +65 -97
- package/lib/QuickReplies.js.map +1 -1
- package/lib/Send.d.ts +5 -17
- package/lib/Send.js +15 -31
- package/lib/Send.js.map +1 -1
- package/lib/SystemMessage.d.ts +3 -12
- package/lib/SystemMessage.js +8 -19
- package/lib/SystemMessage.js.map +1 -1
- package/lib/Time.d.ts +4 -17
- package/lib/Time.js +30 -41
- package/lib/Time.js.map +1 -1
- package/lib/TypingIndicator.d.ts +0 -1
- package/lib/TypingIndicator.js +11 -11
- 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 +41 -67
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: {
|
|
4
|
+
node: true,
|
|
5
|
+
},
|
|
6
|
+
parser: '@typescript-eslint/parser',
|
|
7
|
+
plugins: ['@typescript-eslint'],
|
|
8
|
+
// extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
|
|
9
|
+
rules: {
|
|
10
|
+
'member-access': 0,
|
|
11
|
+
'interface-name': 0,
|
|
12
|
+
'ordered-imports': 0,
|
|
13
|
+
'object-literal-sort-keys': 0,
|
|
14
|
+
'variable-name': 0,
|
|
15
|
+
'one-variable-per-declaration': 0,
|
|
16
|
+
'no-empty': 0,
|
|
17
|
+
'no-console': 0,
|
|
18
|
+
'no-shadowed-variable': 0,
|
|
19
|
+
'no-extra-boolean-cast': 0,
|
|
20
|
+
},
|
|
21
|
+
}
|
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>
|
|
@@ -57,15 +56,15 @@
|
|
|
57
56
|
|
|
58
57
|
<p align="center">
|
|
59
58
|
<br/>
|
|
60
|
-
<a href="https://getstream.io/chat/?utm_source=
|
|
59
|
+
<a href="https://getstream.io/chat/?utm_source=Github&utm_medium=Github_Repo_Content_Ad&utm_content=Developer&utm_campaign=Github_Jan2022_Chat&utm_term=react-native-gifted-chat" target="_blank">
|
|
61
60
|
<img src="https://i.imgur.com/oU7XYkk.png">
|
|
62
61
|
</a>
|
|
63
62
|
<br>
|
|
64
63
|
<p align="center">
|
|
65
|
-
Scalable <a href="https://getstream.io/chat/?utm_source=
|
|
64
|
+
Scalable <a href="https://getstream.io/chat/?utm_source=Github&utm_medium=Github_Repo_Content_Ad&utm_content=Developer&utm_campaign=Github_Jan2022_Chat&utm_term=react-native-gifted-chat" target="_blank">chat API/Server</a> written in Go
|
|
66
65
|
</p>
|
|
67
66
|
<p align="center">
|
|
68
|
-
<a href="https://getstream.io/chat/get_started/?utm_source=
|
|
67
|
+
<a href="https://getstream.io/chat/get_started/?utm_source=Github&utm_medium=Github_Repo_Content_Ad&utm_content=Developer&utm_campaign=Github_Jan2022_Chat&utm_term=react-native-gifted-chat" target="_blank">API Tour</a> | <a href="https://dev.to/nickparsons/react-native-chat-with-chuck-norris-3h7m?utm_source=Github&utm_medium=Github_Repo_Content_Ad&utm_content=Developer&utm_campaign=Github_Jan2022_Chat&utm_term=react-native-gifted-chat" target="_blank">React Native Gifted tutorial</a>
|
|
69
68
|
</p>
|
|
70
69
|
</p>
|
|
71
70
|
|
|
@@ -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
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
- Redux support
|
|
105
105
|
- System message
|
|
106
106
|
- Quick Reply messages (bot)
|
|
107
|
-
-
|
|
107
|
+
- Typing indicator [react-native-typing-animation](https://github.com/watadarkstar/react-native-typing-animation)
|
|
108
108
|
|
|
109
109
|
## Dependency
|
|
110
110
|
|
|
@@ -318,8 +318,8 @@ interface QuickReplies {
|
|
|
318
318
|
- **`onSend`** _(Function)_ - Callback when sending a message
|
|
319
319
|
- **`alwaysShowSend`** _(Bool)_ - Always show send button in input text composer; default `false`, show only when text input is not empty
|
|
320
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'`)
|
|
321
|
-
- **`timeFormat`** _(String)_ - Format to use for rendering times; default is `'LT'`
|
|
322
|
-
- **`dateFormat`** _(String)_ - Format to use for rendering dates; default is `'ll'`
|
|
321
|
+
- **`timeFormat`** _(String)_ - Format to use for rendering times; default is `'LT'` (see [Day.js Format](https://day.js.org/docs/en/display/format))
|
|
322
|
+
- **`dateFormat`** _(String)_ - Format to use for rendering dates; default is `'ll'` (see [Day.js Format](https://day.js.org/docs/en/display/format))
|
|
323
323
|
- **`loadEarlier`** _(Bool)_ - Enables the "load earlier messages" button, required for `infiniteScroll`
|
|
324
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`
|
|
325
325
|
- **`onLoadEarlier`** _(Function)_ - Callback when loading earlier messages
|
|
@@ -335,6 +335,7 @@ interface QuickReplies {
|
|
|
335
335
|
- **`renderBubble`** _(Function)_ - Custom message bubble
|
|
336
336
|
- **`renderTicks`** _(Function(`message`))_ - Custom ticks indicator to display message status
|
|
337
337
|
- **`renderSystemMessage`** _(Function)_ - Custom system message
|
|
338
|
+
- **`onPress`** _(Function(`context`, `message`))_ - Callback when a message bubble is pressed
|
|
338
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))
|
|
339
340
|
- **`inverted`** _(Bool)_ - Reverses display order of `messages`; default is `true`
|
|
340
341
|
- **`renderUsernameOnMessage`** _(Bool)_ - Indicate whether to show the user's username inside the message bubble; default is `false`
|
|
@@ -349,7 +350,7 @@ interface QuickReplies {
|
|
|
349
350
|
- **`renderCustomView`** _(Function)_ - Custom view inside the bubble
|
|
350
351
|
- **`renderDay`** _(Function)_ - Custom day above a message
|
|
351
352
|
- **`renderTime`** _(Function)_ - Custom time inside a message
|
|
352
|
-
- **`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.
|
|
353
354
|
- **`renderChatEmpty`** _(Function)_ - Custom component to render in the ListView when messages are empty
|
|
354
355
|
- **`renderChatFooter`** _(Function)_ - Custom component to render below the MessageContainer (separate from the ListView)
|
|
355
356
|
- **`renderInputToolbar`** _(Function)_ - Custom message composer container
|
|
@@ -451,15 +452,17 @@ If you use React Navigation, additional handling may be required to account for
|
|
|
451
452
|
|
|
452
453
|
### Native
|
|
453
454
|
|
|
454
|
-
1. Install `yarn add
|
|
455
|
-
2. `
|
|
455
|
+
1. Install `yarn global add expo-cli`
|
|
456
|
+
2. Install dependencies`yarn install`
|
|
457
|
+
3. `expo start`
|
|
456
458
|
|
|
457
459
|
### react-native-web
|
|
458
460
|
|
|
459
461
|
#### With expo
|
|
460
462
|
|
|
461
|
-
1. Install `yarn add
|
|
462
|
-
2. `
|
|
463
|
+
1. Install `yarn global add expo-cli`
|
|
464
|
+
2. Install dependencies`yarn install`
|
|
465
|
+
3. `expo start -w`
|
|
463
466
|
|
|
464
467
|
[Upgrade snack version](https://snackager.expo.io/bundle/react-native-gifted-chat@0.15.0?bypassCache=true)
|
|
465
468
|
|
|
@@ -525,4 +528,4 @@ Feel free to ask me questions on Twitter [@FaridSafi](https://www.twitter.com/Fa
|
|
|
525
528
|
|
|
526
529
|
## Hire an expert!
|
|
527
530
|
|
|
528
|
-
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/jest.config.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
preset: 'react-native',
|
|
3
|
+
setupFiles: ['<rootDir>/tests/setup.js'],
|
|
4
|
+
moduleFileExtensions: ['js', 'jsx', 'json', 'ts', 'tsx'],
|
|
5
|
+
transform: {
|
|
6
|
+
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
|
|
7
|
+
// '^.+\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js',
|
|
8
|
+
},
|
|
9
|
+
transformIgnorePatterns: [
|
|
10
|
+
'/node_modules/(?!(@react-native|react-native)).*/',
|
|
11
|
+
],
|
|
12
|
+
testMatch: ['**/*.test.ts?(x)'],
|
|
13
|
+
modulePathIgnorePatterns: ['<rootDir>/example'],
|
|
14
|
+
coveragePathIgnorePatterns: ['./src/__tests__/'],
|
|
15
|
+
}
|
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,9 @@ export interface ActionsProps {
|
|
|
12
12
|
containerStyle?: StyleProp<ViewStyle>;
|
|
13
13
|
onPressActionButton?(): void;
|
|
14
14
|
}
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
export declare function Actions({ options, optionTintColor, icon, wrapperStyle, iconTextStyle, onPressActionButton, containerStyle, }: ActionsProps): JSX.Element;
|
|
16
|
+
export declare namespace Actions {
|
|
17
|
+
var propTypes: {
|
|
18
18
|
onSend: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
19
|
options: PropTypes.Requireable<object>;
|
|
20
20
|
optionTintColor: PropTypes.Requireable<string>;
|
|
@@ -23,10 +23,4 @@ export default class Actions extends React.Component<ActionsProps> {
|
|
|
23
23
|
wrapperStyle: PropTypes.Requireable<number | boolean | object>;
|
|
24
24
|
containerStyle: PropTypes.Requireable<number | boolean | object>;
|
|
25
25
|
};
|
|
26
|
-
static contextTypes: {
|
|
27
|
-
actionSheet: PropTypes.Requireable<(...args: any[]) => any>;
|
|
28
|
-
};
|
|
29
|
-
onActionsPress: () => void;
|
|
30
|
-
renderIcon(): {} | null | undefined;
|
|
31
|
-
render(): JSX.Element;
|
|
32
26
|
}
|
package/lib/Actions.js
CHANGED
|
@@ -3,47 +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 function Actions({ options = {}, optionTintColor = Color.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
|
-
</TouchableOpacity>);
|
|
37
|
-
}
|
|
31
|
+
}, []);
|
|
32
|
+
return (<TouchableOpacity style={[styles.container, containerStyle]} onPress={onPressActionButton || onActionsPress}>
|
|
33
|
+
{renderIcon()}
|
|
34
|
+
</TouchableOpacity>);
|
|
38
35
|
}
|
|
39
|
-
Actions.defaultProps = {
|
|
40
|
-
options: {},
|
|
41
|
-
optionTintColor: Color.optionTintColor,
|
|
42
|
-
icon: undefined,
|
|
43
|
-
containerStyle: {},
|
|
44
|
-
iconTextStyle: {},
|
|
45
|
-
wrapperStyle: {},
|
|
46
|
-
};
|
|
47
36
|
Actions.propTypes = {
|
|
48
37
|
onSend: PropTypes.func,
|
|
49
38
|
options: PropTypes.object,
|
|
@@ -53,9 +42,6 @@ Actions.propTypes = {
|
|
|
53
42
|
wrapperStyle: StylePropType,
|
|
54
43
|
containerStyle: StylePropType,
|
|
55
44
|
};
|
|
56
|
-
Actions.contextTypes = {
|
|
57
|
-
actionSheet: PropTypes.func,
|
|
58
|
-
};
|
|
59
45
|
const styles = StyleSheet.create({
|
|
60
46
|
container: {
|
|
61
47
|
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/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F,CAAC,CAAA"}
|
package/lib/Avatar.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
import
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
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> {
|
|
@@ -16,8 +16,9 @@ export interface AvatarProps<TMessage extends IMessage> {
|
|
|
16
16
|
onPressAvatar?(user: User): void;
|
|
17
17
|
onLongPressAvatar?(user: User): void;
|
|
18
18
|
}
|
|
19
|
-
export
|
|
20
|
-
|
|
19
|
+
export declare function Avatar<TMessage extends IMessage = IMessage>(props: AvatarProps<TMessage>): JSX.Element | null;
|
|
20
|
+
export declare namespace Avatar {
|
|
21
|
+
var defaultProps: {
|
|
21
22
|
renderAvatarOnTop: boolean;
|
|
22
23
|
showAvatarForEveryMessage: boolean;
|
|
23
24
|
position: string;
|
|
@@ -31,7 +32,7 @@ export default class Avatar<TMessage extends IMessage = IMessage> extends React.
|
|
|
31
32
|
onPressAvatar: () => void;
|
|
32
33
|
onLongPressAvatar: () => void;
|
|
33
34
|
};
|
|
34
|
-
|
|
35
|
+
var propTypes: {
|
|
35
36
|
renderAvatarOnTop: PropTypes.Requireable<boolean>;
|
|
36
37
|
showAvatarForEveryMessage: PropTypes.Requireable<boolean>;
|
|
37
38
|
position: PropTypes.Requireable<string>;
|
|
@@ -50,6 +51,4 @@ export default class Avatar<TMessage extends IMessage = IMessage> extends React.
|
|
|
50
51
|
right: PropTypes.Requireable<number | boolean | object>;
|
|
51
52
|
}>>;
|
|
52
53
|
};
|
|
53
|
-
renderAvatar(): {} | null | undefined;
|
|
54
|
-
render(): JSX.Element | null;
|
|
55
54
|
}
|
package/lib/Avatar.js
CHANGED
|
@@ -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
|
-
]} textStyle={this.props.textStyle ? this.props.textStyle : {}} 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
|
-
|
|
59
|
-
}
|
|
60
|
-
if (!showAvatarForEveryMessage &&
|
|
61
|
-
currentMessage &&
|
|
62
|
-
messageToCompare &&
|
|
63
|
-
isSameUser(currentMessage, messageToCompare) &&
|
|
64
|
-
isSameDay(currentMessage, messageToCompare)) {
|
|
65
|
-
return (<View style={[
|
|
43
|
+
if (!showAvatarForEveryMessage &&
|
|
44
|
+
currentMessage &&
|
|
45
|
+
messageToCompare &&
|
|
46
|
+
isSameUser(currentMessage, messageToCompare) &&
|
|
47
|
+
isSameDay(currentMessage, messageToCompare)) {
|
|
48
|
+
return (<View style={[
|
|
66
49
|
styles[position].container,
|
|
67
50
|
containerStyle && containerStyle[position],
|
|
68
51
|
]}>
|
|
69
|
-
|
|
52
|
+
<GiftedAvatar avatarStyle={[
|
|
70
53
|
styles[position].image,
|
|
71
54
|
imageStyle && imageStyle[position],
|
|
72
55
|
]}/>
|
|
73
|
-
|
|
56
|
+
</View>);
|
|
57
|
+
}
|
|
58
|
+
const renderAvatarComponent = () => {
|
|
59
|
+
if (props.renderAvatar) {
|
|
60
|
+
const { renderAvatar, ...avatarProps } = props;
|
|
61
|
+
return props.renderAvatar(avatarProps);
|
|
74
62
|
}
|
|
75
|
-
|
|
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={[
|
|
76
72
|
styles[position].container,
|
|
77
73
|
styles[position][computedStyle],
|
|
78
74
|
containerStyle && containerStyle[position],
|
|
79
75
|
]}>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
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,EACL,UAAU,EACV,IAAI,GAIL,MAAM,cAAc,CAAA;AAC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cAAc,EAAE;QACd,IAAI,EAAE,IAAI;KACX;IACD,eAAe,EAAE,EAAE;IACnB,WAAW,EAAE,EAAE;IACf,cAAc,EAAE,EAAE;IAClB,UAAU,EAAE,EAAE;IACd,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;IACvB,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;CAC5B,CAAA;AAED,MAAM,CAAC,SAAS,GAAG;IACjB,iBAAiB,EAAE,SAAS,CAAC,IAAI;IACjC,yBAAyB,EAAE,SAAS,CAAC,IAAI;IACzC,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,cAAc,EAAE,SAAS,CAAC,MAAM;IAChC,eAAe,EAAE,SAAS,CAAC,MAAM;IACjC,WAAW,EAAE,SAAS,CAAC,MAAM;IAC7B,aAAa,EAAE,SAAS,CAAC,IAAI;IAC7B,iBAAiB,EAAE,SAAS,CAAC,IAAI;IACjC,YAAY,EAAE,SAAS,CAAC,IAAI;IAC5B,cAAc,EAAE,SAAS,CAAC,KAAK,CAAC;QAC9B,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,aAAa;KACrB,CAAC;IACF,UAAU,EAAE,SAAS,CAAC,KAAK,CAAC;QAC1B,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,8 @@ export interface BubbleProps<TMessage extends IMessage> {
|
|
|
30
30
|
containerToPreviousStyle?: LeftRightStyle<ViewStyle>;
|
|
31
31
|
usernameStyle?: TextStyle;
|
|
32
32
|
quickReplyStyle?: StyleProp<ViewStyle>;
|
|
33
|
+
quickReplyTextStyle?: StyleProp<TextStyle>;
|
|
34
|
+
onPress?(context?: any, message?: any): void;
|
|
33
35
|
onLongPress?(context?: any, message?: any): void;
|
|
34
36
|
onQuickReply?(replies: Reply[]): void;
|
|
35
37
|
renderMessageImage?(props: RenderMessageImageProps<TMessage>): React.ReactNode;
|
|
@@ -37,11 +39,11 @@ export interface BubbleProps<TMessage extends IMessage> {
|
|
|
37
39
|
renderMessageAudio?(props: RenderMessageAudioProps<TMessage>): React.ReactNode;
|
|
38
40
|
renderMessageText?(props: RenderMessageTextProps<TMessage>): React.ReactNode;
|
|
39
41
|
renderCustomView?(bubbleProps: BubbleProps<TMessage>): React.ReactNode;
|
|
40
|
-
renderTime?(timeProps:
|
|
42
|
+
renderTime?(timeProps: TimeProps<TMessage>): React.ReactNode;
|
|
41
43
|
renderTicks?(currentMessage: TMessage): React.ReactNode;
|
|
42
44
|
renderUsername?(): React.ReactNode;
|
|
43
45
|
renderQuickReplySend?(): React.ReactNode;
|
|
44
|
-
renderQuickReplies?(quickReplies:
|
|
46
|
+
renderQuickReplies?(quickReplies: QuickRepliesProps): React.ReactNode;
|
|
45
47
|
}
|
|
46
48
|
export default class Bubble<TMessage extends IMessage = IMessage> extends React.Component<BubbleProps<TMessage>> {
|
|
47
49
|
static contextTypes: {
|
|
@@ -49,6 +51,7 @@ export default class Bubble<TMessage extends IMessage = IMessage> extends React.
|
|
|
49
51
|
};
|
|
50
52
|
static defaultProps: {
|
|
51
53
|
touchableProps: {};
|
|
54
|
+
onPress: null;
|
|
52
55
|
onLongPress: null;
|
|
53
56
|
renderMessageImage: null;
|
|
54
57
|
renderMessageVideo: null;
|
|
@@ -121,26 +124,27 @@ export default class Bubble<TMessage extends IMessage = IMessage> extends React.
|
|
|
121
124
|
right: PropTypes.Requireable<number | boolean | object>;
|
|
122
125
|
}>>;
|
|
123
126
|
};
|
|
127
|
+
onPress: () => void;
|
|
124
128
|
onLongPress: () => void;
|
|
125
|
-
styledBubbleToNext(): (
|
|
129
|
+
styledBubbleToNext(): (StyleProp<ViewStyle> | {
|
|
126
130
|
borderBottomLeftRadius: number;
|
|
127
131
|
} | {
|
|
128
132
|
borderBottomRightRadius: number;
|
|
129
|
-
}
|
|
130
|
-
styledBubbleToPrevious(): (
|
|
133
|
+
})[] | null;
|
|
134
|
+
styledBubbleToPrevious(): (StyleProp<ViewStyle> | {
|
|
131
135
|
borderTopLeftRadius: number;
|
|
132
136
|
} | {
|
|
133
137
|
borderTopRightRadius: number;
|
|
134
|
-
}
|
|
135
|
-
renderQuickReplies():
|
|
136
|
-
renderMessageText():
|
|
137
|
-
renderMessageImage():
|
|
138
|
-
renderMessageVideo():
|
|
139
|
-
renderMessageAudio():
|
|
140
|
-
renderTicks():
|
|
141
|
-
renderTime():
|
|
138
|
+
})[] | null;
|
|
139
|
+
renderQuickReplies(): React.ReactNode;
|
|
140
|
+
renderMessageText(): React.ReactNode;
|
|
141
|
+
renderMessageImage(): React.ReactNode;
|
|
142
|
+
renderMessageVideo(): React.ReactNode;
|
|
143
|
+
renderMessageAudio(): React.ReactNode;
|
|
144
|
+
renderTicks(): React.ReactNode;
|
|
145
|
+
renderTime(): React.ReactNode;
|
|
142
146
|
renderUsername(): JSX.Element | null;
|
|
143
|
-
renderCustomView():
|
|
147
|
+
renderCustomView(): React.ReactNode;
|
|
144
148
|
renderBubbleContent(): JSX.Element;
|
|
145
149
|
render(): JSX.Element;
|
|
146
150
|
}
|
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) {
|
|
@@ -138,7 +143,7 @@ export default class Bubble extends React.Component {
|
|
|
138
143
|
return null;
|
|
139
144
|
}
|
|
140
145
|
renderQuickReplies() {
|
|
141
|
-
const { currentMessage, onQuickReply, nextMessage, renderQuickReplySend, quickReplyStyle, } = this.props;
|
|
146
|
+
const { currentMessage, onQuickReply, nextMessage, renderQuickReplySend, quickReplyStyle, quickReplyTextStyle, } = this.props;
|
|
142
147
|
if (currentMessage && currentMessage.quickReplies) {
|
|
143
148
|
const { containerStyle, wrapperStyle, ...quickReplyProps } = this.props;
|
|
144
149
|
if (this.props.renderQuickReplies) {
|
|
@@ -150,6 +155,7 @@ export default class Bubble extends React.Component {
|
|
|
150
155
|
nextMessage,
|
|
151
156
|
renderQuickReplySend,
|
|
152
157
|
quickReplyStyle,
|
|
158
|
+
quickReplyTextStyle,
|
|
153
159
|
}}/>);
|
|
154
160
|
}
|
|
155
161
|
return null;
|
|
@@ -263,22 +269,22 @@ export default class Bubble extends React.Component {
|
|
|
263
269
|
render() {
|
|
264
270
|
const { position, containerStyle, wrapperStyle, bottomContainerStyle, } = this.props;
|
|
265
271
|
return (<View style={[
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
272
|
+
styles[position].container,
|
|
273
|
+
containerStyle && containerStyle[position],
|
|
274
|
+
]}>
|
|
269
275
|
<View style={[
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
<TouchableWithoutFeedback onLongPress={this.onLongPress}
|
|
276
|
+
styles[position].wrapper,
|
|
277
|
+
this.styledBubbleToNext(),
|
|
278
|
+
this.styledBubbleToPrevious(),
|
|
279
|
+
wrapperStyle && wrapperStyle[position],
|
|
280
|
+
]}>
|
|
281
|
+
<TouchableWithoutFeedback onPress={this.onPress} onLongPress={this.onLongPress} accessibilityRole='text' {...this.props.touchableProps}>
|
|
276
282
|
<View>
|
|
277
283
|
{this.renderBubbleContent()}
|
|
278
284
|
<View style={[
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
285
|
+
styles[position].bottom,
|
|
286
|
+
bottomContainerStyle && bottomContainerStyle[position],
|
|
287
|
+
]}>
|
|
282
288
|
{this.renderUsername()}
|
|
283
289
|
{this.renderTime()}
|
|
284
290
|
{this.renderTicks()}
|
|
@@ -295,6 +301,7 @@ Bubble.contextTypes = {
|
|
|
295
301
|
};
|
|
296
302
|
Bubble.defaultProps = {
|
|
297
303
|
touchableProps: {},
|
|
304
|
+
onPress: null,
|
|
298
305
|
onLongPress: null,
|
|
299
306
|
renderMessageImage: null,
|
|
300
307
|
renderMessageVideo: null,
|