react-native-gifted-chat 2.8.1 → 2.8.2-alpha.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 +18 -17
- package/package.json +41 -35
- package/src/Bubble/index.tsx +15 -39
- package/src/Bubble/types.ts +5 -5
- package/src/Composer.tsx +19 -26
- package/src/Constant.ts +0 -1
- package/src/GiftedAvatar.tsx +29 -36
- package/src/GiftedChat/index.tsx +34 -65
- package/src/GiftedChat/types.ts +8 -53
- package/src/InputToolbar.tsx +25 -8
- package/src/LoadEarlier.tsx +19 -17
- package/src/MessageAudio.tsx +19 -7
- package/src/MessageContainer/components/DayAnimated/index.tsx +14 -9
- package/src/MessageContainer/components/Item/index.tsx +7 -1
- package/src/MessageContainer/index.tsx +104 -64
- package/src/MessageContainer/styles.ts +3 -2
- package/src/MessageContainer/types.ts +36 -14
- package/src/MessageImage.tsx +18 -6
- package/src/MessageText.tsx +88 -128
- package/src/MessageVideo.tsx +19 -7
- package/src/QuickReplies.tsx +17 -10
- package/src/Send.tsx +7 -1
- package/src/SystemMessage.tsx +12 -2
- package/src/Time.tsx +9 -2
- package/src/TypingIndicator/index.tsx +2 -1
- package/src/TypingIndicator/types.ts +3 -0
- package/src/__tests__/Actions.test.tsx +3 -4
- package/src/__tests__/Avatar.test.tsx +5 -6
- package/src/__tests__/Bubble.test.tsx +14 -19
- package/src/__tests__/Composer.test.tsx +3 -4
- package/src/__tests__/Day.test.tsx +5 -8
- package/src/__tests__/DayAnimated.test.tsx +52 -0
- package/src/__tests__/GiftedAvatar.test.tsx +3 -8
- package/src/__tests__/GiftedChat.test.tsx +37 -21
- package/src/__tests__/InputToolbar.test.tsx +3 -4
- package/src/__tests__/LoadEarlier.test.tsx +3 -4
- package/src/__tests__/Message.test.tsx +51 -58
- package/src/__tests__/MessageContainer.test.tsx +39 -5
- package/src/__tests__/MessageImage.test.tsx +12 -15
- package/src/__tests__/MessageText.test.tsx +7 -4
- package/src/__tests__/Send.test.tsx +7 -8
- package/src/__tests__/SystemMessage.test.tsx +12 -15
- package/src/__tests__/Time.test.tsx +5 -8
- package/src/__tests__/__snapshots__/Bubble.test.tsx.snap +48 -50
- package/src/__tests__/__snapshots__/Composer.test.tsx.snap +1 -2
- package/src/__tests__/__snapshots__/Constant.test.tsx.snap +0 -1
- package/src/__tests__/__snapshots__/DayAnimated.test.tsx.snap +5 -0
- package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +25 -0
- package/src/__tests__/__snapshots__/InputToolbar.test.tsx.snap +2 -2
- package/src/__tests__/__snapshots__/Message.test.tsx.snap +146 -150
- package/src/__tests__/__snapshots__/MessageImage.test.tsx.snap +12 -10
- package/src/__tests__/__snapshots__/MessageText.test.tsx.snap +12 -8
- package/src/__tests__/__snapshots__/Send.test.tsx.snap +2 -0
- package/src/reanimatedCompat.ts +27 -0
- package/src/types.ts +4 -0
- package/src/utils.ts +77 -1
- package/lib/Actions.d.ts +0 -14
- package/lib/Actions.js +0 -57
- package/lib/Actions.js.map +0 -1
- package/lib/Avatar.d.ts +0 -18
- package/lib/Avatar.js +0 -93
- package/lib/Avatar.js.map +0 -1
- package/lib/Bubble/index.d.ts +0 -6
- package/lib/Bubble/index.js +0 -257
- package/lib/Bubble/index.js.map +0 -1
- package/lib/Bubble/styles.d.ts +0 -69
- package/lib/Bubble/styles.js +0 -72
- package/lib/Bubble/styles.js.map +0 -1
- package/lib/Bubble/types.d.ts +0 -47
- package/lib/Bubble/types.js +0 -2
- package/lib/Bubble/types.js.map +0 -1
- package/lib/Color.d.ts +0 -18
- package/lib/Color.js +0 -18
- package/lib/Color.js.map +0 -1
- package/lib/Composer.d.ts +0 -20
- package/lib/Composer.js +0 -60
- package/lib/Composer.js.map +0 -1
- package/lib/Constant.d.ts +0 -10
- package/lib/Constant.js +0 -17
- package/lib/Constant.js.map +0 -1
- package/lib/Day/index.d.ts +0 -4
- package/lib/Day/index.js +0 -39
- package/lib/Day/index.js.map +0 -1
- package/lib/Day/styles.d.ts +0 -20
- package/lib/Day/styles.js +0 -22
- package/lib/Day/styles.js.map +0 -1
- package/lib/Day/types.d.ts +0 -9
- package/lib/Day/types.js +0 -2
- package/lib/Day/types.js.map +0 -1
- package/lib/GiftedAvatar.d.ts +0 -11
- package/lib/GiftedAvatar.js +0 -104
- package/lib/GiftedAvatar.js.map +0 -1
- package/lib/GiftedChat/index.d.ts +0 -26
- package/lib/GiftedChat/index.js +0 -302
- package/lib/GiftedChat/index.js.map +0 -1
- package/lib/GiftedChat/styles.d.ts +0 -6
- package/lib/GiftedChat/styles.js +0 -7
- package/lib/GiftedChat/styles.js.map +0 -1
- package/lib/GiftedChat/types.d.ts +0 -117
- package/lib/GiftedChat/types.js +0 -2
- package/lib/GiftedChat/types.js.map +0 -1
- package/lib/GiftedChatContext.d.ts +0 -9
- package/lib/GiftedChatContext.js +0 -9
- package/lib/GiftedChatContext.js.map +0 -1
- package/lib/InputToolbar.d.ts +0 -23
- package/lib/InputToolbar.js +0 -56
- package/lib/InputToolbar.js.map +0 -1
- package/lib/LoadEarlier.d.ts +0 -14
- package/lib/LoadEarlier.js +0 -45
- package/lib/LoadEarlier.js.map +0 -1
- package/lib/Message/index.d.ts +0 -6
- package/lib/Message/index.js +0 -80
- package/lib/Message/index.js.map +0 -1
- package/lib/Message/styles.d.ts +0 -21
- package/lib/Message/styles.js +0 -22
- package/lib/Message/styles.js.map +0 -1
- package/lib/Message/types.d.ts +0 -22
- package/lib/Message/types.js +0 -2
- package/lib/Message/types.js.map +0 -1
- package/lib/MessageAudio.d.ts +0 -2
- package/lib/MessageAudio.js +0 -14
- package/lib/MessageAudio.js.map +0 -1
- package/lib/MessageContainer/components/DayAnimated/index.d.ts +0 -5
- package/lib/MessageContainer/components/DayAnimated/index.js +0 -85
- package/lib/MessageContainer/components/DayAnimated/index.js.map +0 -1
- package/lib/MessageContainer/components/DayAnimated/styles.d.ts +0 -11
- package/lib/MessageContainer/components/DayAnimated/styles.js +0 -12
- package/lib/MessageContainer/components/DayAnimated/styles.js.map +0 -1
- package/lib/MessageContainer/components/DayAnimated/types.d.ts +0 -17
- package/lib/MessageContainer/components/DayAnimated/types.js +0 -2
- package/lib/MessageContainer/components/DayAnimated/types.js.map +0 -1
- package/lib/MessageContainer/components/Item/index.d.ts +0 -23
- package/lib/MessageContainer/components/Item/index.js +0 -88
- package/lib/MessageContainer/components/Item/index.js.map +0 -1
- package/lib/MessageContainer/components/Item/types.d.ts +0 -17
- package/lib/MessageContainer/components/Item/types.js +0 -2
- package/lib/MessageContainer/components/Item/types.js.map +0 -1
- package/lib/MessageContainer/index.d.ts +0 -6
- package/lib/MessageContainer/index.js +0 -224
- package/lib/MessageContainer/index.js.map +0 -1
- package/lib/MessageContainer/styles.d.ts +0 -34
- package/lib/MessageContainer/styles.js +0 -31
- package/lib/MessageContainer/styles.js.map +0 -1
- package/lib/MessageContainer/types.d.ts +0 -54
- package/lib/MessageContainer/types.js +0 -2
- package/lib/MessageContainer/types.js.map +0 -1
- package/lib/MessageImage.d.ts +0 -13
- package/lib/MessageImage.js +0 -30
- package/lib/MessageImage.js.map +0 -1
- package/lib/MessageText.d.ts +0 -15
- package/lib/MessageText.js +0 -108
- package/lib/MessageText.js.map +0 -1
- package/lib/MessageVideo.d.ts +0 -2
- package/lib/MessageVideo.js +0 -14
- package/lib/MessageVideo.js.map +0 -1
- package/lib/QuickReplies.d.ts +0 -15
- package/lib/QuickReplies.js +0 -101
- package/lib/QuickReplies.js.map +0 -1
- package/lib/Send.d.ts +0 -15
- package/lib/Send.js +0 -34
- package/lib/Send.js.map +0 -1
- package/lib/SystemMessage.d.ts +0 -10
- package/lib/SystemMessage.js +0 -26
- package/lib/SystemMessage.js.map +0 -1
- package/lib/Time.d.ts +0 -11
- package/lib/Time.js +0 -56
- package/lib/Time.js.map +0 -1
- package/lib/TypingIndicator/index.d.ts +0 -5
- package/lib/TypingIndicator/index.js +0 -94
- package/lib/TypingIndicator/index.js.map +0 -1
- package/lib/TypingIndicator/styles.d.ts +0 -20
- package/lib/TypingIndicator/styles.js +0 -22
- package/lib/TypingIndicator/styles.js.map +0 -1
- package/lib/TypingIndicator/types.d.ts +0 -3
- package/lib/TypingIndicator/types.js +0 -2
- package/lib/TypingIndicator/types.js.map +0 -1
- package/lib/hooks/useUpdateLayoutEffect.d.ts +0 -8
- package/lib/hooks/useUpdateLayoutEffect.js +0 -17
- package/lib/hooks/useUpdateLayoutEffect.js.map +0 -1
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -5
- package/lib/index.js.map +0 -1
- package/lib/logging.d.ts +0 -2
- package/lib/logging.js +0 -5
- package/lib/logging.js.map +0 -1
- package/lib/styles.d.ts +0 -10
- package/lib/styles.js +0 -11
- package/lib/styles.js.map +0 -1
- package/lib/types.d.ts +0 -67
- package/lib/types.js +0 -2
- package/lib/types.js.map +0 -1
- package/lib/utils.d.ts +0 -3
- package/lib/utils.js +0 -17
- package/lib/utils.js.map +0 -1
- package/src/__tests__/__snapshots__/MessageContainer.test.tsx.snap +0 -101
package/src/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react'
|
|
1
2
|
import dayjs from 'dayjs'
|
|
2
|
-
|
|
3
3
|
import { IMessage } from './types'
|
|
4
4
|
|
|
5
5
|
export function isSameDay (
|
|
@@ -29,3 +29,79 @@ export function isSameUser (
|
|
|
29
29
|
diffMessage.user._id === currentMessage.user._id
|
|
30
30
|
)
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
function processCallbackArguments (args: unknown[]): unknown[] {
|
|
34
|
+
const [e, ...rest] = args
|
|
35
|
+
const { nativeEvent } = (e as { nativeEvent?: unknown }) || {}
|
|
36
|
+
let params: unknown[] = []
|
|
37
|
+
if (e) {
|
|
38
|
+
if (nativeEvent)
|
|
39
|
+
params.push({ nativeEvent })
|
|
40
|
+
else
|
|
41
|
+
params.push(e)
|
|
42
|
+
if (rest)
|
|
43
|
+
params = params.concat(rest)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return params
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
export function useCallbackDebounced<T extends (...args: any[]) => any>(callbackFunc: T, deps: React.DependencyList = [], time: number): (...args: Parameters<T>) => void {
|
|
51
|
+
const timeoutId = useRef<ReturnType<typeof setTimeout>>(undefined)
|
|
52
|
+
|
|
53
|
+
const savedFunc = useCallback((...args: Parameters<T>) => {
|
|
54
|
+
const params = processCallbackArguments(args)
|
|
55
|
+
if (timeoutId.current)
|
|
56
|
+
clearTimeout(timeoutId.current)
|
|
57
|
+
timeoutId.current = setTimeout(() => {
|
|
58
|
+
callbackFunc(...params as Parameters<T>)
|
|
59
|
+
}, time)
|
|
60
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
+
}, [callbackFunc, time, ...deps])
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
return () => {
|
|
65
|
+
if (timeoutId.current)
|
|
66
|
+
clearTimeout(timeoutId.current)
|
|
67
|
+
}
|
|
68
|
+
}, [])
|
|
69
|
+
|
|
70
|
+
return savedFunc
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
+
export function useCallbackThrottled<T extends (...args: any[]) => any>(callbackFunc: T, deps: React.DependencyList = [], time: number): (...args: Parameters<T>) => void {
|
|
75
|
+
const lastExecution = useRef<number>(0)
|
|
76
|
+
const timeoutId = useRef<ReturnType<typeof setTimeout>>(undefined)
|
|
77
|
+
|
|
78
|
+
// we use function instead of arrow to access arguments object
|
|
79
|
+
const savedFunc = useCallback((...args: Parameters<T>) => {
|
|
80
|
+
const params = processCallbackArguments(args)
|
|
81
|
+
|
|
82
|
+
const now = Date.now()
|
|
83
|
+
const timeSinceLastExecution = now - lastExecution.current
|
|
84
|
+
|
|
85
|
+
if (timeSinceLastExecution >= time) {
|
|
86
|
+
// Execute immediately if enough time has passed
|
|
87
|
+
lastExecution.current = now
|
|
88
|
+
callbackFunc(...params as Parameters<T>)
|
|
89
|
+
} else {
|
|
90
|
+
// Schedule execution for the remaining time
|
|
91
|
+
clearTimeout(timeoutId.current)
|
|
92
|
+
timeoutId.current = setTimeout(() => {
|
|
93
|
+
lastExecution.current = Date.now()
|
|
94
|
+
callbackFunc(...params as Parameters<T>)
|
|
95
|
+
}, time - timeSinceLastExecution)
|
|
96
|
+
}
|
|
97
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
|
+
}, [callbackFunc, time, ...deps])
|
|
99
|
+
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
return () => {
|
|
102
|
+
clearTimeout(timeoutId.current)
|
|
103
|
+
}
|
|
104
|
+
}, [])
|
|
105
|
+
|
|
106
|
+
return savedFunc
|
|
107
|
+
}
|
package/lib/Actions.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
3
|
-
export interface ActionsProps {
|
|
4
|
-
options?: {
|
|
5
|
-
[key: string]: () => void;
|
|
6
|
-
};
|
|
7
|
-
optionTintColor?: string;
|
|
8
|
-
icon?: () => ReactNode;
|
|
9
|
-
wrapperStyle?: StyleProp<ViewStyle>;
|
|
10
|
-
iconTextStyle?: StyleProp<TextStyle>;
|
|
11
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
12
|
-
onPressActionButton?(): void;
|
|
13
|
-
}
|
|
14
|
-
export declare function Actions({ options, optionTintColor, icon, wrapperStyle, iconTextStyle, onPressActionButton, containerStyle, }: ActionsProps): React.JSX.Element;
|
package/lib/Actions.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import { StyleSheet, Text, TouchableOpacity, View, } from 'react-native';
|
|
3
|
-
import Color from './Color';
|
|
4
|
-
import { useChatContext } from './GiftedChatContext';
|
|
5
|
-
import stylesCommon from './styles';
|
|
6
|
-
export function Actions({ options, optionTintColor = Color.optionTintColor, icon, wrapperStyle, iconTextStyle, onPressActionButton, containerStyle, }) {
|
|
7
|
-
const { actionSheet } = useChatContext();
|
|
8
|
-
const onActionsPress = useCallback(() => {
|
|
9
|
-
if (!options)
|
|
10
|
-
return;
|
|
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
|
-
if (buttonIndex === undefined)
|
|
19
|
-
return;
|
|
20
|
-
const key = optionKeys[buttonIndex];
|
|
21
|
-
if (key)
|
|
22
|
-
options[key]();
|
|
23
|
-
});
|
|
24
|
-
}, [actionSheet, options, optionTintColor]);
|
|
25
|
-
const renderIcon = useCallback(() => {
|
|
26
|
-
if (icon)
|
|
27
|
-
return icon();
|
|
28
|
-
return (<View style={[stylesCommon.fill, stylesCommon.centerItems, styles.wrapper, wrapperStyle]}>
|
|
29
|
-
<Text style={[styles.iconText, iconTextStyle]}>{'+'}</Text>
|
|
30
|
-
</View>);
|
|
31
|
-
}, [icon, iconTextStyle, wrapperStyle]);
|
|
32
|
-
return (<TouchableOpacity style={[styles.container, containerStyle]} onPress={onPressActionButton || onActionsPress}>
|
|
33
|
-
{renderIcon()}
|
|
34
|
-
</TouchableOpacity>);
|
|
35
|
-
}
|
|
36
|
-
const styles = StyleSheet.create({
|
|
37
|
-
container: {
|
|
38
|
-
width: 26,
|
|
39
|
-
height: 26,
|
|
40
|
-
marginLeft: 10,
|
|
41
|
-
marginBottom: 10,
|
|
42
|
-
},
|
|
43
|
-
wrapper: {
|
|
44
|
-
borderRadius: 13,
|
|
45
|
-
borderColor: Color.defaultColor,
|
|
46
|
-
borderWidth: 2,
|
|
47
|
-
},
|
|
48
|
-
iconText: {
|
|
49
|
-
color: Color.defaultColor,
|
|
50
|
-
fontWeight: 'bold',
|
|
51
|
-
fontSize: 16,
|
|
52
|
-
lineHeight: 16,
|
|
53
|
-
backgroundColor: Color.backgroundTransparent,
|
|
54
|
-
textAlign: 'center',
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
//# sourceMappingURL=Actions.js.map
|
package/lib/Actions.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Actions.js","sourceRoot":"","sources":["../src/Actions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAa,WAAW,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,EACL,UAAU,EACV,IAAI,EACJ,gBAAgB,EAChB,IAAI,GAIL,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,YAAY,MAAM,UAAU,CAAA;AAYnC,MAAM,UAAU,OAAO,CAAE,EACvB,OAAO,EACP,eAAe,GAAG,KAAK,CAAC,eAAe,EACvC,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,cAAc,GACD;IACb,MAAM,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE,CAAA;IAExC,MAAM,cAAc,GAAG,WAAW,CAAC,GAAG,EAAE;QACtC,IAAI,CAAC,OAAO;YACV,OAAM;QAER,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACvC,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QAEtD,WAAW,EAAE,CAAC,0BAA0B,CACtC;YACE,OAAO,EAAE,UAAU;YACnB,iBAAiB;YACjB,SAAS,EAAE,eAAe;SAC3B,EACD,CAAC,WAA+B,EAAE,EAAE;YAClC,IAAI,WAAW,KAAK,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D,QAAQ,EAAE;QACR,KAAK,EAAE,KAAK,CAAC,YAAY;QACzB,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,eAAe,EAAE,KAAK,CAAC,qBAAqB;QAC5C,SAAS,EAAE,QAAQ;KACpB;CACF,CAAC,CAAA"}
|
package/lib/Avatar.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
-
import { IMessage, LeftRightStyle, User } from './types';
|
|
4
|
-
export interface AvatarProps<TMessage extends IMessage> {
|
|
5
|
-
currentMessage: TMessage;
|
|
6
|
-
previousMessage?: TMessage;
|
|
7
|
-
nextMessage?: TMessage;
|
|
8
|
-
position: 'left' | 'right';
|
|
9
|
-
renderAvatarOnTop?: boolean;
|
|
10
|
-
showAvatarForEveryMessage?: boolean;
|
|
11
|
-
imageStyle?: LeftRightStyle<ImageStyle>;
|
|
12
|
-
containerStyle?: LeftRightStyle<ViewStyle>;
|
|
13
|
-
textStyle?: TextStyle;
|
|
14
|
-
renderAvatar?(props: Omit<AvatarProps<TMessage>, 'renderAvatar'>): ReactNode;
|
|
15
|
-
onPressAvatar?: (user: User) => void;
|
|
16
|
-
onLongPressAvatar?: (user: User) => void;
|
|
17
|
-
}
|
|
18
|
-
export declare function Avatar<TMessage extends IMessage = IMessage>(props: AvatarProps<TMessage>): React.JSX.Element | null;
|
package/lib/Avatar.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import { StyleSheet, View, } from 'react-native';
|
|
3
|
-
import { GiftedAvatar } from './GiftedAvatar';
|
|
4
|
-
import { isSameUser, isSameDay } from './utils';
|
|
5
|
-
const styles = {
|
|
6
|
-
left: StyleSheet.create({
|
|
7
|
-
container: {
|
|
8
|
-
marginRight: 8,
|
|
9
|
-
},
|
|
10
|
-
onTop: {
|
|
11
|
-
alignSelf: 'flex-start',
|
|
12
|
-
},
|
|
13
|
-
image: {
|
|
14
|
-
height: 36,
|
|
15
|
-
width: 36,
|
|
16
|
-
borderRadius: 18,
|
|
17
|
-
},
|
|
18
|
-
}),
|
|
19
|
-
right: StyleSheet.create({
|
|
20
|
-
container: {
|
|
21
|
-
marginLeft: 8,
|
|
22
|
-
},
|
|
23
|
-
onTop: {
|
|
24
|
-
alignSelf: 'flex-start',
|
|
25
|
-
},
|
|
26
|
-
image: {
|
|
27
|
-
height: 36,
|
|
28
|
-
width: 36,
|
|
29
|
-
borderRadius: 18,
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
};
|
|
33
|
-
export function Avatar(props) {
|
|
34
|
-
const { renderAvatarOnTop, showAvatarForEveryMessage, containerStyle, position, currentMessage, renderAvatar, previousMessage, nextMessage, imageStyle, onPressAvatar, onLongPressAvatar, } = props;
|
|
35
|
-
const messageToCompare = renderAvatarOnTop ? previousMessage : nextMessage;
|
|
36
|
-
const renderAvatarComponent = useCallback(() => {
|
|
37
|
-
if (renderAvatar)
|
|
38
|
-
return renderAvatar({
|
|
39
|
-
renderAvatarOnTop,
|
|
40
|
-
showAvatarForEveryMessage,
|
|
41
|
-
containerStyle,
|
|
42
|
-
position,
|
|
43
|
-
currentMessage,
|
|
44
|
-
previousMessage,
|
|
45
|
-
nextMessage,
|
|
46
|
-
imageStyle,
|
|
47
|
-
onPressAvatar,
|
|
48
|
-
onLongPressAvatar,
|
|
49
|
-
});
|
|
50
|
-
if (currentMessage)
|
|
51
|
-
return (<GiftedAvatar avatarStyle={[
|
|
52
|
-
styles[position].image,
|
|
53
|
-
imageStyle?.[position],
|
|
54
|
-
]} user={currentMessage.user} onPress={() => onPressAvatar?.(currentMessage.user)} onLongPress={() => onLongPressAvatar?.(currentMessage.user)}/>);
|
|
55
|
-
return null;
|
|
56
|
-
}, [
|
|
57
|
-
renderAvatar,
|
|
58
|
-
renderAvatarOnTop,
|
|
59
|
-
showAvatarForEveryMessage,
|
|
60
|
-
containerStyle,
|
|
61
|
-
position,
|
|
62
|
-
currentMessage,
|
|
63
|
-
previousMessage,
|
|
64
|
-
nextMessage,
|
|
65
|
-
imageStyle,
|
|
66
|
-
onPressAvatar,
|
|
67
|
-
onLongPressAvatar,
|
|
68
|
-
]);
|
|
69
|
-
if (renderAvatar === null)
|
|
70
|
-
return null;
|
|
71
|
-
if (!showAvatarForEveryMessage &&
|
|
72
|
-
currentMessage &&
|
|
73
|
-
messageToCompare &&
|
|
74
|
-
isSameUser(currentMessage, messageToCompare) &&
|
|
75
|
-
isSameDay(currentMessage, messageToCompare))
|
|
76
|
-
return (<View style={[
|
|
77
|
-
styles[position].container,
|
|
78
|
-
containerStyle?.[position],
|
|
79
|
-
]}>
|
|
80
|
-
<GiftedAvatar avatarStyle={[
|
|
81
|
-
styles[position].image,
|
|
82
|
-
imageStyle?.[position],
|
|
83
|
-
]}/>
|
|
84
|
-
</View>);
|
|
85
|
-
return (<View style={[
|
|
86
|
-
styles[position].container,
|
|
87
|
-
renderAvatarOnTop && styles[position].onTop,
|
|
88
|
-
containerStyle?.[position],
|
|
89
|
-
]}>
|
|
90
|
-
{renderAvatarComponent()}
|
|
91
|
-
</View>);
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=Avatar.js.map
|
package/lib/Avatar.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../src/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAa,WAAW,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,EAEL,UAAU,EAEV,IAAI,GAEL,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAgB/C,MAAM,MAAM,GAAW;IACrB,IAAI,EAAE,UAAU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index.js
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import { Text, TouchableWithoutFeedback, View, } from 'react-native';
|
|
3
|
-
import { useChatContext } from '../GiftedChatContext';
|
|
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
|
-
import { isSameUser, isSameDay } from '../utils';
|
|
11
|
-
import stylesCommon from '../styles';
|
|
12
|
-
import styles from './styles';
|
|
13
|
-
export * from './types';
|
|
14
|
-
const Bubble = (props) => {
|
|
15
|
-
const { currentMessage, nextMessage, position, containerToNextStyle, previousMessage, containerToPreviousStyle, onQuickReply, renderQuickReplySend, quickReplyStyle, quickReplyTextStyle, quickReplyContainerStyle, containerStyle, wrapperStyle, bottomContainerStyle, } = props;
|
|
16
|
-
const context = useChatContext();
|
|
17
|
-
const onPress = useCallback(() => {
|
|
18
|
-
if (props.onPress)
|
|
19
|
-
props.onPress(context, currentMessage);
|
|
20
|
-
}, [context, props, currentMessage]);
|
|
21
|
-
const onLongPress = useCallback(() => {
|
|
22
|
-
const { onLongPress, optionTitles, } = props;
|
|
23
|
-
if (onLongPress) {
|
|
24
|
-
onLongPress(context, currentMessage);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (!optionTitles?.length)
|
|
28
|
-
return;
|
|
29
|
-
const options = optionTitles;
|
|
30
|
-
const cancelButtonIndex = options.length - 1;
|
|
31
|
-
context.actionSheet().showActionSheetWithOptions({
|
|
32
|
-
options,
|
|
33
|
-
cancelButtonIndex,
|
|
34
|
-
}, (buttonIndex) => {
|
|
35
|
-
console.log('onLongPress', { buttonIndex });
|
|
36
|
-
});
|
|
37
|
-
}, [
|
|
38
|
-
currentMessage,
|
|
39
|
-
context,
|
|
40
|
-
props,
|
|
41
|
-
]);
|
|
42
|
-
const styledBubbleToNext = useCallback(() => {
|
|
43
|
-
if (currentMessage &&
|
|
44
|
-
nextMessage &&
|
|
45
|
-
position &&
|
|
46
|
-
isSameUser(currentMessage, nextMessage) &&
|
|
47
|
-
isSameDay(currentMessage, nextMessage))
|
|
48
|
-
return [
|
|
49
|
-
styles[position].containerToNext,
|
|
50
|
-
containerToNextStyle?.[position],
|
|
51
|
-
];
|
|
52
|
-
return null;
|
|
53
|
-
}, [
|
|
54
|
-
currentMessage,
|
|
55
|
-
nextMessage,
|
|
56
|
-
position,
|
|
57
|
-
containerToNextStyle,
|
|
58
|
-
]);
|
|
59
|
-
const styledBubbleToPrevious = useCallback(() => {
|
|
60
|
-
if (currentMessage &&
|
|
61
|
-
previousMessage &&
|
|
62
|
-
position &&
|
|
63
|
-
isSameUser(currentMessage, previousMessage) &&
|
|
64
|
-
isSameDay(currentMessage, previousMessage))
|
|
65
|
-
return [
|
|
66
|
-
styles[position].containerToPrevious,
|
|
67
|
-
containerToPreviousStyle && containerToPreviousStyle[position],
|
|
68
|
-
];
|
|
69
|
-
return null;
|
|
70
|
-
}, [
|
|
71
|
-
currentMessage,
|
|
72
|
-
previousMessage,
|
|
73
|
-
position,
|
|
74
|
-
containerToPreviousStyle,
|
|
75
|
-
]);
|
|
76
|
-
const renderQuickReplies = useCallback(() => {
|
|
77
|
-
if (currentMessage?.quickReplies) {
|
|
78
|
-
const {
|
|
79
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
80
|
-
containerStyle, wrapperStyle,
|
|
81
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
82
|
-
...quickReplyProps } = props;
|
|
83
|
-
if (props.renderQuickReplies)
|
|
84
|
-
return props.renderQuickReplies(quickReplyProps);
|
|
85
|
-
return (<QuickReplies currentMessage={currentMessage} onQuickReply={onQuickReply} renderQuickReplySend={renderQuickReplySend} quickReplyStyle={quickReplyStyle} quickReplyTextStyle={quickReplyTextStyle} quickReplyContainerStyle={quickReplyContainerStyle} nextMessage={nextMessage}/>);
|
|
86
|
-
}
|
|
87
|
-
return null;
|
|
88
|
-
}, [
|
|
89
|
-
currentMessage,
|
|
90
|
-
onQuickReply,
|
|
91
|
-
renderQuickReplySend,
|
|
92
|
-
quickReplyStyle,
|
|
93
|
-
quickReplyTextStyle,
|
|
94
|
-
quickReplyContainerStyle,
|
|
95
|
-
nextMessage,
|
|
96
|
-
props,
|
|
97
|
-
]);
|
|
98
|
-
const renderMessageText = useCallback(() => {
|
|
99
|
-
if (currentMessage?.text) {
|
|
100
|
-
const {
|
|
101
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
102
|
-
containerStyle, wrapperStyle, optionTitles,
|
|
103
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
104
|
-
...messageTextProps } = props;
|
|
105
|
-
if (props.renderMessageText)
|
|
106
|
-
return props.renderMessageText(messageTextProps);
|
|
107
|
-
return <MessageText {...messageTextProps}/>;
|
|
108
|
-
}
|
|
109
|
-
return null;
|
|
110
|
-
}, [props, currentMessage]);
|
|
111
|
-
const renderMessageImage = useCallback(() => {
|
|
112
|
-
if (currentMessage?.image) {
|
|
113
|
-
const {
|
|
114
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
115
|
-
containerStyle, wrapperStyle,
|
|
116
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
117
|
-
...messageImageProps } = props;
|
|
118
|
-
if (props.renderMessageImage)
|
|
119
|
-
return props.renderMessageImage(messageImageProps);
|
|
120
|
-
return <MessageImage {...messageImageProps}/>;
|
|
121
|
-
}
|
|
122
|
-
return null;
|
|
123
|
-
}, [props, currentMessage]);
|
|
124
|
-
const renderMessageVideo = useCallback(() => {
|
|
125
|
-
if (!currentMessage?.video)
|
|
126
|
-
return null;
|
|
127
|
-
const {
|
|
128
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
129
|
-
containerStyle, wrapperStyle,
|
|
130
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
131
|
-
...messageVideoProps } = props;
|
|
132
|
-
if (props.renderMessageVideo)
|
|
133
|
-
return props.renderMessageVideo(messageVideoProps);
|
|
134
|
-
return <MessageVideo />;
|
|
135
|
-
}, [props, currentMessage]);
|
|
136
|
-
const renderMessageAudio = useCallback(() => {
|
|
137
|
-
if (!currentMessage?.audio)
|
|
138
|
-
return null;
|
|
139
|
-
const {
|
|
140
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
141
|
-
containerStyle, wrapperStyle,
|
|
142
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
143
|
-
...messageAudioProps } = props;
|
|
144
|
-
if (props.renderMessageAudio)
|
|
145
|
-
return props.renderMessageAudio(messageAudioProps);
|
|
146
|
-
return <MessageAudio />;
|
|
147
|
-
}, [props, currentMessage]);
|
|
148
|
-
const renderTicks = useCallback(() => {
|
|
149
|
-
const { renderTicks, user, } = props;
|
|
150
|
-
if (renderTicks && currentMessage)
|
|
151
|
-
return renderTicks(currentMessage);
|
|
152
|
-
if (user &&
|
|
153
|
-
currentMessage?.user &&
|
|
154
|
-
currentMessage.user._id !== user._id)
|
|
155
|
-
return null;
|
|
156
|
-
if (currentMessage &&
|
|
157
|
-
(currentMessage.sent || currentMessage.received || currentMessage.pending))
|
|
158
|
-
return (<View style={styles.content.tickView}>
|
|
159
|
-
{!!currentMessage.sent && (<Text style={[styles.content.tick, props.tickStyle]}>
|
|
160
|
-
{'✓'}
|
|
161
|
-
</Text>)}
|
|
162
|
-
{!!currentMessage.received && (<Text style={[styles.content.tick, props.tickStyle]}>
|
|
163
|
-
{'✓'}
|
|
164
|
-
</Text>)}
|
|
165
|
-
{!!currentMessage.pending && (<Text style={[styles.content.tick, props.tickStyle]}>
|
|
166
|
-
{'🕓'}
|
|
167
|
-
</Text>)}
|
|
168
|
-
</View>);
|
|
169
|
-
return null;
|
|
170
|
-
}, [
|
|
171
|
-
props,
|
|
172
|
-
currentMessage,
|
|
173
|
-
]);
|
|
174
|
-
const renderTime = useCallback(() => {
|
|
175
|
-
if (currentMessage?.createdAt) {
|
|
176
|
-
const {
|
|
177
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
178
|
-
containerStyle, wrapperStyle, textStyle,
|
|
179
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
180
|
-
...timeProps } = props;
|
|
181
|
-
if (props.renderTime)
|
|
182
|
-
return props.renderTime(timeProps);
|
|
183
|
-
return <Time {...timeProps}/>;
|
|
184
|
-
}
|
|
185
|
-
return null;
|
|
186
|
-
}, [props, currentMessage]);
|
|
187
|
-
const renderUsername = useCallback(() => {
|
|
188
|
-
const { user, renderUsername, } = props;
|
|
189
|
-
if (props.renderUsernameOnMessage && currentMessage) {
|
|
190
|
-
if (user && currentMessage.user._id === user._id)
|
|
191
|
-
return null;
|
|
192
|
-
if (renderUsername)
|
|
193
|
-
return renderUsername(currentMessage.user);
|
|
194
|
-
return (<View style={styles.content.usernameView}>
|
|
195
|
-
<Text style={[styles.content.username, props.usernameStyle]}>
|
|
196
|
-
{'~ '}
|
|
197
|
-
{currentMessage.user.name}
|
|
198
|
-
</Text>
|
|
199
|
-
</View>);
|
|
200
|
-
}
|
|
201
|
-
return null;
|
|
202
|
-
}, [
|
|
203
|
-
currentMessage,
|
|
204
|
-
props,
|
|
205
|
-
]);
|
|
206
|
-
const renderCustomView = useCallback(() => {
|
|
207
|
-
if (props.renderCustomView)
|
|
208
|
-
return props.renderCustomView(props);
|
|
209
|
-
return null;
|
|
210
|
-
}, [props]);
|
|
211
|
-
const renderBubbleContent = useCallback(() => {
|
|
212
|
-
return (<View>
|
|
213
|
-
{!props.isCustomViewBottom && renderCustomView()}
|
|
214
|
-
{renderMessageImage()}
|
|
215
|
-
{renderMessageVideo()}
|
|
216
|
-
{renderMessageAudio()}
|
|
217
|
-
{renderMessageText()}
|
|
218
|
-
{props.isCustomViewBottom && renderCustomView()}
|
|
219
|
-
</View>);
|
|
220
|
-
}, [
|
|
221
|
-
renderCustomView,
|
|
222
|
-
renderMessageImage,
|
|
223
|
-
renderMessageVideo,
|
|
224
|
-
renderMessageAudio,
|
|
225
|
-
renderMessageText,
|
|
226
|
-
props.isCustomViewBottom,
|
|
227
|
-
]);
|
|
228
|
-
return (<View style={[
|
|
229
|
-
stylesCommon.fill,
|
|
230
|
-
styles[position].container,
|
|
231
|
-
containerStyle && containerStyle[position],
|
|
232
|
-
]}>
|
|
233
|
-
<View style={[
|
|
234
|
-
styles[position].wrapper,
|
|
235
|
-
styledBubbleToNext(),
|
|
236
|
-
styledBubbleToPrevious(),
|
|
237
|
-
wrapperStyle && wrapperStyle[position],
|
|
238
|
-
]}>
|
|
239
|
-
<TouchableWithoutFeedback onPress={onPress} onLongPress={onLongPress} accessibilityRole='text' {...props.touchableProps}>
|
|
240
|
-
<View>
|
|
241
|
-
{renderBubbleContent()}
|
|
242
|
-
<View style={[
|
|
243
|
-
styles[position].bottom,
|
|
244
|
-
bottomContainerStyle && bottomContainerStyle[position],
|
|
245
|
-
]}>
|
|
246
|
-
{renderUsername()}
|
|
247
|
-
{renderTime()}
|
|
248
|
-
{renderTicks()}
|
|
249
|
-
</View>
|
|
250
|
-
</View>
|
|
251
|
-
</TouchableWithoutFeedback>
|
|
252
|
-
</View>
|
|
253
|
-
{renderQuickReplies()}
|
|
254
|
-
</View>);
|
|
255
|
-
};
|
|
256
|
-
export default Bubble;
|
|
257
|
-
//# sourceMappingURL=index.js.map
|
package/lib/Bubble/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Bubble/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EACL,IAAI,EACJ,wBAAwB,EACxB,IAAI,GACL,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,cAAc,EAAE,MA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B,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,IAAI,oBAAoB,CAAC,QAAQ,CAAC;SACvD,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/styles.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
declare const styles: {
|
|
2
|
-
left: {
|
|
3
|
-
container: {
|
|
4
|
-
alignItems: "flex-start";
|
|
5
|
-
};
|
|
6
|
-
wrapper: {
|
|
7
|
-
borderRadius: number;
|
|
8
|
-
backgroundColor: string;
|
|
9
|
-
marginRight: number;
|
|
10
|
-
minHeight: number;
|
|
11
|
-
justifyContent: "flex-end";
|
|
12
|
-
};
|
|
13
|
-
containerToNext: {
|
|
14
|
-
borderBottomLeftRadius: number;
|
|
15
|
-
};
|
|
16
|
-
containerToPrevious: {
|
|
17
|
-
borderTopLeftRadius: number;
|
|
18
|
-
};
|
|
19
|
-
bottom: {
|
|
20
|
-
flexDirection: "row";
|
|
21
|
-
justifyContent: "flex-start";
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
right: {
|
|
25
|
-
container: {
|
|
26
|
-
alignItems: "flex-end";
|
|
27
|
-
};
|
|
28
|
-
wrapper: {
|
|
29
|
-
borderRadius: number;
|
|
30
|
-
backgroundColor: string;
|
|
31
|
-
marginLeft: number;
|
|
32
|
-
minHeight: number;
|
|
33
|
-
justifyContent: "flex-end";
|
|
34
|
-
};
|
|
35
|
-
containerToNext: {
|
|
36
|
-
borderBottomRightRadius: number;
|
|
37
|
-
};
|
|
38
|
-
containerToPrevious: {
|
|
39
|
-
borderTopRightRadius: number;
|
|
40
|
-
};
|
|
41
|
-
bottom: {
|
|
42
|
-
flexDirection: "row";
|
|
43
|
-
justifyContent: "flex-end";
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
content: {
|
|
47
|
-
tick: {
|
|
48
|
-
fontSize: number;
|
|
49
|
-
backgroundColor: string;
|
|
50
|
-
color: string;
|
|
51
|
-
};
|
|
52
|
-
tickView: {
|
|
53
|
-
flexDirection: "row";
|
|
54
|
-
marginRight: number;
|
|
55
|
-
};
|
|
56
|
-
username: {
|
|
57
|
-
top: number;
|
|
58
|
-
left: number;
|
|
59
|
-
fontSize: number;
|
|
60
|
-
backgroundColor: string;
|
|
61
|
-
color: string;
|
|
62
|
-
};
|
|
63
|
-
usernameView: {
|
|
64
|
-
flexDirection: "row";
|
|
65
|
-
marginHorizontal: number;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
export default styles;
|