react-native-gifted-chat 3.3.0 → 3.3.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/CHANGELOG.md +435 -0
- package/README.md +68 -12
- package/lib/Actions.d.ts +16 -0
- package/lib/Actions.d.ts.map +1 -0
- package/lib/Actions.js +65 -0
- package/lib/Actions.js.map +1 -0
- package/lib/Avatar.d.ts +19 -0
- package/lib/Avatar.d.ts.map +1 -0
- package/lib/Avatar.js +93 -0
- package/lib/Avatar.js.map +1 -0
- package/lib/Bubble/index.d.ts +6 -0
- package/lib/Bubble/index.d.ts.map +1 -0
- package/lib/Bubble/index.js +269 -0
- package/lib/Bubble/index.js.map +1 -0
- package/lib/Bubble/styles.d.ts +57 -0
- package/lib/Bubble/styles.d.ts.map +1 -0
- package/lib/Bubble/styles.js +59 -0
- package/lib/Bubble/styles.js.map +1 -0
- package/lib/Bubble/types.d.ts +59 -0
- package/lib/Bubble/types.d.ts.map +1 -0
- package/lib/Bubble/types.js +2 -0
- package/lib/Bubble/types.js.map +1 -0
- package/lib/Color.d.ts +18 -0
- package/lib/Color.d.ts.map +1 -0
- package/lib/Color.js +18 -0
- package/lib/Color.js.map +1 -0
- package/lib/Composer.d.ts +9 -0
- package/lib/Composer.d.ts.map +1 -0
- package/lib/Composer.js +56 -0
- package/lib/Composer.js.map +1 -0
- package/lib/Constant.d.ts +8 -0
- package/lib/Constant.d.ts.map +1 -0
- package/lib/Constant.js +8 -0
- package/lib/Constant.js.map +1 -0
- package/lib/Day/index.d.ts +5 -0
- package/lib/Day/index.d.ts.map +1 -0
- package/lib/Day/index.js +40 -0
- package/lib/Day/index.js.map +1 -0
- package/lib/Day/styles.d.ts +21 -0
- package/lib/Day/styles.d.ts.map +1 -0
- package/lib/Day/styles.js +22 -0
- package/lib/Day/styles.js.map +1 -0
- package/lib/Day/types.d.ts +11 -0
- package/lib/Day/types.d.ts.map +1 -0
- package/lib/Day/types.js +2 -0
- package/lib/Day/types.js.map +1 -0
- package/lib/GiftedAvatar.d.ts +12 -0
- package/lib/GiftedAvatar.d.ts.map +1 -0
- package/lib/GiftedAvatar.js +101 -0
- package/lib/GiftedAvatar.js.map +1 -0
- package/lib/GiftedChat/index.d.ts +10 -0
- package/lib/GiftedChat/index.d.ts.map +1 -0
- package/lib/GiftedChat/index.js +241 -0
- package/lib/GiftedChat/index.js.map +1 -0
- package/lib/GiftedChat/styles.d.ts +13 -0
- package/lib/GiftedChat/styles.d.ts.map +1 -0
- package/lib/GiftedChat/styles.js +13 -0
- package/lib/GiftedChat/styles.js.map +1 -0
- package/lib/GiftedChat/types.d.ts +90 -0
- package/lib/GiftedChat/types.d.ts.map +1 -0
- package/lib/GiftedChat/types.js +2 -0
- package/lib/GiftedChat/types.js.map +1 -0
- package/lib/GiftedChatContext.d.ts +11 -0
- package/lib/GiftedChatContext.d.ts.map +1 -0
- package/lib/GiftedChatContext.js +10 -0
- package/lib/GiftedChatContext.js.map +1 -0
- package/lib/InputToolbar.d.ts +36 -0
- package/lib/InputToolbar.d.ts.map +1 -0
- package/lib/InputToolbar.js +108 -0
- package/lib/InputToolbar.js.map +1 -0
- package/lib/LoadEarlierMessages.d.ts +17 -0
- package/lib/LoadEarlierMessages.d.ts.map +1 -0
- package/lib/LoadEarlierMessages.js +45 -0
- package/lib/LoadEarlierMessages.js.map +1 -0
- package/lib/Message/index.d.ts +6 -0
- package/lib/Message/index.d.ts.map +1 -0
- package/lib/Message/index.js +180 -0
- package/lib/Message/index.js.map +1 -0
- package/lib/Message/styles.d.ts +18 -0
- package/lib/Message/styles.d.ts.map +1 -0
- package/lib/Message/styles.js +18 -0
- package/lib/Message/styles.js.map +1 -0
- package/lib/Message/types.d.ts +25 -0
- package/lib/Message/types.d.ts.map +1 -0
- package/lib/Message/types.js +2 -0
- package/lib/Message/types.js.map +1 -0
- package/lib/MessageAudio.d.ts +3 -0
- package/lib/MessageAudio.d.ts.map +1 -0
- package/lib/MessageAudio.js +25 -0
- package/lib/MessageAudio.js.map +1 -0
- package/lib/MessageImage.d.ts +12 -0
- package/lib/MessageImage.d.ts.map +1 -0
- package/lib/MessageImage.js +164 -0
- package/lib/MessageImage.js.map +1 -0
- package/lib/MessageReply.d.ts +15 -0
- package/lib/MessageReply.d.ts.map +1 -0
- package/lib/MessageReply.js +103 -0
- package/lib/MessageReply.js.map +1 -0
- package/lib/MessageText.d.ts +24 -0
- package/lib/MessageText.d.ts.map +1 -0
- package/lib/MessageText.js +41 -0
- package/lib/MessageText.js.map +1 -0
- package/lib/MessageVideo.d.ts +3 -0
- package/lib/MessageVideo.d.ts.map +1 -0
- package/lib/MessageVideo.js +25 -0
- package/lib/MessageVideo.js.map +1 -0
- package/lib/MessagesContainer/components/DayAnimated/index.d.ts +5 -0
- package/lib/MessagesContainer/components/DayAnimated/index.d.ts.map +1 -0
- package/lib/MessagesContainer/components/DayAnimated/index.js +92 -0
- package/lib/MessagesContainer/components/DayAnimated/index.js.map +1 -0
- package/lib/MessagesContainer/components/DayAnimated/styles.d.ts +12 -0
- package/lib/MessagesContainer/components/DayAnimated/styles.d.ts.map +1 -0
- package/lib/MessagesContainer/components/DayAnimated/styles.js +12 -0
- package/lib/MessagesContainer/components/DayAnimated/styles.js.map +1 -0
- package/lib/MessagesContainer/components/DayAnimated/types.d.ts +18 -0
- package/lib/MessagesContainer/components/DayAnimated/types.d.ts.map +1 -0
- package/lib/MessagesContainer/components/DayAnimated/types.js +2 -0
- package/lib/MessagesContainer/components/DayAnimated/types.js.map +1 -0
- package/lib/MessagesContainer/components/Item/index.d.ts +23 -0
- package/lib/MessagesContainer/components/Item/index.d.ts.map +1 -0
- package/lib/MessagesContainer/components/Item/index.js +120 -0
- package/lib/MessagesContainer/components/Item/index.js.map +1 -0
- package/lib/MessagesContainer/components/Item/types.d.ts +19 -0
- package/lib/MessagesContainer/components/Item/types.d.ts.map +1 -0
- package/lib/MessagesContainer/components/Item/types.js +2 -0
- package/lib/MessagesContainer/components/Item/types.js.map +1 -0
- package/lib/MessagesContainer/index.d.ts +6 -0
- package/lib/MessagesContainer/index.d.ts.map +1 -0
- package/lib/MessagesContainer/index.js +258 -0
- package/lib/MessagesContainer/index.js.map +1 -0
- package/lib/MessagesContainer/styles.d.ts +55 -0
- package/lib/MessagesContainer/styles.d.ts.map +1 -0
- package/lib/MessagesContainer/styles.js +42 -0
- package/lib/MessagesContainer/styles.js.map +1 -0
- package/lib/MessagesContainer/types.d.ts +88 -0
- package/lib/MessagesContainer/types.d.ts.map +1 -0
- package/lib/MessagesContainer/types.js +10 -0
- package/lib/MessagesContainer/types.js.map +1 -0
- package/lib/Models.d.ts +58 -0
- package/lib/Models.d.ts.map +1 -0
- package/lib/Models.js +2 -0
- package/lib/Models.js.map +1 -0
- package/lib/QuickReplies.d.ts +16 -0
- package/lib/QuickReplies.d.ts.map +1 -0
- package/lib/QuickReplies.js +108 -0
- package/lib/QuickReplies.js.map +1 -0
- package/lib/Reply/index.d.ts +2 -0
- package/lib/Reply/index.d.ts.map +1 -0
- package/lib/Reply/index.js +2 -0
- package/lib/Reply/index.js.map +1 -0
- package/lib/Reply/types.d.ts +72 -0
- package/lib/Reply/types.d.ts.map +1 -0
- package/lib/Reply/types.js +2 -0
- package/lib/Reply/types.js.map +1 -0
- package/lib/ReplyPreview.d.ts +14 -0
- package/lib/ReplyPreview.d.ts.map +1 -0
- package/lib/ReplyPreview.js +95 -0
- package/lib/ReplyPreview.js.map +1 -0
- package/lib/Send.d.ts +19 -0
- package/lib/Send.d.ts.map +1 -0
- package/lib/Send.js +57 -0
- package/lib/Send.js.map +1 -0
- package/lib/SystemMessage.d.ts +14 -0
- package/lib/SystemMessage.d.ts.map +1 -0
- package/lib/SystemMessage.js +42 -0
- package/lib/SystemMessage.js.map +1 -0
- package/lib/Time.d.ts +12 -0
- package/lib/Time.d.ts.map +1 -0
- package/lib/Time.js +39 -0
- package/lib/Time.js.map +1 -0
- package/lib/TypingIndicator/index.d.ts +5 -0
- package/lib/TypingIndicator/index.d.ts.map +1 -0
- package/lib/TypingIndicator/index.js +94 -0
- package/lib/TypingIndicator/index.js.map +1 -0
- package/lib/TypingIndicator/styles.d.ts +21 -0
- package/lib/TypingIndicator/styles.d.ts.map +1 -0
- package/lib/TypingIndicator/styles.js +22 -0
- package/lib/TypingIndicator/styles.js.map +1 -0
- package/lib/TypingIndicator/types.d.ts +6 -0
- package/lib/TypingIndicator/types.d.ts.map +1 -0
- package/lib/TypingIndicator/types.js +2 -0
- package/lib/TypingIndicator/types.js.map +1 -0
- package/lib/components/MessageReply.d.ts +29 -0
- package/lib/components/MessageReply.d.ts.map +1 -0
- package/lib/components/MessageReply.js +87 -0
- package/lib/components/MessageReply.js.map +1 -0
- package/lib/components/ReplyPreview.d.ts +17 -0
- package/lib/components/ReplyPreview.d.ts.map +1 -0
- package/lib/components/ReplyPreview.js +148 -0
- package/lib/components/ReplyPreview.js.map +1 -0
- package/lib/components/TouchableOpacity.d.ts +9 -0
- package/lib/components/TouchableOpacity.d.ts.map +1 -0
- package/lib/components/TouchableOpacity.js +37 -0
- package/lib/components/TouchableOpacity.js.map +1 -0
- package/lib/hooks/useColorScheme.d.ts +8 -0
- package/lib/hooks/useColorScheme.d.ts.map +1 -0
- package/lib/hooks/useColorScheme.js +17 -0
- package/lib/hooks/useColorScheme.js.map +1 -0
- package/lib/hooks/useUpdateLayoutEffect.d.ts +9 -0
- package/lib/hooks/useUpdateLayoutEffect.d.ts.map +1 -0
- package/lib/hooks/useUpdateLayoutEffect.js +17 -0
- package/lib/hooks/useUpdateLayoutEffect.js.map +1 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +31 -0
- package/lib/index.js.map +1 -0
- package/lib/linkParser.d.ts +39 -0
- package/lib/linkParser.d.ts.map +1 -0
- package/lib/linkParser.js +154 -0
- package/lib/linkParser.js.map +1 -0
- package/lib/logging.d.ts +3 -0
- package/lib/logging.d.ts.map +1 -0
- package/lib/logging.js +5 -0
- package/lib/logging.js.map +1 -0
- package/lib/styles.d.ts +14 -0
- package/lib/styles.d.ts.map +1 -0
- package/lib/styles.js +23 -0
- package/lib/styles.js.map +1 -0
- package/lib/types.d.ts +19 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts +8 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +105 -0
- package/lib/utils.js.map +1 -0
- package/package.json +12 -11
- package/src/Actions.tsx +0 -110
- package/src/Avatar.tsx +0 -169
- package/src/Bubble/index.tsx +0 -407
- package/src/Bubble/styles.ts +0 -66
- package/src/Bubble/types.ts +0 -104
- package/src/Color.ts +0 -17
- package/src/Composer.tsx +0 -100
- package/src/Constant.ts +0 -8
- package/src/Day/index.tsx +0 -63
- package/src/Day/styles.ts +0 -22
- package/src/Day/types.ts +0 -15
- package/src/GiftedAvatar.tsx +0 -187
- package/src/GiftedChat/index.tsx +0 -420
- package/src/GiftedChat/styles.ts +0 -10
- package/src/GiftedChat/types.ts +0 -156
- package/src/GiftedChatContext.ts +0 -25
- package/src/InputToolbar.tsx +0 -177
- package/src/LoadEarlierMessages.tsx +0 -94
- package/src/Message/index.tsx +0 -273
- package/src/Message/styles.ts +0 -18
- package/src/Message/types.ts +0 -26
- package/src/MessageAudio.tsx +0 -29
- package/src/MessageImage.tsx +0 -251
- package/src/MessageReply.tsx +0 -160
- package/src/MessageText.tsx +0 -111
- package/src/MessageVideo.tsx +0 -29
- package/src/MessagesContainer/components/DayAnimated/index.tsx +0 -151
- package/src/MessagesContainer/components/DayAnimated/styles.ts +0 -12
- package/src/MessagesContainer/components/DayAnimated/types.ts +0 -12
- package/src/MessagesContainer/components/Item/index.tsx +0 -197
- package/src/MessagesContainer/components/Item/types.ts +0 -13
- package/src/MessagesContainer/index.tsx +0 -434
- package/src/MessagesContainer/styles.ts +0 -42
- package/src/MessagesContainer/types.ts +0 -102
- package/src/Models.ts +0 -66
- package/src/QuickReplies.tsx +0 -181
- package/src/Reply/index.ts +0 -1
- package/src/Reply/types.ts +0 -80
- package/src/ReplyPreview.tsx +0 -132
- package/src/Send.tsx +0 -115
- package/src/SystemMessage.tsx +0 -79
- package/src/Time.tsx +0 -64
- package/src/TypingIndicator/index.tsx +0 -155
- package/src/TypingIndicator/styles.ts +0 -22
- package/src/TypingIndicator/types.ts +0 -6
- package/src/__tests__/Actions.test.tsx +0 -9
- package/src/__tests__/Avatar.test.tsx +0 -17
- package/src/__tests__/Bubble.test.tsx +0 -17
- package/src/__tests__/Color.test.tsx +0 -5
- package/src/__tests__/Composer.test.tsx +0 -10
- package/src/__tests__/Constant.test.tsx +0 -5
- package/src/__tests__/Day.test.tsx +0 -20
- package/src/__tests__/DayAnimated.test.tsx +0 -46
- package/src/__tests__/GiftedAvatar.test.tsx +0 -10
- package/src/__tests__/GiftedChat.test.tsx +0 -60
- package/src/__tests__/InputToolbar.test.tsx +0 -10
- package/src/__tests__/LoadEarlier.test.tsx +0 -10
- package/src/__tests__/Message.test.tsx +0 -67
- package/src/__tests__/MessageImage.test.tsx +0 -24
- package/src/__tests__/MessageReply.test.tsx +0 -54
- package/src/__tests__/MessageText.test.tsx +0 -15
- package/src/__tests__/MessagesContainer.test.tsx +0 -38
- package/src/__tests__/ReplyPreview.test.tsx +0 -41
- package/src/__tests__/Send.test.tsx +0 -21
- package/src/__tests__/SystemMessage.test.tsx +0 -24
- package/src/__tests__/Time.test.tsx +0 -26
- package/src/__tests__/__snapshots__/Actions.test.tsx.snap +0 -40
- package/src/__tests__/__snapshots__/Avatar.test.tsx.snap +0 -17
- package/src/__tests__/__snapshots__/Bubble.test.tsx.snap +0 -121
- package/src/__tests__/__snapshots__/Color.test.tsx.snap +0 -21
- package/src/__tests__/__snapshots__/Composer.test.tsx.snap +0 -51
- package/src/__tests__/__snapshots__/Constant.test.tsx.snap +0 -13
- package/src/__tests__/__snapshots__/Day.test.tsx.snap +0 -99
- package/src/__tests__/__snapshots__/DayAnimated.test.tsx.snap +0 -5
- package/src/__tests__/__snapshots__/GiftedAvatar.test.tsx.snap +0 -24
- package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +0 -169
- package/src/__tests__/__snapshots__/InputToolbar.test.tsx.snap +0 -145
- package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +0 -33
- package/src/__tests__/__snapshots__/Message.test.tsx.snap +0 -510
- package/src/__tests__/__snapshots__/MessageImage.test.tsx.snap +0 -293
- package/src/__tests__/__snapshots__/MessageReply.test.tsx.snap +0 -181
- package/src/__tests__/__snapshots__/MessageText.test.tsx.snap +0 -29
- package/src/__tests__/__snapshots__/ReplyPreview.test.tsx.snap +0 -403
- package/src/__tests__/__snapshots__/Send.test.tsx.snap +0 -214
- package/src/__tests__/__snapshots__/SystemMessage.test.tsx.snap +0 -77
- package/src/__tests__/__snapshots__/Time.test.tsx.snap +0 -22
- package/src/__tests__/data.ts +0 -8
- package/src/__tests__/utils.test.ts +0 -31
- package/src/components/MessageReply.tsx +0 -156
- package/src/components/ReplyPreview.tsx +0 -230
- package/src/components/TouchableOpacity.tsx +0 -67
- package/src/hooks/useColorScheme.ts +0 -18
- package/src/hooks/useUpdateLayoutEffect.ts +0 -21
- package/src/index.ts +0 -29
- package/src/linkParser.tsx +0 -255
- package/src/logging.ts +0 -8
- package/src/styles.ts +0 -25
- package/src/types.ts +0 -25
- package/src/utils.ts +0 -134
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAwB,MAAM,cAAc,CAAA;AAE1E,eAAe,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,IAAI,EAAE,CAAC;KACR;IACD,WAAW,EAAE;QACX,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;KACrB;CACF,CAAC,CAAA;AAEF,MAAM,UAAU,mBAAmB,CAAI,MAAS,EAAE,QAAgB,EAAE,WAA2B;IAC7F,MAAM,GAAG,GAAG,GAAG,QAAQ,IAAI,WAAW,EAAa,CAAA;IACnD,OAAO,CAAC,MAAM,CAAC,QAAmB,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAI,MAAS,EAAE,QAAgB,EAAE,QAAkC;IACrG,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,QAAmB,CAAC,CAAC,CAAA;IACjD,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,GAAG,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAa,CAAA;QAChD,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IAC/B,CAAC;IACD,OAAO,UAAU,CAAC,OAAO,CAAC,WAAW,CAAgD,CAAA;AACvF,CAAC"}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from './Models';
|
|
2
|
+
export type { ActionsProps } from './Actions';
|
|
3
|
+
export type { AvatarProps } from './Avatar';
|
|
4
|
+
export type { BubbleProps, RenderMessageImageProps, RenderMessageVideoProps, RenderMessageAudioProps, RenderMessageTextProps } from './Bubble';
|
|
5
|
+
export type { ComposerProps } from './Composer';
|
|
6
|
+
export type { DayProps } from './Day';
|
|
7
|
+
export type { GiftedAvatarProps } from './GiftedAvatar';
|
|
8
|
+
export type { InputToolbarProps, ReplyPreviewProps } from './InputToolbar';
|
|
9
|
+
export type { LoadEarlierMessagesProps } from './LoadEarlierMessages';
|
|
10
|
+
export type { MessageProps } from './Message';
|
|
11
|
+
export type { MessagesContainerProps } from './MessagesContainer';
|
|
12
|
+
export type { MessageImageProps } from './MessageImage';
|
|
13
|
+
export type { MessageTextProps } from './MessageText';
|
|
14
|
+
export type { MessageReplyProps } from './components/MessageReply';
|
|
15
|
+
export type { QuickRepliesProps } from './QuickReplies';
|
|
16
|
+
export type { SendProps } from './Send';
|
|
17
|
+
export type { SystemMessageProps } from './SystemMessage';
|
|
18
|
+
export type { TimeProps } from './Time';
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AAExB,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3C,YAAY,EACV,WAAW,EACX,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,UAAU,CAAA;AACjB,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACrC,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAC1E,YAAY,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AACrE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AACjE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAClE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACvC,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzD,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA"}
|
package/lib/types.js
ADDED
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IMessage } from './Models';
|
|
3
|
+
export declare function renderComponentOrElement<TProps extends Record<string, any>>(component: React.ComponentType<TProps> | React.ReactElement | ((props: TProps) => React.ReactNode) | null | undefined, props: TProps): React.ReactNode;
|
|
4
|
+
export declare function isSameDay(currentMessage: IMessage, diffMessage: IMessage | null | undefined): boolean;
|
|
5
|
+
export declare function isSameUser(currentMessage: IMessage, diffMessage: IMessage | null | undefined): boolean;
|
|
6
|
+
export declare function useCallbackDebounced<T extends (...args: any[]) => any>(callbackFunc: T, deps: React.DependencyList | undefined, time: number): (...args: Parameters<T>) => void;
|
|
7
|
+
export declare function useCallbackThrottled<T extends (...args: any[]) => any>(callbackFunc: T, deps: React.DependencyList | undefined, time: number): (...args: Parameters<T>) => void;
|
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAA;AAE7D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,wBAAgB,wBAAwB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzE,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,GAAG,SAAS,EACrH,KAAK,EAAE,MAAM,GACZ,KAAK,CAAC,SAAS,CA6BjB;AAED,wBAAgB,SAAS,CACvB,cAAc,EAAE,QAAQ,EACxB,WAAW,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,WAYzC;AAED,wBAAgB,UAAU,CACxB,cAAc,EAAE,QAAQ,EACxB,WAAW,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,WAQzC;AAkBD,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,cAAc,YAAK,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAqBxK;AAED,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,cAAc,YAAK,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAiCxK"}
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
export function renderComponentOrElement(component, props) {
|
|
4
|
+
if (!component)
|
|
5
|
+
return null;
|
|
6
|
+
if (React.isValidElement(component))
|
|
7
|
+
// If it's already a React element, clone it with props
|
|
8
|
+
return React.cloneElement(component, props);
|
|
9
|
+
if (typeof component === 'function') {
|
|
10
|
+
// Check if it's a class component (has prototype.isReactComponent)
|
|
11
|
+
// Class components must use React.createElement
|
|
12
|
+
const isClassComponent = component.prototype && component.prototype.isReactComponent;
|
|
13
|
+
if (isClassComponent)
|
|
14
|
+
return React.createElement(component, props);
|
|
15
|
+
// For function components and render functions, call directly
|
|
16
|
+
// Using createElement with inline arrow functions causes unmount/remount
|
|
17
|
+
// when function reference changes, this matches v2.x behavior
|
|
18
|
+
return component(props);
|
|
19
|
+
}
|
|
20
|
+
// Check for React.memo or React.forwardRef wrapped components
|
|
21
|
+
// These have $$typeof property and should be rendered with createElement
|
|
22
|
+
if (typeof component === 'object' && component !== null && '$$typeof' in component)
|
|
23
|
+
return React.createElement(component, props);
|
|
24
|
+
// If it's neither, return it as-is
|
|
25
|
+
return component;
|
|
26
|
+
}
|
|
27
|
+
export function isSameDay(currentMessage, diffMessage) {
|
|
28
|
+
if (!diffMessage || !diffMessage.createdAt)
|
|
29
|
+
return false;
|
|
30
|
+
const currentCreatedAt = dayjs(currentMessage.createdAt);
|
|
31
|
+
const diffCreatedAt = dayjs(diffMessage.createdAt);
|
|
32
|
+
if (!currentCreatedAt.isValid() || !diffCreatedAt.isValid())
|
|
33
|
+
return false;
|
|
34
|
+
return currentCreatedAt.isSame(diffCreatedAt, 'day');
|
|
35
|
+
}
|
|
36
|
+
export function isSameUser(currentMessage, diffMessage) {
|
|
37
|
+
return !!(diffMessage &&
|
|
38
|
+
diffMessage.user &&
|
|
39
|
+
currentMessage.user &&
|
|
40
|
+
diffMessage.user._id === currentMessage.user._id);
|
|
41
|
+
}
|
|
42
|
+
function processCallbackArguments(args) {
|
|
43
|
+
const [e, ...rest] = args;
|
|
44
|
+
const { nativeEvent } = e || {};
|
|
45
|
+
let params = [];
|
|
46
|
+
if (e) {
|
|
47
|
+
if (nativeEvent)
|
|
48
|
+
params.push({ nativeEvent });
|
|
49
|
+
else
|
|
50
|
+
params.push(e);
|
|
51
|
+
if (rest)
|
|
52
|
+
params = params.concat(rest);
|
|
53
|
+
}
|
|
54
|
+
return params;
|
|
55
|
+
}
|
|
56
|
+
export function useCallbackDebounced(callbackFunc, deps = [], time) {
|
|
57
|
+
const timeoutId = useRef(undefined);
|
|
58
|
+
const savedFunc = useCallback((...args) => {
|
|
59
|
+
const params = processCallbackArguments(args);
|
|
60
|
+
if (timeoutId.current)
|
|
61
|
+
clearTimeout(timeoutId.current);
|
|
62
|
+
timeoutId.current = setTimeout(() => {
|
|
63
|
+
callbackFunc(...params);
|
|
64
|
+
}, time);
|
|
65
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
|
+
}, [callbackFunc, time, ...deps]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
return () => {
|
|
69
|
+
if (timeoutId.current)
|
|
70
|
+
clearTimeout(timeoutId.current);
|
|
71
|
+
};
|
|
72
|
+
}, []);
|
|
73
|
+
return savedFunc;
|
|
74
|
+
}
|
|
75
|
+
export function useCallbackThrottled(callbackFunc, deps = [], time) {
|
|
76
|
+
const lastExecution = useRef(0);
|
|
77
|
+
const timeoutId = useRef(undefined);
|
|
78
|
+
// we use function instead of arrow to access arguments object
|
|
79
|
+
const savedFunc = useCallback((...args) => {
|
|
80
|
+
const params = processCallbackArguments(args);
|
|
81
|
+
const now = Date.now();
|
|
82
|
+
const timeSinceLastExecution = now - lastExecution.current;
|
|
83
|
+
if (timeSinceLastExecution >= time) {
|
|
84
|
+
// Execute immediately if enough time has passed
|
|
85
|
+
lastExecution.current = now;
|
|
86
|
+
callbackFunc(...params);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Schedule execution for the remaining time
|
|
90
|
+
clearTimeout(timeoutId.current);
|
|
91
|
+
timeoutId.current = setTimeout(() => {
|
|
92
|
+
lastExecution.current = Date.now();
|
|
93
|
+
callbackFunc(...params);
|
|
94
|
+
}, time - timeSinceLastExecution);
|
|
95
|
+
}
|
|
96
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
97
|
+
}, [callbackFunc, time, ...deps]);
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
return () => {
|
|
100
|
+
clearTimeout(timeoutId.current);
|
|
101
|
+
};
|
|
102
|
+
}, []);
|
|
103
|
+
return savedFunc;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,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;YAC1C,CAAC,EAAE,IAAI,GAAG,sBAAsB,CAAC,CAAA;QACnC,CAAC;QACH,uDAAuD;IACvD,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAA;IAEjC,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QACjC,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-chat",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.3",
|
|
4
4
|
"description": "The most complete chat UI for React Native",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"android",
|
|
@@ -23,22 +23,23 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"author": "Farid Safi",
|
|
25
25
|
"type": "module",
|
|
26
|
-
"main": "
|
|
27
|
-
"types": "
|
|
26
|
+
"main": "lib/index.js",
|
|
27
|
+
"types": "lib/index.d.ts",
|
|
28
28
|
"files": [
|
|
29
|
-
"
|
|
29
|
+
"lib"
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
|
+
"typecheck": "yarn tsc --noEmit",
|
|
33
|
+
"build": "rm -rf lib && yarn tsc",
|
|
34
|
+
"tsc:watch": "yarn typecheck --watch",
|
|
32
35
|
"lint": "yarn eslint src example",
|
|
33
36
|
"lint:fix": "yarn eslint --cache --fix src example",
|
|
34
|
-
"prepublishOnly": "yarn lint && yarn test",
|
|
37
|
+
"prepublishOnly": "yarn lint && yarn test && yarn build",
|
|
35
38
|
"start": "cd example && expo start",
|
|
36
39
|
"start:web": "cd example && expo start -w --dev",
|
|
37
40
|
"test": "TZ=Europe/Paris jest --no-watchman",
|
|
38
41
|
"test:coverage": "TZ=Europe/Paris jest --coverage",
|
|
39
42
|
"test:watch": "TZ=Europe/Paris jest --watch",
|
|
40
|
-
"tsc:write": "yarn tsc --project tsconfig.json",
|
|
41
|
-
"tsc:watch": "yarn tsc --watch --noEmit",
|
|
42
43
|
"fresh": "yarn start --reset-cache",
|
|
43
44
|
"prepare": "yarn husky"
|
|
44
45
|
},
|
|
@@ -92,11 +93,11 @@
|
|
|
92
93
|
"react": "19.1.0",
|
|
93
94
|
"react-dom": "19.1.0",
|
|
94
95
|
"react-native": "0.81.5",
|
|
95
|
-
"react-native-gesture-handler": "~2.
|
|
96
|
-
"react-native-keyboard-controller": "1.
|
|
97
|
-
"react-native-reanimated": "~4.
|
|
96
|
+
"react-native-gesture-handler": "~2.30.0",
|
|
97
|
+
"react-native-keyboard-controller": "1.20.6",
|
|
98
|
+
"react-native-reanimated": "~4.2.1",
|
|
98
99
|
"react-native-safe-area-context": "~5.6.2",
|
|
99
|
-
"react-native-worklets": "0.
|
|
100
|
+
"react-native-worklets": "0.7.2",
|
|
100
101
|
"react-test-renderer": "19.1.0",
|
|
101
102
|
"typescript": "^5.9.3"
|
|
102
103
|
},
|
package/src/Actions.tsx
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, useCallback } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
StyleSheet,
|
|
4
|
-
View,
|
|
5
|
-
StyleProp,
|
|
6
|
-
ViewStyle,
|
|
7
|
-
TextStyle,
|
|
8
|
-
} from 'react-native'
|
|
9
|
-
import { Text } from 'react-native-gesture-handler'
|
|
10
|
-
import { Color } from './Color'
|
|
11
|
-
import { TouchableOpacity } from './components/TouchableOpacity'
|
|
12
|
-
|
|
13
|
-
import { useChatContext } from './GiftedChatContext'
|
|
14
|
-
import stylesCommon from './styles'
|
|
15
|
-
|
|
16
|
-
export interface ActionsProps {
|
|
17
|
-
actions?: Array<{ title: string, action: () => void }>
|
|
18
|
-
actionSheetOptionTintColor?: string
|
|
19
|
-
icon?: () => ReactNode
|
|
20
|
-
wrapperStyle?: StyleProp<ViewStyle>
|
|
21
|
-
iconTextStyle?: StyleProp<TextStyle>
|
|
22
|
-
buttonStyle?: StyleProp<ViewStyle>
|
|
23
|
-
onPressActionButton?(): void
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function Actions ({
|
|
27
|
-
actions,
|
|
28
|
-
actionSheetOptionTintColor = Color.optionTintColor,
|
|
29
|
-
icon,
|
|
30
|
-
wrapperStyle,
|
|
31
|
-
iconTextStyle,
|
|
32
|
-
onPressActionButton,
|
|
33
|
-
buttonStyle,
|
|
34
|
-
}: ActionsProps) {
|
|
35
|
-
const { actionSheet } = useChatContext()
|
|
36
|
-
|
|
37
|
-
const handlePress = useCallback(() => {
|
|
38
|
-
if (onPressActionButton) {
|
|
39
|
-
onPressActionButton()
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (!actions?.length)
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
const titles = actions.map(item => item.title)
|
|
47
|
-
|
|
48
|
-
actionSheet().showActionSheetWithOptions(
|
|
49
|
-
{
|
|
50
|
-
options: titles,
|
|
51
|
-
cancelButtonIndex: titles.length - 1,
|
|
52
|
-
tintColor: actionSheetOptionTintColor,
|
|
53
|
-
},
|
|
54
|
-
(buttonIndex?: number) => {
|
|
55
|
-
if (buttonIndex === undefined)
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
const item = actions[buttonIndex]
|
|
59
|
-
item.action?.()
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
}, [actionSheet, actions, actionSheetOptionTintColor, onPressActionButton])
|
|
63
|
-
|
|
64
|
-
const renderIcon = useCallback(() => {
|
|
65
|
-
if (icon)
|
|
66
|
-
return icon()
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<View style={[stylesCommon.centerItems, styles.wrapper, wrapperStyle]}>
|
|
70
|
-
<Text style={[styles.iconText, iconTextStyle]}>{'+'}</Text>
|
|
71
|
-
</View>
|
|
72
|
-
)
|
|
73
|
-
}, [icon, iconTextStyle, wrapperStyle])
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<View style={styles.container}>
|
|
77
|
-
<TouchableOpacity
|
|
78
|
-
onPress={handlePress}
|
|
79
|
-
style={[styles.button, buttonStyle]}
|
|
80
|
-
>
|
|
81
|
-
{renderIcon()}
|
|
82
|
-
</TouchableOpacity>
|
|
83
|
-
</View>
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const styles = StyleSheet.create({
|
|
88
|
-
container: {
|
|
89
|
-
alignItems: 'flex-end',
|
|
90
|
-
},
|
|
91
|
-
button: {
|
|
92
|
-
paddingLeft: 10,
|
|
93
|
-
paddingRight: 4,
|
|
94
|
-
paddingVertical: 7,
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
wrapper: {
|
|
98
|
-
borderColor: Color.defaultColor,
|
|
99
|
-
borderWidth: 2,
|
|
100
|
-
width: 26,
|
|
101
|
-
height: 26,
|
|
102
|
-
borderRadius: 13,
|
|
103
|
-
},
|
|
104
|
-
iconText: {
|
|
105
|
-
color: Color.defaultColor,
|
|
106
|
-
fontWeight: 'bold',
|
|
107
|
-
fontSize: 16,
|
|
108
|
-
lineHeight: 16,
|
|
109
|
-
},
|
|
110
|
-
})
|
package/src/Avatar.tsx
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, useCallback } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
ImageStyle,
|
|
4
|
-
StyleSheet,
|
|
5
|
-
TextStyle,
|
|
6
|
-
View,
|
|
7
|
-
ViewStyle,
|
|
8
|
-
} from 'react-native'
|
|
9
|
-
import { GiftedAvatar } from './GiftedAvatar'
|
|
10
|
-
import { IMessage, LeftRightStyle, User } from './Models'
|
|
11
|
-
import { isSameUser, isSameDay } from './utils'
|
|
12
|
-
|
|
13
|
-
interface Styles {
|
|
14
|
-
left: {
|
|
15
|
-
container: ViewStyle
|
|
16
|
-
onTop: ViewStyle
|
|
17
|
-
image: ImageStyle
|
|
18
|
-
}
|
|
19
|
-
right: {
|
|
20
|
-
container: ViewStyle
|
|
21
|
-
onTop: ViewStyle
|
|
22
|
-
image: ImageStyle
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const styles: Styles = {
|
|
27
|
-
left: StyleSheet.create({
|
|
28
|
-
container: {
|
|
29
|
-
marginRight: 8,
|
|
30
|
-
},
|
|
31
|
-
onTop: {
|
|
32
|
-
alignSelf: 'flex-start',
|
|
33
|
-
},
|
|
34
|
-
image: {
|
|
35
|
-
height: 36,
|
|
36
|
-
width: 36,
|
|
37
|
-
borderRadius: 18,
|
|
38
|
-
},
|
|
39
|
-
}),
|
|
40
|
-
right: StyleSheet.create({
|
|
41
|
-
container: {
|
|
42
|
-
marginLeft: 8,
|
|
43
|
-
},
|
|
44
|
-
onTop: {
|
|
45
|
-
alignSelf: 'flex-start',
|
|
46
|
-
},
|
|
47
|
-
image: {
|
|
48
|
-
height: 36,
|
|
49
|
-
width: 36,
|
|
50
|
-
borderRadius: 18,
|
|
51
|
-
},
|
|
52
|
-
}),
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface AvatarProps<TMessage extends IMessage> {
|
|
56
|
-
currentMessage: TMessage
|
|
57
|
-
previousMessage?: TMessage
|
|
58
|
-
nextMessage?: TMessage
|
|
59
|
-
position: 'left' | 'right'
|
|
60
|
-
isAvatarOnTop?: boolean
|
|
61
|
-
isAvatarVisibleForEveryMessage?: boolean
|
|
62
|
-
imageStyle?: LeftRightStyle<ImageStyle>
|
|
63
|
-
containerStyle?: LeftRightStyle<ViewStyle>
|
|
64
|
-
textStyle?: TextStyle
|
|
65
|
-
renderAvatar?(props: Omit<AvatarProps<TMessage>, 'renderAvatar'>): ReactNode
|
|
66
|
-
onPressAvatar?: (user: User) => void
|
|
67
|
-
onLongPressAvatar?: (user: User) => void
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function Avatar<TMessage extends IMessage = IMessage> (
|
|
71
|
-
props: AvatarProps<TMessage>
|
|
72
|
-
) {
|
|
73
|
-
const {
|
|
74
|
-
isAvatarOnTop,
|
|
75
|
-
isAvatarVisibleForEveryMessage,
|
|
76
|
-
containerStyle,
|
|
77
|
-
position,
|
|
78
|
-
currentMessage,
|
|
79
|
-
renderAvatar,
|
|
80
|
-
previousMessage,
|
|
81
|
-
nextMessage,
|
|
82
|
-
imageStyle,
|
|
83
|
-
onPressAvatar,
|
|
84
|
-
onLongPressAvatar,
|
|
85
|
-
} = props
|
|
86
|
-
|
|
87
|
-
const messageToCompare = isAvatarOnTop ? previousMessage : nextMessage
|
|
88
|
-
|
|
89
|
-
const renderAvatarComponent = useCallback(() => {
|
|
90
|
-
if (renderAvatar)
|
|
91
|
-
return renderAvatar({
|
|
92
|
-
isAvatarOnTop,
|
|
93
|
-
isAvatarVisibleForEveryMessage,
|
|
94
|
-
containerStyle,
|
|
95
|
-
position,
|
|
96
|
-
currentMessage,
|
|
97
|
-
previousMessage,
|
|
98
|
-
nextMessage,
|
|
99
|
-
imageStyle,
|
|
100
|
-
onPressAvatar,
|
|
101
|
-
onLongPressAvatar,
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
if (currentMessage)
|
|
105
|
-
return (
|
|
106
|
-
<GiftedAvatar
|
|
107
|
-
avatarStyle={[
|
|
108
|
-
styles[position].image,
|
|
109
|
-
imageStyle?.[position],
|
|
110
|
-
]}
|
|
111
|
-
user={currentMessage.user}
|
|
112
|
-
onPress={() => onPressAvatar?.(currentMessage.user)}
|
|
113
|
-
onLongPress={() => onLongPressAvatar?.(currentMessage.user)}
|
|
114
|
-
/>
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
return null
|
|
118
|
-
}, [
|
|
119
|
-
renderAvatar,
|
|
120
|
-
isAvatarOnTop,
|
|
121
|
-
isAvatarVisibleForEveryMessage,
|
|
122
|
-
containerStyle,
|
|
123
|
-
position,
|
|
124
|
-
currentMessage,
|
|
125
|
-
previousMessage,
|
|
126
|
-
nextMessage,
|
|
127
|
-
imageStyle,
|
|
128
|
-
onPressAvatar,
|
|
129
|
-
onLongPressAvatar,
|
|
130
|
-
])
|
|
131
|
-
|
|
132
|
-
if (renderAvatar === null)
|
|
133
|
-
return null
|
|
134
|
-
|
|
135
|
-
if (
|
|
136
|
-
!isAvatarVisibleForEveryMessage &&
|
|
137
|
-
currentMessage &&
|
|
138
|
-
messageToCompare &&
|
|
139
|
-
isSameUser(currentMessage, messageToCompare) &&
|
|
140
|
-
isSameDay(currentMessage, messageToCompare)
|
|
141
|
-
)
|
|
142
|
-
return (
|
|
143
|
-
<View
|
|
144
|
-
style={[
|
|
145
|
-
styles[position].container,
|
|
146
|
-
containerStyle?.[position],
|
|
147
|
-
]}
|
|
148
|
-
>
|
|
149
|
-
<GiftedAvatar
|
|
150
|
-
avatarStyle={[
|
|
151
|
-
styles[position].image,
|
|
152
|
-
imageStyle?.[position],
|
|
153
|
-
]}
|
|
154
|
-
/>
|
|
155
|
-
</View>
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
return (
|
|
159
|
-
<View
|
|
160
|
-
style={[
|
|
161
|
-
styles[position].container,
|
|
162
|
-
isAvatarOnTop && styles[position].onTop,
|
|
163
|
-
containerStyle?.[position],
|
|
164
|
-
]}
|
|
165
|
-
>
|
|
166
|
-
{renderAvatarComponent()}
|
|
167
|
-
</View>
|
|
168
|
-
)
|
|
169
|
-
}
|