@droppii-org/chat-mobile 0.2.7 → 0.2.8
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/lib/module/components/AttachmentPreview.js +250 -0
- package/lib/module/components/AttachmentPreview.js.map +1 -0
- package/lib/module/components/MediaViewer/index.js +2 -0
- package/lib/module/components/MediaViewer/index.js.map +1 -0
- package/lib/module/components/MediaViewerModal.js +57 -0
- package/lib/module/components/MediaViewerModal.js.map +1 -0
- package/lib/module/components/MergedImageGrid.js +173 -0
- package/lib/module/components/MergedImageGrid.js.map +1 -0
- package/lib/module/components/ThreadCard/thread-card.utils.js +80 -4
- package/lib/module/components/ThreadCard/thread-card.utils.js.map +1 -1
- package/lib/module/components/messages/fileMessage/index.js +26 -0
- package/lib/module/components/messages/fileMessage/index.js.map +1 -0
- package/lib/module/components/messages/imageMessage/index.js +118 -0
- package/lib/module/components/messages/imageMessage/index.js.map +1 -0
- package/lib/module/components/messages/linkMessage/index.js +122 -0
- package/lib/module/components/messages/linkMessage/index.js.map +1 -0
- package/lib/module/components/messages/mergedMessage/index.js +37 -0
- package/lib/module/components/messages/mergedMessage/index.js.map +1 -0
- package/lib/module/components/messages/styles.js +41 -0
- package/lib/module/components/messages/styles.js.map +1 -0
- package/lib/module/components/messages/textMessage/index.js +38 -0
- package/lib/module/components/messages/textMessage/index.js.map +1 -0
- package/lib/module/components/messages/types.js +14 -0
- package/lib/module/components/messages/types.js.map +1 -0
- package/lib/module/components/messages/videoMessage/index.js +110 -0
- package/lib/module/components/messages/videoMessage/index.js.map +1 -0
- package/lib/module/config/api-endpoints.js +66 -0
- package/lib/module/config/api-endpoints.js.map +1 -0
- package/lib/module/config/attachment-priority.js +81 -0
- package/lib/module/config/attachment-priority.js.map +1 -0
- package/lib/module/config/configuration.js +50 -0
- package/lib/module/config/configuration.js.map +1 -0
- package/lib/module/config/index.js +22 -0
- package/lib/module/config/index.js.map +1 -0
- package/lib/module/core/index.js +19 -1
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/useChatListener.js +0 -14
- package/lib/module/core/useChatListener.js.map +1 -1
- package/lib/module/hooks/message/useSendMessage.js +10 -5
- package/lib/module/hooks/message/useSendMessage.js.map +1 -1
- package/lib/module/hooks/useChatMessages.js +0 -3
- package/lib/module/hooks/useChatMessages.js.map +1 -1
- package/lib/module/hooks/useImageAttachment.js +263 -0
- package/lib/module/hooks/useImageAttachment.js.map +1 -0
- package/lib/module/hooks/useMediaViewer.js +24 -0
- package/lib/module/hooks/useMediaViewer.js.map +1 -0
- package/lib/module/hooks/useSendAttachment.js +182 -0
- package/lib/module/hooks/useSendAttachment.js.map +1 -0
- package/lib/module/hooks/useVideoAttachment.js +251 -0
- package/lib/module/hooks/useVideoAttachment.js.map +1 -0
- package/lib/module/index.js +13 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/screens/MediaView/VideoPlayer.js +177 -0
- package/lib/module/screens/MediaView/VideoPlayer.js.map +1 -0
- package/lib/module/screens/MediaView/index.js +264 -0
- package/lib/module/screens/MediaView/index.js.map +1 -0
- package/lib/module/screens/chat-detail/ChatComposer.js +190 -196
- package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatDetail.js +94 -63
- package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatListLegend.js +5 -13
- package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
- package/lib/module/screens/chat-detail/components/ChatInputActions.js +51 -0
- package/lib/module/screens/chat-detail/components/ChatInputActions.js.map +1 -0
- package/lib/module/screens/chat-detail/components/ChatMessageInput.js +93 -0
- package/lib/module/screens/chat-detail/components/ChatMessageInput.js.map +1 -0
- package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js +221 -0
- package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js.map +1 -0
- package/lib/module/screens/chat-detail/hooks/useChatComposerAnimation.js +114 -0
- package/lib/module/screens/chat-detail/hooks/useChatComposerAnimation.js.map +1 -0
- package/lib/module/screens/chat-detail/hooks/useChatComposerState.js +26 -0
- package/lib/module/screens/chat-detail/hooks/useChatComposerState.js.map +1 -0
- package/lib/module/screens/chat-detail/index.js +0 -1
- package/lib/module/screens/chat-detail/index.js.map +1 -1
- package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +33 -13
- package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -1
- package/lib/module/screens/chat-detail/legend/messageTypes.js +15 -0
- package/lib/module/screens/chat-detail/legend/messageTypes.js.map +1 -0
- package/lib/module/screens/inbox/MessagesTab.js.map +1 -1
- package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js +61 -0
- package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js.map +1 -0
- package/lib/module/services/attachmentHandlers/imageAttachmentHandler.js +54 -0
- package/lib/module/services/attachmentHandlers/imageAttachmentHandler.js.map +1 -0
- package/lib/module/services/attachmentHandlers/index.js +12 -0
- package/lib/module/services/attachmentHandlers/index.js.map +1 -0
- package/lib/module/services/attachmentHandlers/videoAttachmentHandler.js +85 -0
- package/lib/module/services/attachmentHandlers/videoAttachmentHandler.js.map +1 -0
- package/lib/module/services/attachmentOrchestrator.js +225 -0
- package/lib/module/services/attachmentOrchestrator.js.map +1 -0
- package/lib/module/services/auth.js +35 -0
- package/lib/module/services/auth.js.map +1 -0
- package/lib/module/services/endpoints.js +20 -1
- package/lib/module/services/endpoints.js.map +1 -1
- package/lib/module/services/imageUpload.js +126 -0
- package/lib/module/services/imageUpload.js.map +1 -0
- package/lib/module/translation/resources/i18n.js +22 -8
- package/lib/module/translation/resources/i18n.js.map +1 -1
- package/lib/module/types/attachment.js +2 -0
- package/lib/module/types/attachment.js.map +1 -0
- package/lib/module/types/attachmentHandler.js +20 -0
- package/lib/module/types/attachmentHandler.js.map +1 -0
- package/lib/module/types/imageUpload.js +2 -0
- package/lib/module/types/imageUpload.js.map +1 -0
- package/lib/module/types/message.js +1 -0
- package/lib/module/types/message.js.map +1 -1
- package/lib/module/utils/chatImageDimens.js +148 -0
- package/lib/module/utils/chatImageDimens.js.map +1 -0
- package/lib/module/utils/device.js +65 -0
- package/lib/module/utils/device.js.map +1 -0
- package/lib/module/utils/imageUrlOptimizer.js +41 -0
- package/lib/module/utils/imageUrlOptimizer.js.map +1 -0
- package/lib/module/utils/imageUtils.js +69 -0
- package/lib/module/utils/imageUtils.js.map +1 -0
- package/lib/module/utils/resolveMessageType.js +3 -0
- package/lib/module/utils/resolveMessageType.js.map +1 -1
- package/lib/module/utils/ui.js +17 -0
- package/lib/module/utils/ui.js.map +1 -0
- package/lib/module/utils/url.js +1 -1
- package/lib/module/utils/url.js.map +1 -1
- package/lib/module/utils/videoThumbnail.js +62 -0
- package/lib/module/utils/videoThumbnail.js.map +1 -0
- package/lib/typescript/src/components/AttachmentPreview.d.ts +28 -0
- package/lib/typescript/src/components/AttachmentPreview.d.ts.map +1 -0
- package/lib/typescript/src/components/MediaViewer/index.d.ts +1 -0
- package/lib/typescript/src/components/MediaViewer/index.d.ts.map +1 -0
- package/lib/typescript/src/components/MediaViewerModal.d.ts +10 -0
- package/lib/typescript/src/components/MediaViewerModal.d.ts.map +1 -0
- package/lib/typescript/src/components/MergedImageGrid.d.ts +16 -0
- package/lib/typescript/src/components/MergedImageGrid.d.ts.map +1 -0
- package/lib/typescript/src/components/ThreadCard/thread-card.utils.d.ts.map +1 -1
- package/lib/typescript/src/components/messages/fileMessage/index.d.ts +3 -0
- package/lib/typescript/src/components/messages/fileMessage/index.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/imageMessage/index.d.ts +3 -0
- package/lib/typescript/src/components/messages/imageMessage/index.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/linkMessage/index.d.ts +9 -0
- package/lib/typescript/src/components/messages/linkMessage/index.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/mergedMessage/index.d.ts +3 -0
- package/lib/typescript/src/components/messages/mergedMessage/index.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/styles.d.ts +36 -0
- package/lib/typescript/src/components/messages/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/textMessage/index.d.ts +9 -0
- package/lib/typescript/src/components/messages/textMessage/index.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/types.d.ts +10 -0
- package/lib/typescript/src/components/messages/types.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/videoMessage/index.d.ts +3 -0
- package/lib/typescript/src/components/messages/videoMessage/index.d.ts.map +1 -0
- package/lib/typescript/src/config/api-endpoints.d.ts +40 -0
- package/lib/typescript/src/config/api-endpoints.d.ts.map +1 -0
- package/lib/typescript/src/config/attachment-priority.d.ts +31 -0
- package/lib/typescript/src/config/attachment-priority.d.ts.map +1 -0
- package/lib/typescript/src/config/configuration.d.ts +30 -0
- package/lib/typescript/src/config/configuration.d.ts.map +1 -0
- package/lib/typescript/src/config/index.d.ts +15 -0
- package/lib/typescript/src/config/index.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +13 -1
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
- package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useChatMessages.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useImageAttachment.d.ts +20 -0
- package/lib/typescript/src/hooks/useImageAttachment.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useMediaViewer.d.ts +13 -0
- package/lib/typescript/src/hooks/useMediaViewer.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useSendAttachment.d.ts +59 -0
- package/lib/typescript/src/hooks/useSendAttachment.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useVideoAttachment.d.ts +29 -0
- package/lib/typescript/src/hooks/useVideoAttachment.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +14 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/MediaView/VideoPlayer.d.ts +12 -0
- package/lib/typescript/src/screens/MediaView/VideoPlayer.d.ts.map +1 -0
- package/lib/typescript/src/screens/MediaView/index.d.ts +11 -0
- package/lib/typescript/src/screens/MediaView/index.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/components/ChatInputActions.d.ts +8 -0
- package/lib/typescript/src/screens/chat-detail/components/ChatInputActions.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/components/ChatMessageInput.d.ts +15 -0
- package/lib/typescript/src/screens/chat-detail/components/ChatMessageInput.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts +23 -0
- package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerAnimation.d.ts +15 -0
- package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerAnimation.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerState.d.ts +13 -0
- package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerState.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/index.d.ts +0 -2
- package/lib/typescript/src/screens/chat-detail/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts +3 -1
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/legend/messageTypes.d.ts +13 -0
- package/lib/typescript/src/screens/chat-detail/legend/messageTypes.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/types.d.ts +4 -1
- package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
- package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts +22 -0
- package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts.map +1 -0
- package/lib/typescript/src/services/attachmentHandlers/imageAttachmentHandler.d.ts +3 -0
- package/lib/typescript/src/services/attachmentHandlers/imageAttachmentHandler.d.ts.map +1 -0
- package/lib/typescript/src/services/attachmentHandlers/index.d.ts +5 -0
- package/lib/typescript/src/services/attachmentHandlers/index.d.ts.map +1 -0
- package/lib/typescript/src/services/attachmentHandlers/videoAttachmentHandler.d.ts +31 -0
- package/lib/typescript/src/services/attachmentHandlers/videoAttachmentHandler.d.ts.map +1 -0
- package/lib/typescript/src/services/attachmentOrchestrator.d.ts +5 -0
- package/lib/typescript/src/services/attachmentOrchestrator.d.ts.map +1 -0
- package/lib/typescript/src/services/auth.d.ts +19 -0
- package/lib/typescript/src/services/auth.d.ts.map +1 -0
- package/lib/typescript/src/services/endpoints.d.ts +11 -1
- package/lib/typescript/src/services/endpoints.d.ts.map +1 -1
- package/lib/typescript/src/services/imageUpload.d.ts +7 -0
- package/lib/typescript/src/services/imageUpload.d.ts.map +1 -0
- package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
- package/lib/typescript/src/types/attachment.d.ts +72 -0
- package/lib/typescript/src/types/attachment.d.ts.map +1 -0
- package/lib/typescript/src/types/attachmentHandler.d.ts +13 -0
- package/lib/typescript/src/types/attachmentHandler.d.ts.map +1 -0
- package/lib/typescript/src/types/imageUpload.d.ts +26 -0
- package/lib/typescript/src/types/imageUpload.d.ts.map +1 -0
- package/lib/typescript/src/types/message.d.ts +1 -0
- package/lib/typescript/src/types/message.d.ts.map +1 -1
- package/lib/typescript/src/utils/chatImageDimens.d.ts +34 -0
- package/lib/typescript/src/utils/chatImageDimens.d.ts.map +1 -0
- package/lib/typescript/src/utils/device.d.ts +7 -0
- package/lib/typescript/src/utils/device.d.ts.map +1 -0
- package/lib/typescript/src/utils/imageUrlOptimizer.d.ts +12 -0
- package/lib/typescript/src/utils/imageUrlOptimizer.d.ts.map +1 -0
- package/lib/typescript/src/utils/imageUtils.d.ts +9 -0
- package/lib/typescript/src/utils/imageUtils.d.ts.map +1 -0
- package/lib/typescript/src/utils/resolveMessageType.d.ts.map +1 -1
- package/lib/typescript/src/utils/ui.d.ts +13 -0
- package/lib/typescript/src/utils/ui.d.ts.map +1 -0
- package/lib/typescript/src/utils/videoThumbnail.d.ts +16 -0
- package/lib/typescript/src/utils/videoThumbnail.d.ts.map +1 -0
- package/package.json +15 -3
- package/src/components/AttachmentPreview.tsx +304 -0
- package/src/components/MediaViewer/index.tsx +0 -0
- package/src/components/MediaViewerModal.tsx +70 -0
- package/src/components/MergedImageGrid.tsx +238 -0
- package/src/components/ThreadCard/thread-card.utils.ts +95 -4
- package/src/components/messages/fileMessage/index.tsx +30 -0
- package/src/components/messages/imageMessage/index.tsx +137 -0
- package/src/components/messages/linkMessage/index.tsx +162 -0
- package/src/components/messages/mergedMessage/index.tsx +45 -0
- package/src/components/messages/styles.ts +39 -0
- package/src/components/messages/textMessage/index.tsx +53 -0
- package/src/components/messages/types.ts +22 -0
- package/src/components/messages/videoMessage/index.tsx +120 -0
- package/src/config/api-endpoints.ts +72 -0
- package/src/config/attachment-priority.ts +93 -0
- package/src/config/configuration.ts +50 -0
- package/src/config/index.ts +19 -0
- package/src/core/index.ts +25 -1
- package/src/core/useChatListener.ts +0 -21
- package/src/hooks/message/useSendMessage.ts +12 -5
- package/src/hooks/useChatMessages.ts +0 -4
- package/src/hooks/useImageAttachment.ts +348 -0
- package/src/hooks/useMediaViewer.ts +32 -0
- package/src/hooks/useSendAttachment.ts +295 -0
- package/src/hooks/useVideoAttachment.ts +334 -0
- package/src/index.tsx +13 -1
- package/src/screens/MediaView/VideoPlayer.tsx +211 -0
- package/src/screens/MediaView/index.tsx +327 -0
- package/src/screens/chat-detail/ChatComposer.tsx +206 -271
- package/src/screens/chat-detail/ChatDetail.tsx +142 -89
- package/src/screens/chat-detail/ChatListLegend.tsx +9 -11
- package/src/screens/chat-detail/components/ChatInputActions.tsx +71 -0
- package/src/screens/chat-detail/components/ChatMessageInput.tsx +127 -0
- package/src/screens/chat-detail/hooks/useAttachmentSendHandler.ts +291 -0
- package/src/screens/chat-detail/hooks/useChatComposerAnimation.ts +184 -0
- package/src/screens/chat-detail/hooks/useChatComposerState.ts +40 -0
- package/src/screens/chat-detail/index.ts +0 -2
- package/src/screens/chat-detail/legend/LegendChatMessage.tsx +47 -24
- package/src/screens/chat-detail/legend/messageTypes.tsx +13 -0
- package/src/screens/chat-detail/types.ts +5 -1
- package/src/screens/inbox/MessagesTab.tsx +1 -1
- package/src/services/attachmentHandlers/fileAttachmentHandler.ts +78 -0
- package/src/services/attachmentHandlers/imageAttachmentHandler.ts +54 -0
- package/src/services/attachmentHandlers/index.ts +10 -0
- package/src/services/attachmentHandlers/videoAttachmentHandler.ts +114 -0
- package/src/services/attachmentOrchestrator.ts +300 -0
- package/src/services/auth.ts +34 -0
- package/src/services/endpoints.ts +24 -1
- package/src/services/imageUpload.ts +162 -0
- package/src/translation/resources/i18n.ts +22 -8
- package/src/types/attachment.ts +85 -0
- package/src/types/attachmentHandler.ts +31 -0
- package/src/types/imageUpload.ts +28 -0
- package/src/types/message.ts +1 -0
- package/src/utils/chatImageDimens.ts +178 -0
- package/src/utils/device.ts +73 -0
- package/src/utils/imageUrlOptimizer.ts +56 -0
- package/src/utils/imageUtils.ts +76 -0
- package/src/utils/resolveMessageType.ts +2 -0
- package/src/utils/ui.ts +19 -0
- package/src/utils/url.ts +1 -1
- package/src/utils/videoThumbnail.ts +85 -0
- package/lib/module/screens/chat-detail/ChatList.js +0 -147
- package/lib/module/screens/chat-detail/ChatList.js.map +0 -1
- package/lib/module/screens/chat-detail/ChatTextBubble.js +0 -62
- package/lib/module/screens/chat-detail/ChatTextBubble.js.map +0 -1
- package/lib/module/screens/chat-detail/legend/message-types.js +0 -244
- package/lib/module/screens/chat-detail/legend/message-types.js.map +0 -1
- package/lib/module/screens/chat-detail/messages/ChatMessageBubble.js +0 -24
- package/lib/module/screens/chat-detail/messages/ChatMessageBubble.js.map +0 -1
- package/lib/module/screens/chat-detail/messages/types.js +0 -4
- package/lib/module/screens/chat-detail/messages/types.js.map +0 -1
- package/lib/typescript/src/screens/chat-detail/ChatList.d.ts +0 -3
- package/lib/typescript/src/screens/chat-detail/ChatList.d.ts.map +0 -1
- package/lib/typescript/src/screens/chat-detail/ChatTextBubble.d.ts +0 -3
- package/lib/typescript/src/screens/chat-detail/ChatTextBubble.d.ts.map +0 -1
- package/lib/typescript/src/screens/chat-detail/legend/message-types.d.ts +0 -13
- package/lib/typescript/src/screens/chat-detail/legend/message-types.d.ts.map +0 -1
- package/lib/typescript/src/screens/chat-detail/messages/ChatMessageBubble.d.ts +0 -3
- package/lib/typescript/src/screens/chat-detail/messages/ChatMessageBubble.d.ts.map +0 -1
- package/lib/typescript/src/screens/chat-detail/messages/types.d.ts +0 -13
- package/lib/typescript/src/screens/chat-detail/messages/types.d.ts.map +0 -1
- package/src/screens/chat-detail/ChatList.tsx +0 -190
- package/src/screens/chat-detail/ChatTextBubble.tsx +0 -73
- package/src/screens/chat-detail/legend/message-types.tsx +0 -304
- package/src/screens/chat-detail/messages/ChatMessageBubble.tsx +0 -23
- package/src/screens/chat-detail/messages/types.ts +0 -14
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MessageType } from '@droppii/openim-rn-client-sdk';
|
|
2
2
|
import type { DMessageItem } from '../../types/chat';
|
|
3
|
+
import { DChatMessageType } from '../../types/message';
|
|
3
4
|
|
|
4
5
|
const extractTextContent = (message: DMessageItem): string => {
|
|
5
6
|
if (message.textElem?.content) return message.textElem.content;
|
|
@@ -11,18 +12,108 @@ const extractTextContent = (message: DMessageItem): string => {
|
|
|
11
12
|
}
|
|
12
13
|
};
|
|
13
14
|
|
|
15
|
+
const formatDuration = (seconds: number): string => {
|
|
16
|
+
const mins = Math.floor(seconds / 60);
|
|
17
|
+
const secs = seconds % 60;
|
|
18
|
+
return `${mins}:${secs.toString().padStart(2, '0')}`;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getMessagePreview = (message: DMessageItem): string => {
|
|
22
|
+
// Check custom message type first
|
|
23
|
+
if (message.contentType === MessageType.CustomMessage) {
|
|
24
|
+
try {
|
|
25
|
+
const data = JSON.parse(message.content);
|
|
26
|
+
const dataType = data.dataType || data.type;
|
|
27
|
+
|
|
28
|
+
if (dataType === DChatMessageType.Link) {
|
|
29
|
+
const linkText = data.content || data.title || 'Link';
|
|
30
|
+
return linkText;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (dataType === DChatMessageType.Order) {
|
|
34
|
+
const orderCode = data.orderCode || data.code || '';
|
|
35
|
+
return `[Đơn hàng] ${orderCode}`;
|
|
36
|
+
}
|
|
37
|
+
} catch {
|
|
38
|
+
// Fall through to default
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Handle standard message types
|
|
43
|
+
switch (message.contentType) {
|
|
44
|
+
case MessageType.TextMessage:
|
|
45
|
+
return extractTextContent(message);
|
|
46
|
+
|
|
47
|
+
case MessageType.PictureMessage:
|
|
48
|
+
return '[Hình ảnh]';
|
|
49
|
+
|
|
50
|
+
case MessageType.VideoMessage:
|
|
51
|
+
try {
|
|
52
|
+
const videoData = JSON.parse(message.content);
|
|
53
|
+
const duration = videoData.duration || 0;
|
|
54
|
+
const durationStr = duration > 0 ? ` ${formatDuration(duration)}` : '';
|
|
55
|
+
return `[Video]${durationStr}`;
|
|
56
|
+
} catch {
|
|
57
|
+
return '[Video]';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
case MessageType.FileMessage:
|
|
61
|
+
try {
|
|
62
|
+
const fileData = JSON.parse(message.content);
|
|
63
|
+
const fileName = fileData.fileName || fileData.name || 'File';
|
|
64
|
+
return `[File] ${fileName}`;
|
|
65
|
+
} catch {
|
|
66
|
+
return '[File]';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
case MessageType.MergeMessage:
|
|
70
|
+
// Show image count for merged messages containing images
|
|
71
|
+
try {
|
|
72
|
+
const mergeData = message.mergeElem;
|
|
73
|
+
if (mergeData?.multiMessage) {
|
|
74
|
+
const imageCount = mergeData.multiMessage.filter(
|
|
75
|
+
(msg: any) => msg.contentType === MessageType.PictureMessage
|
|
76
|
+
).length;
|
|
77
|
+
if (imageCount > 0) {
|
|
78
|
+
return `${imageCount} [Hình ảnh]`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} catch {
|
|
82
|
+
// Fall through to default
|
|
83
|
+
}
|
|
84
|
+
return '';
|
|
85
|
+
|
|
86
|
+
case MessageType.UrlTextMessage:
|
|
87
|
+
// Preview link message - show with [Link] prefix
|
|
88
|
+
const urlText =
|
|
89
|
+
message?.urlTextElem?.content || message?.urlTextElem?.urls?.[0] || '';
|
|
90
|
+
console.log('message', urlText);
|
|
91
|
+
return urlText ? `[Link] ${urlText}` : '[Link]';
|
|
92
|
+
|
|
93
|
+
case MessageType.AtTextMessage:
|
|
94
|
+
case MessageType.QuoteMessage:
|
|
95
|
+
return extractTextContent(message);
|
|
96
|
+
|
|
97
|
+
default:
|
|
98
|
+
return '[Tin nhắn không được hỗ trợ]';
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
14
102
|
export const getLastMessageText = (
|
|
15
103
|
message: DMessageItem | undefined,
|
|
16
104
|
currentUserId?: string
|
|
17
105
|
): string => {
|
|
18
106
|
if (!message) return '';
|
|
19
|
-
if (message.contentType !== MessageType.TextMessage) return '';
|
|
20
107
|
|
|
21
|
-
const
|
|
108
|
+
const preview = getMessagePreview(message);
|
|
109
|
+
if (!preview) return '';
|
|
110
|
+
|
|
111
|
+
// Add sender name
|
|
22
112
|
if (currentUserId && message.sendID === currentUserId) {
|
|
23
|
-
return `Bạn: ${
|
|
113
|
+
return `Bạn: ${preview}`;
|
|
24
114
|
}
|
|
25
|
-
|
|
115
|
+
|
|
116
|
+
return preview;
|
|
26
117
|
};
|
|
27
118
|
|
|
28
119
|
export const formatTimestamp = (ts: number | string | null): string => {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { KContainer, KLabel } from '@droppii/libs';
|
|
3
|
+
import { CHAT_BUBBLE_COLORS } from '../../../screens/chat-detail/constants';
|
|
4
|
+
import { messageStyles } from '../styles';
|
|
5
|
+
import type { BaseLegendMessageProps } from '../types';
|
|
6
|
+
|
|
7
|
+
export const FileMessage = memo(
|
|
8
|
+
({ message, isOutgoing }: BaseLegendMessageProps) => {
|
|
9
|
+
const fileName = message.fileElem?.fileName || message.content || '[File]';
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<KContainer.View style={messageStyles.wrapper}>
|
|
13
|
+
<KContainer.View
|
|
14
|
+
style={[
|
|
15
|
+
messageStyles.bubble,
|
|
16
|
+
isOutgoing
|
|
17
|
+
? messageStyles.bubbleSent
|
|
18
|
+
: messageStyles.bubbleReceived,
|
|
19
|
+
]}
|
|
20
|
+
>
|
|
21
|
+
<KLabel.Text typo="TextSmNormal" color={CHAT_BUBBLE_COLORS.text}>
|
|
22
|
+
📎 {fileName}
|
|
23
|
+
</KLabel.Text>
|
|
24
|
+
</KContainer.View>
|
|
25
|
+
</KContainer.View>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
FileMessage.displayName = 'FileMessage';
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { memo, useState, useCallback, useMemo } from 'react';
|
|
2
|
+
import { StyleSheet, Image, useWindowDimensions } from 'react-native';
|
|
3
|
+
import { KContainer, KImage } from '@droppii/libs';
|
|
4
|
+
import ChatImageDimens from '../../../utils/chatImageDimens';
|
|
5
|
+
import { messageStyles } from '../styles';
|
|
6
|
+
import type { BaseLegendMessageProps } from '../types';
|
|
7
|
+
|
|
8
|
+
export const ImageMessage = memo(
|
|
9
|
+
({ message, onMediaPress }: BaseLegendMessageProps) => {
|
|
10
|
+
const windowWidth = useWindowDimensions().width;
|
|
11
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
12
|
+
const pictureElem = (message as any).pictureElem;
|
|
13
|
+
const rawImageUrl =
|
|
14
|
+
pictureElem?.snapshotPicture?.url ||
|
|
15
|
+
pictureElem?.bigPicture?.url ||
|
|
16
|
+
pictureElem?.sourcePicture?.url;
|
|
17
|
+
|
|
18
|
+
// Calculate dimensions respecting aspect ratio and 80% device width
|
|
19
|
+
const imageDimensions = useMemo(() => {
|
|
20
|
+
if (!rawImageUrl) return { width: 250, height: 250 };
|
|
21
|
+
|
|
22
|
+
const responseWidth =
|
|
23
|
+
pictureElem?.width ||
|
|
24
|
+
pictureElem?.bigPicture?.width ||
|
|
25
|
+
pictureElem?.snapshotPicture?.width;
|
|
26
|
+
const responseHeight =
|
|
27
|
+
pictureElem?.height ||
|
|
28
|
+
pictureElem?.bigPicture?.height ||
|
|
29
|
+
pictureElem?.snapshotPicture?.height;
|
|
30
|
+
|
|
31
|
+
let imgWidth = responseWidth;
|
|
32
|
+
let imgHeight = responseHeight;
|
|
33
|
+
|
|
34
|
+
// If no dimensions in response, try to resolve from image source
|
|
35
|
+
if (!imgWidth || !imgHeight) {
|
|
36
|
+
try {
|
|
37
|
+
const source = Image.resolveAssetSource({ uri: rawImageUrl });
|
|
38
|
+
imgWidth = source?.width || 300;
|
|
39
|
+
imgHeight = source?.height || 300;
|
|
40
|
+
} catch {
|
|
41
|
+
// Fallback to default if resolution fails
|
|
42
|
+
imgWidth = 300;
|
|
43
|
+
imgHeight = 300;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const aspectRatio = imgWidth / imgHeight;
|
|
48
|
+
// Account for all margins/padding: use 75% of window width with buffer
|
|
49
|
+
const horizontalBuffer = 16; // Left and right combined buffer
|
|
50
|
+
const maxWidth = Math.floor(windowWidth * 0.75 - horizontalBuffer);
|
|
51
|
+
|
|
52
|
+
// Calculate final dimensions
|
|
53
|
+
let finalWidth = maxWidth;
|
|
54
|
+
let finalHeight = maxWidth / aspectRatio;
|
|
55
|
+
|
|
56
|
+
// Cap maximum height to avoid overly tall images
|
|
57
|
+
const maxHeight = 500;
|
|
58
|
+
if (finalHeight > maxHeight) {
|
|
59
|
+
finalHeight = maxHeight;
|
|
60
|
+
finalWidth = finalHeight * aspectRatio;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
width: Math.round(finalWidth),
|
|
65
|
+
height: Math.round(finalHeight),
|
|
66
|
+
};
|
|
67
|
+
}, [pictureElem, rawImageUrl, windowWidth]);
|
|
68
|
+
|
|
69
|
+
const handleLoadEnd = useCallback(() => {
|
|
70
|
+
setIsLoading(false);
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
const handlePress = useCallback(() => {
|
|
74
|
+
onMediaPress?.([{ url: rawImageUrl }], 0);
|
|
75
|
+
}, [onMediaPress, rawImageUrl]);
|
|
76
|
+
|
|
77
|
+
if (!rawImageUrl) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Use dynamic optimization matching calculated dimensions
|
|
82
|
+
const optimizedUrl = ChatImageDimens.getOptimizedImageUrlWithDimensions(
|
|
83
|
+
rawImageUrl,
|
|
84
|
+
imageDimensions.width,
|
|
85
|
+
imageDimensions.height
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<KContainer.View style={[messageStyles.wrapper, styles.wrapper]}>
|
|
90
|
+
<KContainer.Touchable
|
|
91
|
+
onPress={handlePress}
|
|
92
|
+
style={[
|
|
93
|
+
messageStyles.imageBubble,
|
|
94
|
+
styles.imageContainer,
|
|
95
|
+
{
|
|
96
|
+
width: imageDimensions.width,
|
|
97
|
+
height: imageDimensions.height,
|
|
98
|
+
},
|
|
99
|
+
]}
|
|
100
|
+
>
|
|
101
|
+
<KImage.Base
|
|
102
|
+
uri={optimizedUrl}
|
|
103
|
+
width={imageDimensions.width}
|
|
104
|
+
height={imageDimensions.height}
|
|
105
|
+
style={[messageStyles.imageBubble]}
|
|
106
|
+
onLoadEnd={handleLoadEnd}
|
|
107
|
+
/>
|
|
108
|
+
|
|
109
|
+
{isLoading && <KContainer.View style={styles.skeleton} />}
|
|
110
|
+
</KContainer.Touchable>
|
|
111
|
+
</KContainer.View>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
ImageMessage.displayName = 'ImageMessage';
|
|
117
|
+
|
|
118
|
+
const styles = StyleSheet.create({
|
|
119
|
+
wrapper: {
|
|
120
|
+
// paddingRight: 8,
|
|
121
|
+
overflow: 'hidden',
|
|
122
|
+
},
|
|
123
|
+
skeleton: {
|
|
124
|
+
position: 'absolute',
|
|
125
|
+
top: 0,
|
|
126
|
+
left: 0,
|
|
127
|
+
right: 0,
|
|
128
|
+
bottom: 0,
|
|
129
|
+
backgroundColor: '#f0f0f0',
|
|
130
|
+
borderRadius: 8,
|
|
131
|
+
},
|
|
132
|
+
imageContainer: {
|
|
133
|
+
position: 'relative',
|
|
134
|
+
overflow: 'hidden',
|
|
135
|
+
borderRadius: 8,
|
|
136
|
+
},
|
|
137
|
+
});
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { Linking, StyleSheet } from 'react-native';
|
|
3
|
+
import {
|
|
4
|
+
KContainer,
|
|
5
|
+
KImage,
|
|
6
|
+
KLabel,
|
|
7
|
+
KColors,
|
|
8
|
+
KSpacingValue,
|
|
9
|
+
} from '@droppii/libs';
|
|
10
|
+
import type { DMessageItem } from '../../../types/chat';
|
|
11
|
+
import type { IUrlMetadata } from '../../../types/common';
|
|
12
|
+
import { formatMessageTime } from '../types';
|
|
13
|
+
import { CHAT_BUBBLE_COLORS } from '../../../screens/chat-detail/constants';
|
|
14
|
+
|
|
15
|
+
interface BaseLegendMessageProps {
|
|
16
|
+
message: DMessageItem;
|
|
17
|
+
isOutgoing: boolean;
|
|
18
|
+
createdAtTime: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const parseUrlMetadata = (ex?: string): IUrlMetadata | undefined => {
|
|
22
|
+
if (!ex) return undefined;
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(ex) as any;
|
|
25
|
+
// Handle nested urlMetadata structure
|
|
26
|
+
return parsed.urlMetadata || parsed;
|
|
27
|
+
} catch {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const renderTextWithLinks = (content: string, urls: string[]) => {
|
|
33
|
+
if (!urls.length) {
|
|
34
|
+
return <KLabel.Text typo="TextMdNormal">{content}</KLabel.Text>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<KLabel.Text typo="TextMdNormal" color={CHAT_BUBBLE_COLORS.text}>
|
|
39
|
+
{content}
|
|
40
|
+
</KLabel.Text>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const LinkMessage = memo(
|
|
45
|
+
({ message, isOutgoing, createdAtTime }: BaseLegendMessageProps) => {
|
|
46
|
+
const content = message?.urlTextElem?.content;
|
|
47
|
+
const urls = message?.urlTextElem?.urls ?? [];
|
|
48
|
+
const metadata = parseUrlMetadata(message.ex);
|
|
49
|
+
const timeLabel = formatMessageTime(createdAtTime);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<KContainer.View style={styles.wrapper}>
|
|
53
|
+
<KContainer.View
|
|
54
|
+
style={[
|
|
55
|
+
styles.bubble,
|
|
56
|
+
isOutgoing ? styles.bubbleSent : styles.bubbleReceived,
|
|
57
|
+
]}
|
|
58
|
+
>
|
|
59
|
+
{!!content?.trim() && (
|
|
60
|
+
<KContainer.View style={styles.textRow}>
|
|
61
|
+
{renderTextWithLinks(content, urls)}
|
|
62
|
+
</KContainer.View>
|
|
63
|
+
)}
|
|
64
|
+
|
|
65
|
+
{metadata && (
|
|
66
|
+
<KContainer.Touchable
|
|
67
|
+
style={styles.card}
|
|
68
|
+
onPress={() => metadata.url && Linking.openURL(metadata.url)}
|
|
69
|
+
>
|
|
70
|
+
{!!metadata.image && (
|
|
71
|
+
<KContainer.View style={styles.cardThumb}>
|
|
72
|
+
<KImage.Base
|
|
73
|
+
uri={metadata.image}
|
|
74
|
+
style={StyleSheet.absoluteFill}
|
|
75
|
+
resizeMode="cover"
|
|
76
|
+
/>
|
|
77
|
+
</KContainer.View>
|
|
78
|
+
)}
|
|
79
|
+
<KContainer.View style={styles.cardBody}>
|
|
80
|
+
{!!metadata.title && (
|
|
81
|
+
<KLabel.Text
|
|
82
|
+
typo="TextNmMedium"
|
|
83
|
+
color={KColors.palette.gray.w900}
|
|
84
|
+
numberOfLines={1}
|
|
85
|
+
>
|
|
86
|
+
{metadata.title}
|
|
87
|
+
</KLabel.Text>
|
|
88
|
+
)}
|
|
89
|
+
{!!metadata.url && (
|
|
90
|
+
<KLabel.Text
|
|
91
|
+
typo="TextXsMedium"
|
|
92
|
+
color={KColors.palette.primary.w400}
|
|
93
|
+
numberOfLines={1}
|
|
94
|
+
>
|
|
95
|
+
{metadata.url}
|
|
96
|
+
</KLabel.Text>
|
|
97
|
+
)}
|
|
98
|
+
{!!metadata.description && (
|
|
99
|
+
<KLabel.Text
|
|
100
|
+
typo="TextXsNormal"
|
|
101
|
+
color={KColors.gray.normal}
|
|
102
|
+
numberOfLines={2}
|
|
103
|
+
>
|
|
104
|
+
{metadata.description}
|
|
105
|
+
</KLabel.Text>
|
|
106
|
+
)}
|
|
107
|
+
</KContainer.View>
|
|
108
|
+
</KContainer.Touchable>
|
|
109
|
+
)}
|
|
110
|
+
</KContainer.View>
|
|
111
|
+
|
|
112
|
+
{!isOutgoing && timeLabel ? (
|
|
113
|
+
<KLabel.Text
|
|
114
|
+
typo="TextXsNormal"
|
|
115
|
+
color={CHAT_BUBBLE_COLORS.timestamp}
|
|
116
|
+
marginL="0.25rem"
|
|
117
|
+
>
|
|
118
|
+
{timeLabel}
|
|
119
|
+
</KLabel.Text>
|
|
120
|
+
) : null}
|
|
121
|
+
</KContainer.View>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
LinkMessage.displayName = 'LinkMessage';
|
|
127
|
+
|
|
128
|
+
const styles = StyleSheet.create({
|
|
129
|
+
wrapper: {
|
|
130
|
+
maxWidth: '80%',
|
|
131
|
+
},
|
|
132
|
+
bubble: {
|
|
133
|
+
paddingHorizontal: KSpacingValue['0.75rem'],
|
|
134
|
+
paddingVertical: KSpacingValue['0.5rem'],
|
|
135
|
+
borderRadius: KSpacingValue['1.25rem'],
|
|
136
|
+
},
|
|
137
|
+
bubbleReceived: {
|
|
138
|
+
backgroundColor: CHAT_BUBBLE_COLORS.received,
|
|
139
|
+
},
|
|
140
|
+
bubbleSent: {
|
|
141
|
+
backgroundColor: CHAT_BUBBLE_COLORS.sent,
|
|
142
|
+
},
|
|
143
|
+
textRow: {
|
|
144
|
+
paddingHorizontal: KSpacingValue['0.25rem'],
|
|
145
|
+
},
|
|
146
|
+
card: {
|
|
147
|
+
borderRadius: KSpacingValue['0.75rem'],
|
|
148
|
+
borderWidth: 1,
|
|
149
|
+
borderColor: 'rgba(57,62,64,0.1)',
|
|
150
|
+
backgroundColor: KColors.white,
|
|
151
|
+
overflow: 'hidden',
|
|
152
|
+
},
|
|
153
|
+
cardThumb: {
|
|
154
|
+
width: '100%',
|
|
155
|
+
aspectRatio: 16 / 9,
|
|
156
|
+
},
|
|
157
|
+
cardBody: {
|
|
158
|
+
paddingHorizontal: KSpacingValue['0.75rem'],
|
|
159
|
+
paddingVertical: KSpacingValue['0.5rem'],
|
|
160
|
+
gap: 2,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { KContainer } from '@droppii/libs';
|
|
3
|
+
import { MergedImageGrid } from '../../MergedImageGrid';
|
|
4
|
+
import { messageStyles } from '../styles';
|
|
5
|
+
import type { BaseLegendMessageProps } from '../types';
|
|
6
|
+
|
|
7
|
+
export const MergedMessage = memo(
|
|
8
|
+
({ message, isOutgoing, onMediaPress }: BaseLegendMessageProps) => {
|
|
9
|
+
const mergeElem = (message as any).mergeElem;
|
|
10
|
+
|
|
11
|
+
if (!mergeElem?.multiMessage) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { multiMessage } = mergeElem;
|
|
16
|
+
const imageMessages = multiMessage.filter(
|
|
17
|
+
(msg: any) => msg.contentType === 102
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<KContainer.View style={messageStyles.wrapper}>
|
|
22
|
+
<KContainer.View
|
|
23
|
+
style={[
|
|
24
|
+
messageStyles.bubble,
|
|
25
|
+
isOutgoing
|
|
26
|
+
? messageStyles.bubbleSent
|
|
27
|
+
: messageStyles.bubbleReceived,
|
|
28
|
+
]}
|
|
29
|
+
>
|
|
30
|
+
{imageMessages.length > 0 && (
|
|
31
|
+
<KContainer.View marginB="0.5rem">
|
|
32
|
+
<MergedImageGrid
|
|
33
|
+
images={imageMessages}
|
|
34
|
+
maxDisplay={4}
|
|
35
|
+
onMediaPress={onMediaPress}
|
|
36
|
+
/>
|
|
37
|
+
</KContainer.View>
|
|
38
|
+
)}
|
|
39
|
+
</KContainer.View>
|
|
40
|
+
</KContainer.View>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
MergedMessage.displayName = 'MergedMessage';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { KSpacingValue } from '@droppii/libs';
|
|
3
|
+
import { CHAT_BUBBLE_COLORS } from '../../screens/chat-detail/constants';
|
|
4
|
+
|
|
5
|
+
export const messageStyles = StyleSheet.create({
|
|
6
|
+
wrapper: {
|
|
7
|
+
maxWidth: '80%',
|
|
8
|
+
},
|
|
9
|
+
bubble: {
|
|
10
|
+
paddingHorizontal: KSpacingValue['0.75rem'],
|
|
11
|
+
paddingVertical: KSpacingValue['0.5rem'],
|
|
12
|
+
borderRadius: KSpacingValue['1.25rem'],
|
|
13
|
+
},
|
|
14
|
+
bubbleReceived: {
|
|
15
|
+
backgroundColor: CHAT_BUBBLE_COLORS.received,
|
|
16
|
+
},
|
|
17
|
+
bubbleSent: {
|
|
18
|
+
backgroundColor: CHAT_BUBBLE_COLORS.sent,
|
|
19
|
+
},
|
|
20
|
+
imageBubble: {
|
|
21
|
+
borderRadius: KSpacingValue['0.75rem'],
|
|
22
|
+
},
|
|
23
|
+
videoPlaceholder: {
|
|
24
|
+
backgroundColor: CHAT_BUBBLE_COLORS.received,
|
|
25
|
+
},
|
|
26
|
+
videoContainer: {
|
|
27
|
+
position: 'relative',
|
|
28
|
+
overflow: 'hidden',
|
|
29
|
+
borderRadius: KSpacingValue['0.75rem'],
|
|
30
|
+
},
|
|
31
|
+
playButtonOverlay: {
|
|
32
|
+
position: 'absolute',
|
|
33
|
+
top: 0,
|
|
34
|
+
left: 0,
|
|
35
|
+
right: 0,
|
|
36
|
+
bottom: 0,
|
|
37
|
+
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
|
38
|
+
},
|
|
39
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { KContainer, KLabel } from '@droppii/libs';
|
|
3
|
+
import { getMessageText } from '../../../utils/legendListMessage';
|
|
4
|
+
import type { DMessageItem } from '../../../types/chat';
|
|
5
|
+
import { CHAT_BUBBLE_COLORS } from '../../../screens/chat-detail/constants';
|
|
6
|
+
import { messageStyles } from '../styles';
|
|
7
|
+
import { formatMessageTime } from '../types';
|
|
8
|
+
|
|
9
|
+
interface TextMessageProps {
|
|
10
|
+
message: DMessageItem;
|
|
11
|
+
isOutgoing: boolean;
|
|
12
|
+
createdAtTime: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const TextMessage = memo(
|
|
16
|
+
({ message, isOutgoing, createdAtTime }: TextMessageProps) => {
|
|
17
|
+
const messageText = getMessageText(message);
|
|
18
|
+
const timeLabel = formatMessageTime(createdAtTime);
|
|
19
|
+
|
|
20
|
+
if (!messageText?.trim()) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<KContainer.View style={messageStyles.wrapper}>
|
|
26
|
+
<KContainer.View
|
|
27
|
+
style={[
|
|
28
|
+
messageStyles.bubble,
|
|
29
|
+
isOutgoing
|
|
30
|
+
? messageStyles.bubbleSent
|
|
31
|
+
: messageStyles.bubbleReceived,
|
|
32
|
+
]}
|
|
33
|
+
>
|
|
34
|
+
<KLabel.Text typo="TextMdNormal" color={CHAT_BUBBLE_COLORS.text}>
|
|
35
|
+
{messageText}
|
|
36
|
+
</KLabel.Text>
|
|
37
|
+
</KContainer.View>
|
|
38
|
+
|
|
39
|
+
{!isOutgoing && timeLabel ? (
|
|
40
|
+
<KLabel.Text
|
|
41
|
+
typo="TextXsNormal"
|
|
42
|
+
color={CHAT_BUBBLE_COLORS.timestamp}
|
|
43
|
+
marginL={'0.25rem'}
|
|
44
|
+
>
|
|
45
|
+
{timeLabel}
|
|
46
|
+
</KLabel.Text>
|
|
47
|
+
) : null}
|
|
48
|
+
</KContainer.View>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
TextMessage.displayName = 'TextMessage';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DMessageItem } from '../../types/chat';
|
|
2
|
+
import type { MediaItem } from '../../hooks/useMediaViewer';
|
|
3
|
+
|
|
4
|
+
export interface BaseLegendMessageProps {
|
|
5
|
+
message: DMessageItem;
|
|
6
|
+
isOutgoing: boolean;
|
|
7
|
+
createdAtTime: number;
|
|
8
|
+
onMediaPress?: (items: MediaItem[], index?: number) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const formatMessageTime = (createdAt: number) => {
|
|
12
|
+
const date = new Date(createdAt);
|
|
13
|
+
if (Number.isNaN(date.getTime())) {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return date.toLocaleTimeString('vi-VN', {
|
|
18
|
+
hour: '2-digit',
|
|
19
|
+
minute: '2-digit',
|
|
20
|
+
hour12: false,
|
|
21
|
+
});
|
|
22
|
+
};
|