@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
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { ScrollView, StyleSheet } from 'react-native';
|
|
3
|
+
import { KContainer, KImage, KColors, KLabel } from '@droppii/libs';
|
|
4
|
+
|
|
5
|
+
type AttachmentType = 'image' | 'video' | 'audio' | 'document' | 'file';
|
|
6
|
+
|
|
7
|
+
interface AttachmentMetadata {
|
|
8
|
+
path: string;
|
|
9
|
+
filename?: string;
|
|
10
|
+
size?: number;
|
|
11
|
+
duration?: number;
|
|
12
|
+
mimeType?: string;
|
|
13
|
+
width?: number;
|
|
14
|
+
height?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface AttachmentItem {
|
|
18
|
+
metadata: AttachmentMetadata;
|
|
19
|
+
uploadProgress: number;
|
|
20
|
+
error: string | null;
|
|
21
|
+
isUploading: boolean;
|
|
22
|
+
uploadedUrl?: string;
|
|
23
|
+
thumbnailUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface AttachmentPreviewProps {
|
|
27
|
+
visible: boolean;
|
|
28
|
+
attachments?: Array<AttachmentItem & { type: AttachmentType }>;
|
|
29
|
+
onRemove: (type: AttachmentType, index: number) => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const formatDuration = (seconds: number): string => {
|
|
33
|
+
const mins = Math.floor(seconds / 60);
|
|
34
|
+
const secs = seconds % 60;
|
|
35
|
+
return `${mins}:${secs.toString().padStart(2, '0')}`;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const getAttachmentIcon = (type: AttachmentType): string => {
|
|
39
|
+
switch (type) {
|
|
40
|
+
case 'image':
|
|
41
|
+
return 'image';
|
|
42
|
+
case 'video':
|
|
43
|
+
return 'play-circle';
|
|
44
|
+
case 'audio':
|
|
45
|
+
return 'music';
|
|
46
|
+
case 'document':
|
|
47
|
+
return 'file-document';
|
|
48
|
+
case 'file':
|
|
49
|
+
default:
|
|
50
|
+
return 'file';
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const AttachmentPreview = memo(
|
|
55
|
+
({ visible, attachments, onRemove }: AttachmentPreviewProps) => {
|
|
56
|
+
if (!visible || !attachments?.length) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<KContainer.View
|
|
62
|
+
paddingH="0.75rem"
|
|
63
|
+
// paddingV="0.75rem"
|
|
64
|
+
brW={1}
|
|
65
|
+
brC={KColors.palette.gray.w100}
|
|
66
|
+
background={KColors.white}
|
|
67
|
+
style={styles.container}
|
|
68
|
+
>
|
|
69
|
+
<KContainer.View row alignItems minH={70}>
|
|
70
|
+
<KContainer.View flex>
|
|
71
|
+
<ScrollView
|
|
72
|
+
horizontal
|
|
73
|
+
showsHorizontalScrollIndicator={false}
|
|
74
|
+
scrollEventThrottle={16}
|
|
75
|
+
contentContainerStyle={{ alignItems: 'center' }}
|
|
76
|
+
>
|
|
77
|
+
{attachments.map((item, index) => {
|
|
78
|
+
const {
|
|
79
|
+
type,
|
|
80
|
+
metadata,
|
|
81
|
+
uploadProgress,
|
|
82
|
+
error,
|
|
83
|
+
isUploading,
|
|
84
|
+
thumbnailUrl,
|
|
85
|
+
} = item;
|
|
86
|
+
|
|
87
|
+
const isImage = type === 'image';
|
|
88
|
+
const isVideo = type === 'video';
|
|
89
|
+
const hasPreview = isImage || isVideo;
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<KContainer.View key={`${type}-${index}`}>
|
|
93
|
+
<KContainer.View style={styles.thumbnail} center>
|
|
94
|
+
{/* Video thumbnail */}
|
|
95
|
+
{isVideo && thumbnailUrl && (
|
|
96
|
+
<KImage.Base
|
|
97
|
+
uri={thumbnailUrl}
|
|
98
|
+
width={48}
|
|
99
|
+
height={48}
|
|
100
|
+
resizeMode="cover"
|
|
101
|
+
/>
|
|
102
|
+
)}
|
|
103
|
+
|
|
104
|
+
{/* Video placeholder (no thumbnail yet) */}
|
|
105
|
+
{isVideo && !thumbnailUrl && (
|
|
106
|
+
<KContainer.View
|
|
107
|
+
style={[styles.videoBg, styles.videoThumbnail]}
|
|
108
|
+
/>
|
|
109
|
+
)}
|
|
110
|
+
|
|
111
|
+
{/* Image preview */}
|
|
112
|
+
{isImage && (
|
|
113
|
+
<KImage.Base
|
|
114
|
+
uri={`file://${metadata.path}`}
|
|
115
|
+
width={48}
|
|
116
|
+
height={48}
|
|
117
|
+
/>
|
|
118
|
+
)}
|
|
119
|
+
|
|
120
|
+
{/* Show icon overlay for non-media files */}
|
|
121
|
+
{!hasPreview && (
|
|
122
|
+
<KContainer.View
|
|
123
|
+
style={styles.iconOverlay}
|
|
124
|
+
center
|
|
125
|
+
background={KColors.palette.gray.w100}
|
|
126
|
+
>
|
|
127
|
+
<KImage.VectorIcons
|
|
128
|
+
name={getAttachmentIcon(type)}
|
|
129
|
+
provider="MaterialCommunityIcons"
|
|
130
|
+
size={24}
|
|
131
|
+
color={KColors.palette.primary.w400}
|
|
132
|
+
/>
|
|
133
|
+
</KContainer.View>
|
|
134
|
+
)}
|
|
135
|
+
|
|
136
|
+
{/* Video duration badge */}
|
|
137
|
+
{isVideo && metadata.duration && (
|
|
138
|
+
<KContainer.View style={styles.durationBadge} center>
|
|
139
|
+
<KLabel.Text
|
|
140
|
+
typo="TextXsNormal"
|
|
141
|
+
color={KColors.white}
|
|
142
|
+
style={styles.durationText}
|
|
143
|
+
>
|
|
144
|
+
{formatDuration(metadata.duration / 1000)}
|
|
145
|
+
</KLabel.Text>
|
|
146
|
+
</KContainer.View>
|
|
147
|
+
)}
|
|
148
|
+
|
|
149
|
+
{/* Type icon for non-preview items */}
|
|
150
|
+
{!hasPreview && (
|
|
151
|
+
<KContainer.View style={styles.typeIcon} center>
|
|
152
|
+
<KImage.VectorIcons
|
|
153
|
+
name={getAttachmentIcon(type)}
|
|
154
|
+
provider="MaterialCommunityIcons"
|
|
155
|
+
size={14}
|
|
156
|
+
color={KColors.white}
|
|
157
|
+
/>
|
|
158
|
+
</KContainer.View>
|
|
159
|
+
)}
|
|
160
|
+
|
|
161
|
+
{/* Error state */}
|
|
162
|
+
{error && (
|
|
163
|
+
<KContainer.View style={styles.errorOverlay} center>
|
|
164
|
+
<KImage.VectorIcons
|
|
165
|
+
name="close-circle"
|
|
166
|
+
provider="MaterialCommunityIcons"
|
|
167
|
+
size={28}
|
|
168
|
+
color={KColors.white}
|
|
169
|
+
/>
|
|
170
|
+
</KContainer.View>
|
|
171
|
+
)}
|
|
172
|
+
|
|
173
|
+
{/* Progress overlay */}
|
|
174
|
+
{isUploading && (
|
|
175
|
+
<KContainer.View style={styles.progressOverlay} center>
|
|
176
|
+
<KLabel.Text
|
|
177
|
+
typo="TextSmNormal"
|
|
178
|
+
color={KColors.white}
|
|
179
|
+
>
|
|
180
|
+
{uploadProgress}%
|
|
181
|
+
</KLabel.Text>
|
|
182
|
+
</KContainer.View>
|
|
183
|
+
)}
|
|
184
|
+
</KContainer.View>
|
|
185
|
+
{/* Remove button */}
|
|
186
|
+
<KContainer.Touchable
|
|
187
|
+
style={styles.removeButton}
|
|
188
|
+
center
|
|
189
|
+
br="round"
|
|
190
|
+
background={KColors.black}
|
|
191
|
+
onPress={() => onRemove(type, index)}
|
|
192
|
+
disabled={isUploading}
|
|
193
|
+
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
|
194
|
+
>
|
|
195
|
+
<KImage.VectorIcons
|
|
196
|
+
name="close"
|
|
197
|
+
provider="MaterialCommunityIcons"
|
|
198
|
+
size={14}
|
|
199
|
+
color={KColors.white}
|
|
200
|
+
/>
|
|
201
|
+
</KContainer.Touchable>
|
|
202
|
+
</KContainer.View>
|
|
203
|
+
);
|
|
204
|
+
})}
|
|
205
|
+
</ScrollView>
|
|
206
|
+
</KContainer.View>
|
|
207
|
+
</KContainer.View>
|
|
208
|
+
</KContainer.View>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
AttachmentPreview.displayName = 'AttachmentPreview';
|
|
214
|
+
|
|
215
|
+
const styles = StyleSheet.create({
|
|
216
|
+
container: {
|
|
217
|
+
// minHeight: 80,
|
|
218
|
+
},
|
|
219
|
+
thumbnail: {
|
|
220
|
+
position: 'relative',
|
|
221
|
+
width: 48,
|
|
222
|
+
height: 48,
|
|
223
|
+
borderRadius: 4,
|
|
224
|
+
overflow: 'hidden',
|
|
225
|
+
marginRight: 8,
|
|
226
|
+
backgroundColor: KColors.palette.gray.w50,
|
|
227
|
+
},
|
|
228
|
+
durationBadge: {
|
|
229
|
+
position: 'absolute',
|
|
230
|
+
bottom: 4,
|
|
231
|
+
right: 4,
|
|
232
|
+
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
233
|
+
borderRadius: 3,
|
|
234
|
+
paddingVertical: 2,
|
|
235
|
+
paddingHorizontal: 4,
|
|
236
|
+
},
|
|
237
|
+
durationText: {
|
|
238
|
+
fontSize: 11,
|
|
239
|
+
fontWeight: '600',
|
|
240
|
+
},
|
|
241
|
+
iconOverlay: {
|
|
242
|
+
width: 48,
|
|
243
|
+
height: 48,
|
|
244
|
+
borderRadius: 4,
|
|
245
|
+
},
|
|
246
|
+
videoIcon: {
|
|
247
|
+
position: 'absolute',
|
|
248
|
+
top: 2,
|
|
249
|
+
right: 2,
|
|
250
|
+
backgroundColor: 'rgba(0, 0, 0, 0.6)',
|
|
251
|
+
borderRadius: 8,
|
|
252
|
+
width: 20,
|
|
253
|
+
height: 20,
|
|
254
|
+
},
|
|
255
|
+
typeIcon: {
|
|
256
|
+
position: 'absolute',
|
|
257
|
+
bottom: 2,
|
|
258
|
+
right: 2,
|
|
259
|
+
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
260
|
+
borderRadius: 6,
|
|
261
|
+
width: 16,
|
|
262
|
+
height: 16,
|
|
263
|
+
},
|
|
264
|
+
videoBg: {
|
|
265
|
+
width: 48,
|
|
266
|
+
height: 48,
|
|
267
|
+
borderRadius: 4,
|
|
268
|
+
},
|
|
269
|
+
videoThumbnail: {
|
|
270
|
+
backgroundColor: KColors.black,
|
|
271
|
+
},
|
|
272
|
+
progressOverlay: {
|
|
273
|
+
position: 'absolute',
|
|
274
|
+
top: 0,
|
|
275
|
+
left: 0,
|
|
276
|
+
right: 0,
|
|
277
|
+
bottom: 0,
|
|
278
|
+
backgroundColor: 'rgba(0, 0, 0, 0.6)',
|
|
279
|
+
},
|
|
280
|
+
errorOverlay: {
|
|
281
|
+
position: 'absolute',
|
|
282
|
+
top: 0,
|
|
283
|
+
left: 0,
|
|
284
|
+
right: 0,
|
|
285
|
+
bottom: 0,
|
|
286
|
+
backgroundColor: 'rgba(255, 59, 48, 0.8)',
|
|
287
|
+
},
|
|
288
|
+
removeButton: {
|
|
289
|
+
position: 'absolute',
|
|
290
|
+
top: -8,
|
|
291
|
+
right: 2,
|
|
292
|
+
width: 22,
|
|
293
|
+
height: 22,
|
|
294
|
+
shadowColor: '#000',
|
|
295
|
+
shadowOffset: { width: 0, height: 1 },
|
|
296
|
+
shadowOpacity: 0.2,
|
|
297
|
+
shadowRadius: 2,
|
|
298
|
+
elevation: 3,
|
|
299
|
+
},
|
|
300
|
+
sendButton: {
|
|
301
|
+
width: 48,
|
|
302
|
+
height: 48,
|
|
303
|
+
},
|
|
304
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { forwardRef, useImperativeHandle } from 'react';
|
|
2
|
+
import { Modal, StyleSheet } from 'react-native';
|
|
3
|
+
import MediaViewerScreen from '../screens/MediaView';
|
|
4
|
+
import { useMediaViewer, type MediaItem } from '../hooks/useMediaViewer';
|
|
5
|
+
|
|
6
|
+
export interface MediaViewerModalHandle {
|
|
7
|
+
show: (items: MediaItem[], index?: number) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface MediaViewerModalProps {
|
|
11
|
+
onDismiss?: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const MediaViewerModal = forwardRef<
|
|
15
|
+
MediaViewerModalHandle,
|
|
16
|
+
MediaViewerModalProps
|
|
17
|
+
>(({ onDismiss }, ref) => {
|
|
18
|
+
const { visible, mediaList, initIndex, show, hide } = useMediaViewer();
|
|
19
|
+
|
|
20
|
+
// Expose show method to parent via ref
|
|
21
|
+
useImperativeHandle(
|
|
22
|
+
ref,
|
|
23
|
+
() => ({
|
|
24
|
+
show,
|
|
25
|
+
}),
|
|
26
|
+
[show]
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const handleDismiss = () => {
|
|
30
|
+
hide();
|
|
31
|
+
onDismiss?.();
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
if (!visible || mediaList.length === 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const images = mediaList.map((item) => ({
|
|
39
|
+
url: item.url,
|
|
40
|
+
isVideo: item.isVideo || false,
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Modal
|
|
45
|
+
visible={visible}
|
|
46
|
+
transparent={false}
|
|
47
|
+
statusBarTranslucent={true}
|
|
48
|
+
style={styles.modal}
|
|
49
|
+
presentationStyle="overFullScreen"
|
|
50
|
+
animationType="fade"
|
|
51
|
+
onRequestClose={handleDismiss}
|
|
52
|
+
>
|
|
53
|
+
<MediaViewerScreen
|
|
54
|
+
images={images}
|
|
55
|
+
initIndex={initIndex}
|
|
56
|
+
pagination={images.length > 1}
|
|
57
|
+
onDismiss={handleDismiss}
|
|
58
|
+
download
|
|
59
|
+
/>
|
|
60
|
+
</Modal>
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
MediaViewerModal.displayName = 'MediaViewerModal';
|
|
65
|
+
|
|
66
|
+
const styles = StyleSheet.create({
|
|
67
|
+
modal: {
|
|
68
|
+
flex: 1,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { memo, useMemo, useState, useCallback } from 'react';
|
|
2
|
+
import { StyleSheet, useWindowDimensions } from 'react-native';
|
|
3
|
+
import { KContainer, KImage, KLabel, KColors } from '@droppii/libs';
|
|
4
|
+
import ChatImageDimens from '../utils/chatImageDimens';
|
|
5
|
+
import type { MediaItem } from '../hooks/useMediaViewer';
|
|
6
|
+
|
|
7
|
+
interface MergedImageGridProps {
|
|
8
|
+
images: Array<{
|
|
9
|
+
pictureElem?: any;
|
|
10
|
+
}>;
|
|
11
|
+
maxDisplay?: number;
|
|
12
|
+
onMediaPress?: (items: MediaItem[], index?: number) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Generic image grid for merged messages
|
|
17
|
+
* Layout: 1 image (1x1), 2 images (1x2), 3 images (1x3), 4+ images (2x2)
|
|
18
|
+
* Shows "+N more" overlay on last cell if images exceed limit
|
|
19
|
+
*/
|
|
20
|
+
export const MergedImageGrid = memo(
|
|
21
|
+
({ images, maxDisplay = 4, onMediaPress }: MergedImageGridProps) => {
|
|
22
|
+
const windowWidth = useWindowDimensions().width;
|
|
23
|
+
const [loadingState, setLoadingState] = useState<Record<number, boolean>>(
|
|
24
|
+
{}
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const displayedImages = useMemo(
|
|
28
|
+
() => images.slice(0, maxDisplay),
|
|
29
|
+
[images, maxDisplay]
|
|
30
|
+
);
|
|
31
|
+
const hiddenCount = Math.max(0, images.length - maxDisplay);
|
|
32
|
+
|
|
33
|
+
// Calculate single image dimensions respecting aspect ratio and 80% width limit
|
|
34
|
+
const singleImageSize = useMemo(() => {
|
|
35
|
+
if (displayedImages.length !== 1) return null;
|
|
36
|
+
|
|
37
|
+
const image = displayedImages[0];
|
|
38
|
+
const pictureElem = image?.pictureElem;
|
|
39
|
+
const imgWidth =
|
|
40
|
+
pictureElem?.width || pictureElem?.bigPicture?.width || 0;
|
|
41
|
+
const imgHeight =
|
|
42
|
+
pictureElem?.height || pictureElem?.bigPicture?.height || 0;
|
|
43
|
+
|
|
44
|
+
const maxWidth = Math.floor(windowWidth * 0.8);
|
|
45
|
+
const aspectRatio = imgWidth && imgHeight ? imgWidth / imgHeight : 1;
|
|
46
|
+
|
|
47
|
+
// Calculate dimensions respecting aspect ratio and max width
|
|
48
|
+
let finalWidth = maxWidth;
|
|
49
|
+
let finalHeight = maxWidth / aspectRatio;
|
|
50
|
+
|
|
51
|
+
// If height exceeds reasonable limit, scale down
|
|
52
|
+
const maxHeight = 400;
|
|
53
|
+
if (finalHeight > maxHeight) {
|
|
54
|
+
finalHeight = maxHeight;
|
|
55
|
+
finalWidth = finalHeight * aspectRatio;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
width: Math.round(finalWidth),
|
|
60
|
+
height: Math.round(finalHeight),
|
|
61
|
+
};
|
|
62
|
+
}, [displayedImages, windowWidth]);
|
|
63
|
+
|
|
64
|
+
const mediaItems = useMemo(
|
|
65
|
+
() =>
|
|
66
|
+
images
|
|
67
|
+
.map((image) => {
|
|
68
|
+
const pictureElem = image.pictureElem;
|
|
69
|
+
const imageUrl =
|
|
70
|
+
pictureElem?.snapshotPicture?.url ||
|
|
71
|
+
pictureElem?.bigPicture?.url ||
|
|
72
|
+
pictureElem?.sourcePicture?.url;
|
|
73
|
+
return { url: imageUrl };
|
|
74
|
+
})
|
|
75
|
+
.filter((item): item is MediaItem => Boolean(item.url)),
|
|
76
|
+
[images]
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const handleImageLoadEnd = useCallback((index: number) => {
|
|
80
|
+
setLoadingState((prev) => ({
|
|
81
|
+
...prev,
|
|
82
|
+
[index]: false,
|
|
83
|
+
}));
|
|
84
|
+
}, []);
|
|
85
|
+
|
|
86
|
+
const handleImagePress = useCallback(
|
|
87
|
+
(index: number) => {
|
|
88
|
+
onMediaPress?.(mediaItems, index);
|
|
89
|
+
},
|
|
90
|
+
[onMediaPress, mediaItems]
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const initializeLoading = useMemo(() => {
|
|
94
|
+
const initial: Record<number, boolean> = {};
|
|
95
|
+
displayedImages.forEach((_, index) => {
|
|
96
|
+
initial[index] = true;
|
|
97
|
+
});
|
|
98
|
+
return initial;
|
|
99
|
+
}, [displayedImages]);
|
|
100
|
+
|
|
101
|
+
useMemo(() => {
|
|
102
|
+
setLoadingState(initializeLoading);
|
|
103
|
+
}, [initializeLoading]);
|
|
104
|
+
|
|
105
|
+
if (displayedImages.length === 0) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Calculate columns based on image count
|
|
110
|
+
let columns = 1;
|
|
111
|
+
if (displayedImages.length === 2) {
|
|
112
|
+
columns = 2; // 2 images: horizontal layout (1x2)
|
|
113
|
+
} else if (displayedImages.length === 3) {
|
|
114
|
+
columns = 3; // 3 images: horizontal layout (1x3)
|
|
115
|
+
} else if (displayedImages.length >= 4) {
|
|
116
|
+
columns = 2; // 4+ images: grid layout (2x2)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Use calculated aspect ratio for single image, 100x100 for multiple images
|
|
120
|
+
const cellSize =
|
|
121
|
+
displayedImages.length === 1 && singleImageSize
|
|
122
|
+
? singleImageSize.width
|
|
123
|
+
: 100;
|
|
124
|
+
const cellHeight =
|
|
125
|
+
displayedImages.length === 1 && singleImageSize
|
|
126
|
+
? singleImageSize.height
|
|
127
|
+
: cellSize;
|
|
128
|
+
const gap = 4;
|
|
129
|
+
const totalWidth = cellSize * columns + gap * (columns - 1);
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<KContainer.View
|
|
133
|
+
style={[
|
|
134
|
+
styles.grid,
|
|
135
|
+
{
|
|
136
|
+
width: totalWidth,
|
|
137
|
+
},
|
|
138
|
+
]}
|
|
139
|
+
>
|
|
140
|
+
{displayedImages.map((image, index) => {
|
|
141
|
+
const pictureElem = image.pictureElem;
|
|
142
|
+
const imageUrl =
|
|
143
|
+
pictureElem?.snapshotPicture?.url ||
|
|
144
|
+
pictureElem?.bigPicture?.url ||
|
|
145
|
+
pictureElem?.sourcePicture?.url;
|
|
146
|
+
|
|
147
|
+
if (!imageUrl) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Use dynamic optimization based on calculated dimensions
|
|
152
|
+
const optimizedUrl =
|
|
153
|
+
ChatImageDimens.getOptimizedImageUrlWithDimensions(
|
|
154
|
+
imageUrl,
|
|
155
|
+
cellSize,
|
|
156
|
+
cellHeight
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
const isLastCell = index === displayedImages.length - 1;
|
|
160
|
+
const showHiddenCount = isLastCell && hiddenCount > 0;
|
|
161
|
+
const isImageLoading = loadingState[index] ?? true;
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<KContainer.Touchable
|
|
165
|
+
key={`merged-image-${index}`}
|
|
166
|
+
onPress={() => handleImagePress(index)}
|
|
167
|
+
style={[
|
|
168
|
+
styles.imageCell,
|
|
169
|
+
{
|
|
170
|
+
width: cellSize,
|
|
171
|
+
height: cellHeight,
|
|
172
|
+
},
|
|
173
|
+
]}
|
|
174
|
+
>
|
|
175
|
+
<KImage.Base
|
|
176
|
+
uri={optimizedUrl}
|
|
177
|
+
width={cellSize}
|
|
178
|
+
height={cellHeight}
|
|
179
|
+
style={styles.image}
|
|
180
|
+
onLoadEnd={() => handleImageLoadEnd(index)}
|
|
181
|
+
/>
|
|
182
|
+
|
|
183
|
+
{isImageLoading && <KContainer.View style={styles.skeleton} />}
|
|
184
|
+
|
|
185
|
+
{/* Hidden count overlay with +N text */}
|
|
186
|
+
{showHiddenCount && (
|
|
187
|
+
<KContainer.View style={styles.hiddenOverlay} center>
|
|
188
|
+
<KLabel.Text typo="TextMdBold" color={KColors.white}>
|
|
189
|
+
+{hiddenCount}
|
|
190
|
+
</KLabel.Text>
|
|
191
|
+
</KContainer.View>
|
|
192
|
+
)}
|
|
193
|
+
</KContainer.Touchable>
|
|
194
|
+
);
|
|
195
|
+
})}
|
|
196
|
+
</KContainer.View>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
MergedImageGrid.displayName = 'MergedImageGrid';
|
|
202
|
+
|
|
203
|
+
const styles = StyleSheet.create({
|
|
204
|
+
grid: {
|
|
205
|
+
flexDirection: 'row',
|
|
206
|
+
flexWrap: 'wrap',
|
|
207
|
+
gap: 4,
|
|
208
|
+
justifyContent: 'flex-start',
|
|
209
|
+
alignItems: 'flex-start',
|
|
210
|
+
},
|
|
211
|
+
imageCell: {
|
|
212
|
+
position: 'relative',
|
|
213
|
+
overflow: 'hidden',
|
|
214
|
+
borderRadius: 8,
|
|
215
|
+
backgroundColor: '#f0f0f0',
|
|
216
|
+
},
|
|
217
|
+
image: {
|
|
218
|
+
width: '100%',
|
|
219
|
+
height: '100%',
|
|
220
|
+
},
|
|
221
|
+
skeleton: {
|
|
222
|
+
position: 'absolute',
|
|
223
|
+
top: 0,
|
|
224
|
+
left: 0,
|
|
225
|
+
right: 0,
|
|
226
|
+
bottom: 0,
|
|
227
|
+
backgroundColor: '#f0f0f0',
|
|
228
|
+
borderRadius: 8,
|
|
229
|
+
},
|
|
230
|
+
hiddenOverlay: {
|
|
231
|
+
position: 'absolute',
|
|
232
|
+
top: 0,
|
|
233
|
+
left: 0,
|
|
234
|
+
right: 0,
|
|
235
|
+
bottom: 0,
|
|
236
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
237
|
+
},
|
|
238
|
+
});
|