@droppii-org/chat-mobile 0.2.16 → 0.2.18
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/assets/images/icon_excel.png +0 -0
- package/lib/module/assets/images/icon_img.png +0 -0
- package/lib/module/assets/images/icon_pdf.png +0 -0
- package/lib/module/assets/images/icon_txt.png +0 -0
- package/lib/module/assets/images/icon_word.png +0 -0
- package/lib/module/assets/images/index.js +5 -0
- package/lib/module/assets/images/index.js.map +1 -1
- package/lib/module/components/AttachmentPreview/FilePreview.js +107 -0
- package/lib/module/components/AttachmentPreview/FilePreview.js.map +1 -0
- package/lib/module/components/AttachmentPreview/MediaPreview.js +212 -0
- package/lib/module/components/AttachmentPreview/MediaPreview.js.map +1 -0
- package/lib/module/components/AttachmentPreview/index.js +49 -0
- package/lib/module/components/AttachmentPreview/index.js.map +1 -0
- package/lib/module/components/MergedImageGrid.js +28 -18
- package/lib/module/components/MergedImageGrid.js.map +1 -1
- package/lib/module/components/messages/fileMessage/index.js +122 -12
- package/lib/module/components/messages/fileMessage/index.js.map +1 -1
- package/lib/module/components/messages/mergedMessage/index.js +4 -7
- package/lib/module/components/messages/mergedMessage/index.js.map +1 -1
- package/lib/module/hooks/useFileAttachment.js +116 -0
- package/lib/module/hooks/useFileAttachment.js.map +1 -0
- package/lib/module/hooks/useFileDownload.js +175 -0
- package/lib/module/hooks/useFileDownload.js.map +1 -0
- package/lib/module/hooks/useImageAttachment.js +16 -8
- package/lib/module/hooks/useImageAttachment.js.map +1 -1
- package/lib/module/hooks/useVideoAttachment.js +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/screens/MediaView/VideoPlayer.js +1 -0
- package/lib/module/screens/MediaView/VideoPlayer.js.map +1 -1
- package/lib/module/screens/MediaView/index.js +7 -9
- package/lib/module/screens/MediaView/index.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatComposer.js +44 -36
- package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatListLegend.js +11 -2
- package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
- package/lib/module/screens/chat-detail/hooks/useAttachmentMapping.js +51 -0
- package/lib/module/screens/chat-detail/hooks/useAttachmentMapping.js.map +1 -0
- package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js +39 -13
- package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js.map +1 -1
- package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js +6 -6
- package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js.map +1 -1
- package/lib/module/services/attachmentHandlers/index.js +1 -1
- package/lib/module/services/attachmentHandlers/index.js.map +1 -1
- package/lib/module/services/attachmentHandlers/videoAttachmentHandler.js +1 -1
- package/lib/module/translation/resources/i18n.js +10 -0
- package/lib/module/translation/resources/i18n.js.map +1 -1
- package/lib/module/utils/device.js +32 -0
- package/lib/module/utils/device.js.map +1 -1
- package/lib/module/utils/imageUtils.js +44 -28
- package/lib/module/utils/imageUtils.js.map +1 -1
- package/lib/module/utils/videoThumbnail.js +76 -3
- package/lib/module/utils/videoThumbnail.js.map +1 -1
- package/lib/typescript/src/assets/images/index.d.ts +5 -0
- package/lib/typescript/src/assets/images/index.d.ts.map +1 -1
- package/lib/typescript/src/components/AttachmentPreview/FilePreview.d.ts +6 -0
- package/lib/typescript/src/components/AttachmentPreview/FilePreview.d.ts.map +1 -0
- package/lib/typescript/src/components/AttachmentPreview/MediaPreview.d.ts +9 -0
- package/lib/typescript/src/components/AttachmentPreview/MediaPreview.d.ts.map +1 -0
- package/lib/typescript/src/components/AttachmentPreview/index.d.ts +9 -0
- package/lib/typescript/src/components/AttachmentPreview/index.d.ts.map +1 -0
- package/lib/typescript/src/components/MergedImageGrid.d.ts +2 -2
- package/lib/typescript/src/components/MergedImageGrid.d.ts.map +1 -1
- package/lib/typescript/src/components/messages/fileMessage/index.d.ts.map +1 -1
- package/lib/typescript/src/components/messages/mergedMessage/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useFileAttachment.d.ts +20 -0
- package/lib/typescript/src/hooks/useFileAttachment.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useFileDownload.d.ts +15 -0
- package/lib/typescript/src/hooks/useFileDownload.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useImageAttachment.d.ts +1 -2
- package/lib/typescript/src/hooks/useImageAttachment.d.ts.map +1 -1
- package/lib/typescript/src/screens/MediaView/VideoPlayer.d.ts.map +1 -1
- package/lib/typescript/src/screens/MediaView/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentMapping.d.ts +10 -0
- package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentMapping.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts +4 -1
- package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts.map +1 -1
- package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts +2 -2
- package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts.map +1 -1
- package/lib/typescript/src/services/attachmentHandlers/index.d.ts +1 -1
- package/lib/typescript/src/services/attachmentHandlers/index.d.ts.map +1 -1
- package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
- package/lib/typescript/src/types/attachment.d.ts +22 -1
- package/lib/typescript/src/types/attachment.d.ts.map +1 -1
- package/lib/typescript/src/utils/device.d.ts +7 -0
- package/lib/typescript/src/utils/device.d.ts.map +1 -1
- package/lib/typescript/src/utils/imageUtils.d.ts +1 -0
- package/lib/typescript/src/utils/imageUtils.d.ts.map +1 -1
- package/lib/typescript/src/utils/videoThumbnail.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/assets/images/icon_excel.png +0 -0
- package/src/assets/images/icon_img.png +0 -0
- package/src/assets/images/icon_pdf.png +0 -0
- package/src/assets/images/icon_txt.png +0 -0
- package/src/assets/images/icon_word.png +0 -0
- package/src/assets/images/index.ts +5 -0
- package/src/components/AttachmentPreview/FilePreview.tsx +137 -0
- package/src/components/AttachmentPreview/MediaPreview.tsx +238 -0
- package/src/components/AttachmentPreview/index.tsx +68 -0
- package/src/components/MergedImageGrid.tsx +36 -23
- package/src/components/messages/fileMessage/index.tsx +156 -13
- package/src/components/messages/mergedMessage/index.tsx +5 -7
- package/src/hooks/useFileAttachment.ts +163 -0
- package/src/hooks/useFileDownload.ts +200 -0
- package/src/hooks/useImageAttachment.ts +23 -13
- package/src/hooks/useVideoAttachment.ts +1 -1
- package/src/screens/MediaView/VideoPlayer.tsx +1 -0
- package/src/screens/MediaView/index.tsx +7 -6
- package/src/screens/chat-detail/ChatComposer.tsx +61 -30
- package/src/screens/chat-detail/ChatListLegend.tsx +9 -2
- package/src/screens/chat-detail/hooks/useAttachmentMapping.ts +58 -0
- package/src/screens/chat-detail/hooks/useAttachmentSendHandler.ts +50 -11
- package/src/services/attachmentHandlers/fileAttachmentHandler.ts +8 -7
- package/src/services/attachmentHandlers/index.ts +4 -1
- package/src/services/attachmentHandlers/videoAttachmentHandler.ts +1 -1
- package/src/translation/resources/i18n.ts +10 -0
- package/src/types/attachment.ts +23 -1
- package/src/utils/device.ts +58 -0
- package/src/utils/imageUtils.ts +50 -28
- package/src/utils/videoThumbnail.ts +77 -3
- package/lib/module/components/AttachmentPreview.js +0 -250
- package/lib/module/components/AttachmentPreview.js.map +0 -1
- package/lib/typescript/src/components/AttachmentPreview.d.ts +0 -28
- package/lib/typescript/src/components/AttachmentPreview.d.ts.map +0 -1
- package/src/components/AttachmentPreview.tsx +0 -304
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useImageAttachment.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useImageAttachment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAQ3E,
|
|
1
|
+
{"version":3,"file":"useImageAttachment.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useImageAttachment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAQ3E,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,WAAW,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,qBAAqB,EAAE,CAAC;IACxC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,eAAO,MAAM,kBAAkB,QAAO,wBAiTrC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoPlayer.d.ts","sourceRoot":"","sources":["../../../../../src/screens/MediaView/VideoPlayer.tsx"],"names":[],"mappings":"AAUA,OAAc,EAA0B,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAK/E,UAAU,KAAK;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAUD,QAAA,MAAM,WAAW,8CAAgB,KAAK,
|
|
1
|
+
{"version":3,"file":"VideoPlayer.d.ts","sourceRoot":"","sources":["../../../../../src/screens/MediaView/VideoPlayer.tsx"],"names":[],"mappings":"AAUA,OAAc,EAA0B,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAK/E,UAAU,KAAK;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAUD,QAAA,MAAM,WAAW,8CAAgB,KAAK,iCA+IpC,CAAC;AAGH,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/screens/MediaView/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/screens/MediaView/index.tsx"],"names":[],"mappings":"AAgCA,UAAU,iBAAiB;IACzB,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,QAAA,MAAM,iBAAiB,GAAI,OAAO,iBAAiB,gCA0LlD,CAAC;AAIF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatComposer.d.ts","sourceRoot":"","sources":["../../../../../src/screens/chat-detail/ChatComposer.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatComposer.d.ts","sourceRoot":"","sources":["../../../../../src/screens/chat-detail/ChatComposer.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAejD,eAAO,MAAM,YAAY,+TAkBpB,iBAAiB,iCA6XrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatListLegend.d.ts","sourceRoot":"","sources":["../../../../../src/screens/chat-detail/ChatListLegend.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAW7C,eAAO,MAAM,cAAc,kNActB,aAAa,
|
|
1
|
+
{"version":3,"file":"ChatListLegend.d.ts","sourceRoot":"","sources":["../../../../../src/screens/chat-detail/ChatListLegend.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAW7C,eAAO,MAAM,cAAc,kNActB,aAAa,iCA0WjB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ImageWithUploadStatus } from '../../../hooks/useImageAttachment';
|
|
2
|
+
import type { FileWithUploadStatus } from '../../../hooks/useFileAttachment';
|
|
3
|
+
import type { AttachmentItem } from '../../../types/attachment';
|
|
4
|
+
type Props = {
|
|
5
|
+
selectedImages: ImageWithUploadStatus[];
|
|
6
|
+
selectedFiles: FileWithUploadStatus[];
|
|
7
|
+
};
|
|
8
|
+
export declare const useAttachmentMapping: ({ selectedImages, selectedFiles, }: Props) => AttachmentItem[];
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=useAttachmentMapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAttachmentMapping.d.ts","sourceRoot":"","sources":["../../../../../../src/screens/chat-detail/hooks/useAttachmentMapping.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,KAAK,KAAK,GAAG;IACX,cAAc,EAAE,qBAAqB,EAAE,CAAC;IACxC,aAAa,EAAE,oBAAoB,EAAE,CAAC;CACvC,CAAC;AAwCF,eAAO,MAAM,oBAAoB,GAAI,oCAGlC,KAAK,qBAKP,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DMessageItem } from '../../../types/chat';
|
|
2
|
+
import type { FileWithUploadStatus } from '../../../hooks/useFileAttachment';
|
|
2
3
|
interface AttachmentItem {
|
|
3
4
|
image: any;
|
|
4
5
|
uploadedUrl?: string;
|
|
@@ -8,15 +9,17 @@ interface AttachmentItem {
|
|
|
8
9
|
}
|
|
9
10
|
interface UseAttachmentSendHandlerProps {
|
|
10
11
|
selectedImages: AttachmentItem[];
|
|
12
|
+
selectedFiles: FileWithUploadStatus[];
|
|
11
13
|
sendAttachments: (items: any[], _: any, onMessageSent?: (message: DMessageItem) => void) => Promise<boolean>;
|
|
12
14
|
clearAllImages: () => void;
|
|
15
|
+
clearAllFiles?: () => void;
|
|
13
16
|
onSend?: () => void;
|
|
14
17
|
onMessageSent?: (message: DMessageItem) => void;
|
|
15
18
|
textMessage?: string;
|
|
16
19
|
urlMetadata?: any;
|
|
17
20
|
onSendText?: (text: string, urlMetadata?: any) => void;
|
|
18
21
|
}
|
|
19
|
-
export declare const useAttachmentSendHandler: ({ selectedImages, sendAttachments, clearAllImages, onSend, onMessageSent, textMessage, urlMetadata, onSendText, }: UseAttachmentSendHandlerProps) => {
|
|
22
|
+
export declare const useAttachmentSendHandler: ({ selectedImages, selectedFiles, sendAttachments, clearAllImages, clearAllFiles, onSend, onMessageSent, textMessage, urlMetadata, onSendText, }: UseAttachmentSendHandlerProps) => {
|
|
20
23
|
handleSend: () => Promise<void>;
|
|
21
24
|
};
|
|
22
25
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAttachmentSendHandler.d.ts","sourceRoot":"","sources":["../../../../../../src/screens/chat-detail/hooks/useAttachmentSendHandler.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"useAttachmentSendHandler.d.ts","sourceRoot":"","sources":["../../../../../../src/screens/chat-detail/hooks/useAttachmentSendHandler.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,UAAU,cAAc;IACtB,KAAK,EAAE,GAAG,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,UAAU,6BAA6B;IACrC,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC,aAAa,EAAE,oBAAoB,EAAE,CAAC;IACtC,eAAe,EAAE,CACf,KAAK,EAAE,GAAG,EAAE,EACZ,CAAC,EAAE,GAAG,EACN,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,KAC5C,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;CACxD;AAED,eAAO,MAAM,wBAAwB,GAAI,iJAWtC,6BAA6B;;CAoV/B,CAAC"}
|
|
@@ -5,10 +5,10 @@ interface FileElem {
|
|
|
5
5
|
fileName: string;
|
|
6
6
|
fileSize: number;
|
|
7
7
|
fileType: string;
|
|
8
|
-
|
|
8
|
+
sourceUrl: string;
|
|
9
9
|
}
|
|
10
|
+
export declare const MAX_FILE_SIZE: number;
|
|
10
11
|
export declare class FileAttachmentHandler implements IAttachmentHandler {
|
|
11
|
-
private static readonly MAX_FILE_SIZE;
|
|
12
12
|
validate(attachment: Attachment): {
|
|
13
13
|
valid: true;
|
|
14
14
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileAttachmentHandler.d.ts","sourceRoot":"","sources":["../../../../../src/services/attachmentHandlers/fileAttachmentHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,
|
|
1
|
+
{"version":3,"file":"fileAttachmentHandler.d.ts","sourceRoot":"","sources":["../../../../../src/services/attachmentHandlers/fileAttachmentHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,eAAO,MAAM,aAAa,QAAU,CAAC;AAErC,qBAAa,qBAAsB,YAAW,kBAAkB;IAC9D,QAAQ,CACN,UAAU,EAAE,UAAU,GACrB;QAAE,KAAK,EAAE,IAAI,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAkC/C,YAAY,CAChB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,QAAQ,CAAC;CAsBrB;;AAED,wBAA2C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function initializeAttachmentHandlers(): void;
|
|
2
2
|
export { ImageAttachmentHandler } from './imageAttachmentHandler';
|
|
3
3
|
export { default as VideoAttachmentHandler } from './videoAttachmentHandler';
|
|
4
|
-
export { default as FileAttachmentHandler } from './fileAttachmentHandler';
|
|
4
|
+
export { default as FileAttachmentHandler, MAX_FILE_SIZE, } from './fileAttachmentHandler';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/attachmentHandlers/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD;AAED,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/attachmentHandlers/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD;AAED,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EACL,OAAO,IAAI,qBAAqB,EAChC,aAAa,GACd,MAAM,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../../../src/translation/resources/i18n.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../../../src/translation/resources/i18n.ts"],"names":[],"mappings":";;;AAqCA,wBAEE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type AttachmentType = 'image' | 'video' | 'file' | 'audio';
|
|
1
|
+
export type AttachmentType = 'image' | 'video' | 'file' | 'audio' | 'document';
|
|
2
2
|
export interface BaseAttachment {
|
|
3
3
|
id: string;
|
|
4
4
|
type: AttachmentType;
|
|
@@ -69,4 +69,25 @@ export interface AttachmentSendResult {
|
|
|
69
69
|
mergedMessageId?: string;
|
|
70
70
|
errors: Record<string, string>;
|
|
71
71
|
}
|
|
72
|
+
interface AttachmentMetadata {
|
|
73
|
+
id?: string;
|
|
74
|
+
path: string;
|
|
75
|
+
filename?: string;
|
|
76
|
+
size?: number;
|
|
77
|
+
duration?: number;
|
|
78
|
+
mimeType?: string;
|
|
79
|
+
width?: number;
|
|
80
|
+
height?: number;
|
|
81
|
+
uri?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface AttachmentItem {
|
|
84
|
+
metadata: AttachmentMetadata;
|
|
85
|
+
uploadProgress: number;
|
|
86
|
+
error: string | null;
|
|
87
|
+
isUploading: boolean;
|
|
88
|
+
uploadedUrl?: string;
|
|
89
|
+
thumbnailUrl?: string;
|
|
90
|
+
type: AttachmentType;
|
|
91
|
+
}
|
|
92
|
+
export {};
|
|
72
93
|
//# sourceMappingURL=attachment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../../../src/types/attachment.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../../../src/types/attachment.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
export interface PickedFile {
|
|
2
|
+
uri: string;
|
|
3
|
+
name: string;
|
|
4
|
+
size: number;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
}
|
|
1
7
|
declare const DeviceUtils: {
|
|
2
8
|
openImagePicker: (multiple?: boolean) => Promise<(import("react-native-image-crop-picker").Image & any[]) | (import("react-native-image-crop-picker").Video & any[]) | import("react-native-image-crop-picker").ImageOrVideo[]>;
|
|
3
9
|
openVideoPicker: (multiple?: boolean) => Promise<(import("react-native-image-crop-picker").Video & any[]) | import("react-native-image-crop-picker").Video[]>;
|
|
10
|
+
openFilePicker: (multiple?: boolean) => Promise<PickedFile[] | null>;
|
|
4
11
|
};
|
|
5
12
|
export default DeviceUtils;
|
|
6
13
|
export { DeviceUtils };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../../../src/utils/device.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../../../src/utils/device.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,QAAA,MAAM,WAAW;iCACmB,OAAO;iCAmCP,OAAO;gCAkC7B,OAAO,KAChB,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC;CAyChC,CAAC;AAEF,eAAe,WAAW,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -3,6 +3,7 @@ export declare const generateUUID: () => string;
|
|
|
3
3
|
export declare const isVideoFile: (filename: string | undefined) => boolean;
|
|
4
4
|
export declare const isVideoFromPicker: (pickedItem: any) => boolean;
|
|
5
5
|
export declare const getMimeType: (fileName: string) => string;
|
|
6
|
+
export declare const getFileIcon: (mimeType?: string) => number;
|
|
6
7
|
export declare const formatFileSize: (bytes: number) => string;
|
|
7
8
|
export declare const validateImageFile: (file: ImageFile) => string | null;
|
|
8
9
|
export declare const getImageUploadEndpoint: (baseUrl: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageUtils.d.ts","sourceRoot":"","sources":["../../../../src/utils/imageUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"imageUtils.d.ts","sourceRoot":"","sources":["../../../../src/utils/imageUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,eAAO,MAAM,YAAY,QAAO,MAE/B,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,UAAU,MAAM,GAAG,SAAS,KAAG,OAI1D,CAAC;AAGF,eAAO,MAAM,iBAAiB,GAAI,YAAY,GAAG,KAAG,OAInD,CAAC;AA+BF,eAAO,MAAM,WAAW,GAAI,UAAU,MAAM,KAAG,MAG9C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,WAAW,MAAM,KAAG,MAkB/C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,KAAG,MAM9C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,KAAG,MAAM,GAAG,IAmB5D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,SAAS,MAAM,KAAG,MAExD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"videoThumbnail.d.ts","sourceRoot":"","sources":["../../../../src/utils/videoThumbnail.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"videoThumbnail.d.ts","sourceRoot":"","sources":["../../../../src/utils/videoThumbnail.ts"],"names":[],"mappings":"AAIA,UAAU,gBAAgB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AA4DD,eAAO,MAAM,kBAAkB;mCAEhB,MAAM,YACR,gBAAgB,KACxB,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;sCA6DM,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;0CAWhD,MAAM,EAAE,YACX,gBAAgB,KACxB,OAAO,CAAC,eAAe,EAAE,CAAC;CAe9B,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@droppii-org/chat-mobile",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.18",
|
|
4
4
|
"description": "Droppii chat mobile",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"@eslint/js": "^10.0.1",
|
|
86
86
|
"@growthbook/growthbook-react": "*",
|
|
87
87
|
"@jest/globals": "^30.0.0",
|
|
88
|
+
"@react-native-documents/picker": "^12.0.1",
|
|
88
89
|
"@react-native/babel-preset": "0.85.0",
|
|
89
90
|
"@react-native/eslint-config": "0.85.0",
|
|
90
91
|
"@react-native/jest-preset": "0.85.0",
|
|
@@ -112,6 +113,7 @@
|
|
|
112
113
|
"react-native-builder-bob": "^0.41.0",
|
|
113
114
|
"react-native-create-thumbnail": "^2.2.0",
|
|
114
115
|
"react-native-device-info": "*",
|
|
116
|
+
"react-native-file-viewer": "^2.1.5",
|
|
115
117
|
"react-native-gesture-handler": "^3.0.0",
|
|
116
118
|
"react-native-image-crop-picker": "^0.51.1",
|
|
117
119
|
"react-native-keyboard-controller": "1.19.0",
|
|
@@ -134,11 +136,13 @@
|
|
|
134
136
|
},
|
|
135
137
|
"peerDependencies": {
|
|
136
138
|
"@droppii/libs": "*",
|
|
139
|
+
"@react-native-documents/picker": "*",
|
|
137
140
|
"@tanstack/react-query": "*",
|
|
138
141
|
"react": "*",
|
|
139
142
|
"react-native": "*",
|
|
140
143
|
"react-native-blob-util": "*",
|
|
141
144
|
"react-native-create-thumbnail": "*",
|
|
145
|
+
"react-native-file-viewer": "*",
|
|
142
146
|
"react-native-gesture-handler": "*",
|
|
143
147
|
"react-native-gifted-chat": "*",
|
|
144
148
|
"react-native-image-crop-picker": "*",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
const Images = {
|
|
2
2
|
ICON_BOT: require('./icon_bot.png'),
|
|
3
|
+
ICON_EXCEL: require('./icon_excel.png'),
|
|
4
|
+
ICON_IMG: require('./icon_img.png'),
|
|
5
|
+
ICON_PDF: require('./icon_pdf.png'),
|
|
6
|
+
ICON_TXT: require('./icon_txt.png'),
|
|
7
|
+
ICON_WORD: require('./icon_word.png'),
|
|
3
8
|
TAG_BOT: require('./tag_bot.png'),
|
|
4
9
|
TAG_MALL: require('./tag_mall.png'),
|
|
5
10
|
ICON_DROPPII: require('./icon_droppii.png'),
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { memo, useCallback } from 'react';
|
|
2
|
+
import { ActivityIndicator, StyleSheet } from 'react-native';
|
|
3
|
+
import { KContainer, KImage, KLabel, KColors } from '@droppii/libs';
|
|
4
|
+
import FileViewer from 'react-native-file-viewer';
|
|
5
|
+
import UIUtils from '../../utils/ui';
|
|
6
|
+
import { trans } from '../../translation';
|
|
7
|
+
import { formatFileSize, getFileIcon } from '../../utils/imageUtils';
|
|
8
|
+
import type { AttachmentItem } from '../../types/attachment';
|
|
9
|
+
|
|
10
|
+
export const FilePreview = memo(
|
|
11
|
+
({
|
|
12
|
+
file,
|
|
13
|
+
onRemove,
|
|
14
|
+
}: {
|
|
15
|
+
file: AttachmentItem;
|
|
16
|
+
onRemove: (id: string) => void;
|
|
17
|
+
}) => {
|
|
18
|
+
const handlePress = useCallback(async () => {
|
|
19
|
+
if (file.isUploading || file.error) return;
|
|
20
|
+
try {
|
|
21
|
+
const path = file.metadata.uri?.startsWith('file://')
|
|
22
|
+
? file.metadata.uri.slice(7)
|
|
23
|
+
: file.metadata.uri;
|
|
24
|
+
await FileViewer.open(path ?? '', {
|
|
25
|
+
showOpenWithDialog: true,
|
|
26
|
+
showAppsSuggestions: true,
|
|
27
|
+
});
|
|
28
|
+
} catch {
|
|
29
|
+
UIUtils.toast.open({
|
|
30
|
+
title: trans('chat:file_preview_unsupported'),
|
|
31
|
+
theme: 'warning',
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}, [file]);
|
|
35
|
+
|
|
36
|
+
const handleRemove = useCallback(() => {
|
|
37
|
+
onRemove(file.metadata.id ?? '');
|
|
38
|
+
}, [file.metadata?.id, onRemove]);
|
|
39
|
+
|
|
40
|
+
const iconSource = getFileIcon(file.metadata.mimeType);
|
|
41
|
+
const hasError = !!file.error;
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<KContainer.Touchable
|
|
45
|
+
row
|
|
46
|
+
alignItems
|
|
47
|
+
width={160}
|
|
48
|
+
onPress={handlePress}
|
|
49
|
+
br="3x"
|
|
50
|
+
background={
|
|
51
|
+
!hasError
|
|
52
|
+
? KColors.hexToRgba(KColors.palette.gray.w400, 0.1)
|
|
53
|
+
: KColors.hexToRgba(KColors.danger.light, 0.2)
|
|
54
|
+
}
|
|
55
|
+
paddingL={'0.5rem'}
|
|
56
|
+
paddingR={'1rem'}
|
|
57
|
+
paddingV={'0.25rem'}
|
|
58
|
+
>
|
|
59
|
+
{/* File icon */}
|
|
60
|
+
<KContainer.VisibleView visible={file.isUploading}>
|
|
61
|
+
<ActivityIndicator
|
|
62
|
+
size="small"
|
|
63
|
+
color={KColors.palette.primary.w400}
|
|
64
|
+
style={styles.loader}
|
|
65
|
+
/>
|
|
66
|
+
</KContainer.VisibleView>
|
|
67
|
+
<KContainer.VisibleView visible={!file.isUploading}>
|
|
68
|
+
<KImage.Base
|
|
69
|
+
uri={iconSource}
|
|
70
|
+
style={styles.icon}
|
|
71
|
+
resizeMode="contain"
|
|
72
|
+
/>
|
|
73
|
+
</KContainer.VisibleView>
|
|
74
|
+
|
|
75
|
+
{/* File info */}
|
|
76
|
+
<KContainer.View flex>
|
|
77
|
+
<KLabel.Text
|
|
78
|
+
typo="TextSmMedium"
|
|
79
|
+
color={KColors.gray.dark}
|
|
80
|
+
numberOfLines={1}
|
|
81
|
+
ellipsizeMode="middle"
|
|
82
|
+
>
|
|
83
|
+
{file.metadata.filename}
|
|
84
|
+
</KLabel.Text>
|
|
85
|
+
<KLabel.Text
|
|
86
|
+
typo="TextXsNormal"
|
|
87
|
+
color={KColors.palette.gray.w500}
|
|
88
|
+
numberOfLines={1}
|
|
89
|
+
>
|
|
90
|
+
{hasError
|
|
91
|
+
? file.error
|
|
92
|
+
: file.isUploading
|
|
93
|
+
? `${file.uploadProgress}%`
|
|
94
|
+
: formatFileSize(file.metadata.size ?? 0)}
|
|
95
|
+
</KLabel.Text>
|
|
96
|
+
</KContainer.View>
|
|
97
|
+
|
|
98
|
+
{/* Remove button */}
|
|
99
|
+
<KContainer.Touchable
|
|
100
|
+
onPress={handleRemove}
|
|
101
|
+
center
|
|
102
|
+
width={20}
|
|
103
|
+
height={20}
|
|
104
|
+
br={'round'}
|
|
105
|
+
background={KColors.gray.dark}
|
|
106
|
+
hitSlop={8}
|
|
107
|
+
style={styles.removeBtn}
|
|
108
|
+
>
|
|
109
|
+
<KImage.VectorIcons
|
|
110
|
+
name="close"
|
|
111
|
+
provider="MaterialCommunityIcons"
|
|
112
|
+
size={18}
|
|
113
|
+
color={KColors.white}
|
|
114
|
+
/>
|
|
115
|
+
</KContainer.Touchable>
|
|
116
|
+
</KContainer.Touchable>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
FilePreview.displayName = 'FilePreview';
|
|
122
|
+
|
|
123
|
+
const styles = StyleSheet.create({
|
|
124
|
+
icon: {
|
|
125
|
+
width: 20,
|
|
126
|
+
height: 20,
|
|
127
|
+
marginRight: 7,
|
|
128
|
+
},
|
|
129
|
+
loader: {
|
|
130
|
+
marginRight: 8,
|
|
131
|
+
},
|
|
132
|
+
removeBtn: {
|
|
133
|
+
position: 'absolute',
|
|
134
|
+
right: -4,
|
|
135
|
+
top: -4,
|
|
136
|
+
},
|
|
137
|
+
});
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { KColors, KContainer, KImage, KLabel } from '@droppii/libs';
|
|
3
|
+
import type { AttachmentItem, AttachmentType } from '../../types/attachment';
|
|
4
|
+
import { StyleSheet } from 'react-native';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
item: AttachmentItem;
|
|
8
|
+
index: number;
|
|
9
|
+
onRemove(type: AttachmentType, index: number): void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const formatDuration = (seconds: number): string => {
|
|
13
|
+
const totalSecs = Math.floor(seconds);
|
|
14
|
+
const mins = Math.floor(totalSecs / 60);
|
|
15
|
+
const secs = totalSecs % 60;
|
|
16
|
+
return `${mins.toString().padStart(2, '0')}:${secs
|
|
17
|
+
.toString()
|
|
18
|
+
.padStart(2, '0')}`;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getAttachmentIcon = (type: AttachmentType): string => {
|
|
22
|
+
switch (type) {
|
|
23
|
+
case 'image':
|
|
24
|
+
return 'image';
|
|
25
|
+
case 'video':
|
|
26
|
+
return 'play-circle';
|
|
27
|
+
case 'audio':
|
|
28
|
+
return 'music';
|
|
29
|
+
case 'document':
|
|
30
|
+
return 'file-document';
|
|
31
|
+
case 'file':
|
|
32
|
+
default:
|
|
33
|
+
return 'file';
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const MediaPreview = memo(({ item, index, onRemove }: Props) => {
|
|
38
|
+
const { type, metadata, uploadProgress, error, isUploading, thumbnailUrl } =
|
|
39
|
+
item;
|
|
40
|
+
|
|
41
|
+
const isImage = type === 'image';
|
|
42
|
+
const isVideo = type === 'video';
|
|
43
|
+
const hasPreview = isImage || isVideo;
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<KContainer.View>
|
|
47
|
+
<KContainer.View style={styles.thumbnail} center>
|
|
48
|
+
{/* Video thumbnail */}
|
|
49
|
+
{isVideo && thumbnailUrl && (
|
|
50
|
+
<KImage.Base
|
|
51
|
+
uri={thumbnailUrl}
|
|
52
|
+
width={48}
|
|
53
|
+
height={48}
|
|
54
|
+
resizeMode="cover"
|
|
55
|
+
/>
|
|
56
|
+
)}
|
|
57
|
+
|
|
58
|
+
{/* Video placeholder (no thumbnail yet) */}
|
|
59
|
+
{isVideo && !thumbnailUrl && (
|
|
60
|
+
<KContainer.View style={[styles.videoBg, styles.videoThumbnail]} />
|
|
61
|
+
)}
|
|
62
|
+
|
|
63
|
+
{/* Image preview */}
|
|
64
|
+
{isImage && (
|
|
65
|
+
<KImage.Base uri={`file://${metadata.path}`} width={48} height={48} />
|
|
66
|
+
)}
|
|
67
|
+
|
|
68
|
+
{/* Show icon overlay for non-media files */}
|
|
69
|
+
{!hasPreview && (
|
|
70
|
+
<KContainer.View
|
|
71
|
+
style={styles.iconOverlay}
|
|
72
|
+
center
|
|
73
|
+
background={KColors.palette.gray.w100}
|
|
74
|
+
>
|
|
75
|
+
<KImage.VectorIcons
|
|
76
|
+
name={getAttachmentIcon(type)}
|
|
77
|
+
provider="MaterialCommunityIcons"
|
|
78
|
+
size={24}
|
|
79
|
+
color={KColors.palette.primary.w400}
|
|
80
|
+
/>
|
|
81
|
+
</KContainer.View>
|
|
82
|
+
)}
|
|
83
|
+
|
|
84
|
+
{/* Video duration badge */}
|
|
85
|
+
{isVideo && !!metadata.duration && (
|
|
86
|
+
<KContainer.View style={styles.durationBadge} center>
|
|
87
|
+
<KLabel.Text
|
|
88
|
+
typo="TextXsNormal"
|
|
89
|
+
color={KColors.white}
|
|
90
|
+
style={styles.durationText}
|
|
91
|
+
>
|
|
92
|
+
{formatDuration(metadata.duration / 1000)}
|
|
93
|
+
</KLabel.Text>
|
|
94
|
+
</KContainer.View>
|
|
95
|
+
)}
|
|
96
|
+
|
|
97
|
+
{/* Type icon for non-preview items */}
|
|
98
|
+
{!hasPreview && (
|
|
99
|
+
<KContainer.View style={styles.typeIcon} center>
|
|
100
|
+
<KImage.VectorIcons
|
|
101
|
+
name={getAttachmentIcon(type)}
|
|
102
|
+
provider="MaterialCommunityIcons"
|
|
103
|
+
size={14}
|
|
104
|
+
color={KColors.white}
|
|
105
|
+
/>
|
|
106
|
+
</KContainer.View>
|
|
107
|
+
)}
|
|
108
|
+
|
|
109
|
+
{/* Error state */}
|
|
110
|
+
{error && (
|
|
111
|
+
<KContainer.View style={styles.errorOverlay} center>
|
|
112
|
+
<KImage.VectorIcons
|
|
113
|
+
name="close-circle"
|
|
114
|
+
provider="MaterialCommunityIcons"
|
|
115
|
+
size={28}
|
|
116
|
+
color={KColors.white}
|
|
117
|
+
/>
|
|
118
|
+
</KContainer.View>
|
|
119
|
+
)}
|
|
120
|
+
|
|
121
|
+
{/* Progress overlay */}
|
|
122
|
+
{isUploading && (
|
|
123
|
+
<KContainer.View style={styles.progressOverlay} center>
|
|
124
|
+
<KLabel.Text typo="TextSmNormal" color={KColors.white}>
|
|
125
|
+
{uploadProgress}%
|
|
126
|
+
</KLabel.Text>
|
|
127
|
+
</KContainer.View>
|
|
128
|
+
)}
|
|
129
|
+
</KContainer.View>
|
|
130
|
+
{/* Remove button */}
|
|
131
|
+
<KContainer.Touchable
|
|
132
|
+
style={styles.removeButton}
|
|
133
|
+
center
|
|
134
|
+
br="round"
|
|
135
|
+
background={KColors.black}
|
|
136
|
+
onPress={() => onRemove(type, index)}
|
|
137
|
+
disabled={isUploading}
|
|
138
|
+
hitSlop={10}
|
|
139
|
+
>
|
|
140
|
+
<KImage.VectorIcons
|
|
141
|
+
name="close"
|
|
142
|
+
provider="MaterialCommunityIcons"
|
|
143
|
+
size={18}
|
|
144
|
+
color={KColors.white}
|
|
145
|
+
/>
|
|
146
|
+
</KContainer.Touchable>
|
|
147
|
+
</KContainer.View>
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
MediaPreview.displayName = 'MediaPreview';
|
|
152
|
+
|
|
153
|
+
const styles = StyleSheet.create({
|
|
154
|
+
thumbnail: {
|
|
155
|
+
position: 'relative',
|
|
156
|
+
width: 48,
|
|
157
|
+
height: 48,
|
|
158
|
+
borderRadius: 4,
|
|
159
|
+
overflow: 'hidden',
|
|
160
|
+
backgroundColor: KColors.palette.gray.w50,
|
|
161
|
+
},
|
|
162
|
+
durationBadge: {
|
|
163
|
+
position: 'absolute',
|
|
164
|
+
bottom: 4,
|
|
165
|
+
right: 4,
|
|
166
|
+
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
167
|
+
borderRadius: 3,
|
|
168
|
+
paddingVertical: 2,
|
|
169
|
+
paddingHorizontal: 4,
|
|
170
|
+
},
|
|
171
|
+
durationText: {
|
|
172
|
+
fontSize: 11,
|
|
173
|
+
fontWeight: '600',
|
|
174
|
+
},
|
|
175
|
+
iconOverlay: {
|
|
176
|
+
width: 48,
|
|
177
|
+
height: 48,
|
|
178
|
+
borderRadius: 4,
|
|
179
|
+
},
|
|
180
|
+
videoIcon: {
|
|
181
|
+
position: 'absolute',
|
|
182
|
+
top: 2,
|
|
183
|
+
right: 2,
|
|
184
|
+
backgroundColor: 'rgba(0, 0, 0, 0.6)',
|
|
185
|
+
borderRadius: 8,
|
|
186
|
+
width: 20,
|
|
187
|
+
height: 20,
|
|
188
|
+
},
|
|
189
|
+
typeIcon: {
|
|
190
|
+
position: 'absolute',
|
|
191
|
+
bottom: 2,
|
|
192
|
+
right: 2,
|
|
193
|
+
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
194
|
+
borderRadius: 6,
|
|
195
|
+
width: 16,
|
|
196
|
+
height: 16,
|
|
197
|
+
},
|
|
198
|
+
videoBg: {
|
|
199
|
+
width: 48,
|
|
200
|
+
height: 48,
|
|
201
|
+
borderRadius: 4,
|
|
202
|
+
},
|
|
203
|
+
videoThumbnail: {
|
|
204
|
+
backgroundColor: KColors.black,
|
|
205
|
+
},
|
|
206
|
+
progressOverlay: {
|
|
207
|
+
position: 'absolute',
|
|
208
|
+
top: 0,
|
|
209
|
+
left: 0,
|
|
210
|
+
right: 0,
|
|
211
|
+
bottom: 0,
|
|
212
|
+
backgroundColor: 'rgba(0, 0, 0, 0.6)',
|
|
213
|
+
},
|
|
214
|
+
errorOverlay: {
|
|
215
|
+
position: 'absolute',
|
|
216
|
+
top: 0,
|
|
217
|
+
left: 0,
|
|
218
|
+
right: 0,
|
|
219
|
+
bottom: 0,
|
|
220
|
+
backgroundColor: 'rgba(255, 59, 48, 0.8)',
|
|
221
|
+
},
|
|
222
|
+
removeButton: {
|
|
223
|
+
position: 'absolute',
|
|
224
|
+
right: -4,
|
|
225
|
+
top: -4,
|
|
226
|
+
width: 22,
|
|
227
|
+
height: 22,
|
|
228
|
+
shadowColor: '#000',
|
|
229
|
+
shadowOffset: { width: 0, height: 1 },
|
|
230
|
+
shadowOpacity: 0.2,
|
|
231
|
+
shadowRadius: 2,
|
|
232
|
+
elevation: 3,
|
|
233
|
+
},
|
|
234
|
+
sendButton: {
|
|
235
|
+
width: 48,
|
|
236
|
+
height: 48,
|
|
237
|
+
},
|
|
238
|
+
});
|