@droppii-org/chat-mobile 0.2.17 → 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.
Files changed (96) hide show
  1. package/lib/module/assets/images/icon_excel.png +0 -0
  2. package/lib/module/assets/images/icon_img.png +0 -0
  3. package/lib/module/assets/images/icon_pdf.png +0 -0
  4. package/lib/module/assets/images/icon_txt.png +0 -0
  5. package/lib/module/assets/images/icon_word.png +0 -0
  6. package/lib/module/assets/images/index.js +5 -0
  7. package/lib/module/assets/images/index.js.map +1 -1
  8. package/lib/module/components/AttachmentPreview/FilePreview.js +107 -0
  9. package/lib/module/components/AttachmentPreview/FilePreview.js.map +1 -0
  10. package/lib/module/components/AttachmentPreview/MediaPreview.js +212 -0
  11. package/lib/module/components/AttachmentPreview/MediaPreview.js.map +1 -0
  12. package/lib/module/components/AttachmentPreview/index.js +49 -0
  13. package/lib/module/components/AttachmentPreview/index.js.map +1 -0
  14. package/lib/module/components/messages/fileMessage/index.js +122 -12
  15. package/lib/module/components/messages/fileMessage/index.js.map +1 -1
  16. package/lib/module/hooks/useFileAttachment.js +116 -0
  17. package/lib/module/hooks/useFileAttachment.js.map +1 -0
  18. package/lib/module/hooks/useFileDownload.js +175 -0
  19. package/lib/module/hooks/useFileDownload.js.map +1 -0
  20. package/lib/module/index.js +1 -1
  21. package/lib/module/index.js.map +1 -1
  22. package/lib/module/screens/chat-detail/ChatComposer.js +44 -36
  23. package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
  24. package/lib/module/screens/chat-detail/hooks/useAttachmentMapping.js +51 -0
  25. package/lib/module/screens/chat-detail/hooks/useAttachmentMapping.js.map +1 -0
  26. package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js +39 -13
  27. package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js.map +1 -1
  28. package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js +6 -6
  29. package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js.map +1 -1
  30. package/lib/module/services/attachmentHandlers/index.js +1 -1
  31. package/lib/module/services/attachmentHandlers/index.js.map +1 -1
  32. package/lib/module/translation/resources/i18n.js +9 -0
  33. package/lib/module/translation/resources/i18n.js.map +1 -1
  34. package/lib/module/utils/device.js +32 -0
  35. package/lib/module/utils/device.js.map +1 -1
  36. package/lib/module/utils/imageUtils.js +44 -28
  37. package/lib/module/utils/imageUtils.js.map +1 -1
  38. package/lib/typescript/src/assets/images/index.d.ts +5 -0
  39. package/lib/typescript/src/assets/images/index.d.ts.map +1 -1
  40. package/lib/typescript/src/components/AttachmentPreview/FilePreview.d.ts +6 -0
  41. package/lib/typescript/src/components/AttachmentPreview/FilePreview.d.ts.map +1 -0
  42. package/lib/typescript/src/components/AttachmentPreview/MediaPreview.d.ts +9 -0
  43. package/lib/typescript/src/components/AttachmentPreview/MediaPreview.d.ts.map +1 -0
  44. package/lib/typescript/src/components/AttachmentPreview/index.d.ts +9 -0
  45. package/lib/typescript/src/components/AttachmentPreview/index.d.ts.map +1 -0
  46. package/lib/typescript/src/components/messages/fileMessage/index.d.ts.map +1 -1
  47. package/lib/typescript/src/hooks/useFileAttachment.d.ts +20 -0
  48. package/lib/typescript/src/hooks/useFileAttachment.d.ts.map +1 -0
  49. package/lib/typescript/src/hooks/useFileDownload.d.ts +15 -0
  50. package/lib/typescript/src/hooks/useFileDownload.d.ts.map +1 -0
  51. package/lib/typescript/src/hooks/useImageAttachment.d.ts +1 -2
  52. package/lib/typescript/src/hooks/useImageAttachment.d.ts.map +1 -1
  53. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
  54. package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentMapping.d.ts +10 -0
  55. package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentMapping.d.ts.map +1 -0
  56. package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts +4 -1
  57. package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts.map +1 -1
  58. package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts +2 -2
  59. package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts.map +1 -1
  60. package/lib/typescript/src/services/attachmentHandlers/index.d.ts +1 -1
  61. package/lib/typescript/src/services/attachmentHandlers/index.d.ts.map +1 -1
  62. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  63. package/lib/typescript/src/types/attachment.d.ts +22 -1
  64. package/lib/typescript/src/types/attachment.d.ts.map +1 -1
  65. package/lib/typescript/src/utils/device.d.ts +7 -0
  66. package/lib/typescript/src/utils/device.d.ts.map +1 -1
  67. package/lib/typescript/src/utils/imageUtils.d.ts +1 -0
  68. package/lib/typescript/src/utils/imageUtils.d.ts.map +1 -1
  69. package/package.json +5 -1
  70. package/src/assets/images/icon_excel.png +0 -0
  71. package/src/assets/images/icon_img.png +0 -0
  72. package/src/assets/images/icon_pdf.png +0 -0
  73. package/src/assets/images/icon_txt.png +0 -0
  74. package/src/assets/images/icon_word.png +0 -0
  75. package/src/assets/images/index.ts +5 -0
  76. package/src/components/AttachmentPreview/FilePreview.tsx +137 -0
  77. package/src/components/AttachmentPreview/MediaPreview.tsx +238 -0
  78. package/src/components/AttachmentPreview/index.tsx +68 -0
  79. package/src/components/messages/fileMessage/index.tsx +156 -13
  80. package/src/hooks/useFileAttachment.ts +163 -0
  81. package/src/hooks/useFileDownload.ts +200 -0
  82. package/src/hooks/useImageAttachment.ts +1 -1
  83. package/src/screens/chat-detail/ChatComposer.tsx +61 -30
  84. package/src/screens/chat-detail/hooks/useAttachmentMapping.ts +58 -0
  85. package/src/screens/chat-detail/hooks/useAttachmentSendHandler.ts +50 -11
  86. package/src/services/attachmentHandlers/fileAttachmentHandler.ts +8 -7
  87. package/src/services/attachmentHandlers/index.ts +4 -1
  88. package/src/translation/resources/i18n.ts +9 -0
  89. package/src/types/attachment.ts +23 -1
  90. package/src/utils/device.ts +58 -0
  91. package/src/utils/imageUtils.ts +50 -28
  92. package/lib/module/components/AttachmentPreview.js +0 -252
  93. package/lib/module/components/AttachmentPreview.js.map +0 -1
  94. package/lib/typescript/src/components/AttachmentPreview.d.ts +0 -28
  95. package/lib/typescript/src/components/AttachmentPreview.d.ts.map +0 -1
  96. package/src/components/AttachmentPreview.tsx +0 -310
@@ -1,252 +0,0 @@
1
- "use strict";
2
-
3
- import { memo } from 'react';
4
- import { ScrollView, StyleSheet } from 'react-native';
5
- import { KContainer, KImage, KColors, KLabel } from '@droppii/libs';
6
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
- const formatDuration = seconds => {
8
- const totalSecs = Math.floor(seconds);
9
- const mins = Math.floor(totalSecs / 60);
10
- const secs = totalSecs % 60;
11
- return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
12
- };
13
- const getAttachmentIcon = type => {
14
- switch (type) {
15
- case 'image':
16
- return 'image';
17
- case 'video':
18
- return 'play-circle';
19
- case 'audio':
20
- return 'music';
21
- case 'document':
22
- return 'file-document';
23
- case 'file':
24
- default:
25
- return 'file';
26
- }
27
- };
28
- export const AttachmentPreview = /*#__PURE__*/memo(({
29
- visible,
30
- attachments,
31
- onRemove
32
- }) => {
33
- if (!visible || !attachments?.length) {
34
- return null;
35
- }
36
- return /*#__PURE__*/_jsx(KContainer.View, {
37
- paddingH: "0.75rem"
38
- // paddingV="0.75rem"
39
- ,
40
- brW: 1,
41
- brC: KColors.palette.gray.w100,
42
- background: KColors.white,
43
- style: styles.container,
44
- children: /*#__PURE__*/_jsx(KContainer.View, {
45
- row: true,
46
- alignItems: true,
47
- minH: 70,
48
- children: /*#__PURE__*/_jsx(KContainer.View, {
49
- flex: true,
50
- children: /*#__PURE__*/_jsx(ScrollView, {
51
- horizontal: true,
52
- showsHorizontalScrollIndicator: false,
53
- scrollEventThrottle: 16,
54
- contentContainerStyle: styles.scrollContent,
55
- children: attachments.map((item, index) => {
56
- const {
57
- type,
58
- metadata,
59
- uploadProgress,
60
- error,
61
- isUploading,
62
- thumbnailUrl
63
- } = item;
64
- const isImage = type === 'image';
65
- const isVideo = type === 'video';
66
- const hasPreview = isImage || isVideo;
67
- return /*#__PURE__*/_jsxs(KContainer.View, {
68
- children: [/*#__PURE__*/_jsxs(KContainer.View, {
69
- style: styles.thumbnail,
70
- center: true,
71
- children: [isVideo && thumbnailUrl && /*#__PURE__*/_jsx(KImage.Base, {
72
- uri: thumbnailUrl,
73
- width: 48,
74
- height: 48,
75
- resizeMode: "cover"
76
- }), isVideo && !thumbnailUrl && /*#__PURE__*/_jsx(KContainer.View, {
77
- style: [styles.videoBg, styles.videoThumbnail]
78
- }), isImage && /*#__PURE__*/_jsx(KImage.Base, {
79
- uri: `file://${metadata.path}`,
80
- width: 48,
81
- height: 48
82
- }), !hasPreview && /*#__PURE__*/_jsx(KContainer.View, {
83
- style: styles.iconOverlay,
84
- center: true,
85
- background: KColors.palette.gray.w100,
86
- children: /*#__PURE__*/_jsx(KImage.VectorIcons, {
87
- name: getAttachmentIcon(type),
88
- provider: "MaterialCommunityIcons",
89
- size: 24,
90
- color: KColors.palette.primary.w400
91
- })
92
- }), isVideo && !!metadata.duration && /*#__PURE__*/_jsx(KContainer.View, {
93
- style: styles.durationBadge,
94
- center: true,
95
- children: /*#__PURE__*/_jsx(KLabel.Text, {
96
- typo: "TextXsNormal",
97
- color: KColors.white,
98
- style: styles.durationText,
99
- children: formatDuration(metadata.duration / 1000)
100
- })
101
- }), !hasPreview && /*#__PURE__*/_jsx(KContainer.View, {
102
- style: styles.typeIcon,
103
- center: true,
104
- children: /*#__PURE__*/_jsx(KImage.VectorIcons, {
105
- name: getAttachmentIcon(type),
106
- provider: "MaterialCommunityIcons",
107
- size: 14,
108
- color: KColors.white
109
- })
110
- }), error && /*#__PURE__*/_jsx(KContainer.View, {
111
- style: styles.errorOverlay,
112
- center: true,
113
- children: /*#__PURE__*/_jsx(KImage.VectorIcons, {
114
- name: "close-circle",
115
- provider: "MaterialCommunityIcons",
116
- size: 28,
117
- color: KColors.white
118
- })
119
- }), isUploading && /*#__PURE__*/_jsx(KContainer.View, {
120
- style: styles.progressOverlay,
121
- center: true,
122
- children: /*#__PURE__*/_jsxs(KLabel.Text, {
123
- typo: "TextSmNormal",
124
- color: KColors.white,
125
- children: [uploadProgress, "%"]
126
- })
127
- })]
128
- }), /*#__PURE__*/_jsx(KContainer.Touchable, {
129
- style: styles.removeButton,
130
- center: true,
131
- br: "round",
132
- background: KColors.black,
133
- onPress: () => onRemove(type, index),
134
- disabled: isUploading,
135
- hitSlop: {
136
- top: 10,
137
- bottom: 10,
138
- left: 10,
139
- right: 10
140
- },
141
- children: /*#__PURE__*/_jsx(KImage.VectorIcons, {
142
- name: "close",
143
- provider: "MaterialCommunityIcons",
144
- size: 14,
145
- color: KColors.white
146
- })
147
- })]
148
- }, `${type}-${index}`);
149
- })
150
- })
151
- })
152
- })
153
- });
154
- });
155
- AttachmentPreview.displayName = 'AttachmentPreview';
156
- const styles = StyleSheet.create({
157
- container: {
158
- // minHeight: 80,
159
- },
160
- scrollContent: {
161
- alignItems: 'center'
162
- },
163
- thumbnail: {
164
- position: 'relative',
165
- width: 48,
166
- height: 48,
167
- borderRadius: 4,
168
- overflow: 'hidden',
169
- marginRight: 8,
170
- backgroundColor: KColors.palette.gray.w50
171
- },
172
- durationBadge: {
173
- position: 'absolute',
174
- bottom: 4,
175
- right: 4,
176
- backgroundColor: 'rgba(0, 0, 0, 0.8)',
177
- borderRadius: 3,
178
- paddingVertical: 2,
179
- paddingHorizontal: 4
180
- },
181
- durationText: {
182
- fontSize: 11,
183
- fontWeight: '600'
184
- },
185
- iconOverlay: {
186
- width: 48,
187
- height: 48,
188
- borderRadius: 4
189
- },
190
- videoIcon: {
191
- position: 'absolute',
192
- top: 2,
193
- right: 2,
194
- backgroundColor: 'rgba(0, 0, 0, 0.6)',
195
- borderRadius: 8,
196
- width: 20,
197
- height: 20
198
- },
199
- typeIcon: {
200
- position: 'absolute',
201
- bottom: 2,
202
- right: 2,
203
- backgroundColor: 'rgba(0, 0, 0, 0.7)',
204
- borderRadius: 6,
205
- width: 16,
206
- height: 16
207
- },
208
- videoBg: {
209
- width: 48,
210
- height: 48,
211
- borderRadius: 4
212
- },
213
- videoThumbnail: {
214
- backgroundColor: KColors.black
215
- },
216
- progressOverlay: {
217
- position: 'absolute',
218
- top: 0,
219
- left: 0,
220
- right: 0,
221
- bottom: 0,
222
- backgroundColor: 'rgba(0, 0, 0, 0.6)'
223
- },
224
- errorOverlay: {
225
- position: 'absolute',
226
- top: 0,
227
- left: 0,
228
- right: 0,
229
- bottom: 0,
230
- backgroundColor: 'rgba(255, 59, 48, 0.8)'
231
- },
232
- removeButton: {
233
- position: 'absolute',
234
- top: -8,
235
- right: 2,
236
- width: 22,
237
- height: 22,
238
- shadowColor: '#000',
239
- shadowOffset: {
240
- width: 0,
241
- height: 1
242
- },
243
- shadowOpacity: 0.2,
244
- shadowRadius: 2,
245
- elevation: 3
246
- },
247
- sendButton: {
248
- width: 48,
249
- height: 48
250
- }
251
- });
252
- //# sourceMappingURL=AttachmentPreview.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["memo","ScrollView","StyleSheet","KContainer","KImage","KColors","KLabel","jsx","_jsx","jsxs","_jsxs","formatDuration","seconds","totalSecs","Math","floor","mins","secs","toString","padStart","getAttachmentIcon","type","AttachmentPreview","visible","attachments","onRemove","length","View","paddingH","brW","brC","palette","gray","w100","background","white","style","styles","container","children","row","alignItems","minH","flex","horizontal","showsHorizontalScrollIndicator","scrollEventThrottle","contentContainerStyle","scrollContent","map","item","index","metadata","uploadProgress","error","isUploading","thumbnailUrl","isImage","isVideo","hasPreview","thumbnail","center","Base","uri","width","height","resizeMode","videoBg","videoThumbnail","path","iconOverlay","VectorIcons","name","provider","size","color","primary","w400","duration","durationBadge","Text","typo","durationText","typeIcon","errorOverlay","progressOverlay","Touchable","removeButton","br","black","onPress","disabled","hitSlop","top","bottom","left","right","displayName","create","position","borderRadius","overflow","marginRight","backgroundColor","w50","paddingVertical","paddingHorizontal","fontSize","fontWeight","videoIcon","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation","sendButton"],"sourceRoot":"../../../src","sources":["components/AttachmentPreview.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,OAAO;AAC5B,SAASC,UAAU,EAAEC,UAAU,QAAQ,cAAc;AACrD,SAASC,UAAU,EAAEC,MAAM,EAAEC,OAAO,EAAEC,MAAM,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AA6BpE,MAAMC,cAAc,GAAIC,OAAe,IAAa;EAClD,MAAMC,SAAS,GAAGC,IAAI,CAACC,KAAK,CAACH,OAAO,CAAC;EACrC,MAAMI,IAAI,GAAGF,IAAI,CAACC,KAAK,CAACF,SAAS,GAAG,EAAE,CAAC;EACvC,MAAMI,IAAI,GAAGJ,SAAS,GAAG,EAAE;EAC3B,OAAO,GAAGG,IAAI,CAACE,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAIF,IAAI,CAC/CC,QAAQ,CAAC,CAAC,CACVC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE;AACvB,CAAC;AAED,MAAMC,iBAAiB,GAAIC,IAAoB,IAAa;EAC1D,QAAQA,IAAI;IACV,KAAK,OAAO;MACV,OAAO,OAAO;IAChB,KAAK,OAAO;MACV,OAAO,aAAa;IACtB,KAAK,OAAO;MACV,OAAO,OAAO;IAChB,KAAK,UAAU;MACb,OAAO,eAAe;IACxB,KAAK,MAAM;IACX;MACE,OAAO,MAAM;EACjB;AACF,CAAC;AAED,OAAO,MAAMC,iBAAiB,gBAAGtB,IAAI,CACnC,CAAC;EAAEuB,OAAO;EAAEC,WAAW;EAAEC;AAAiC,CAAC,KAAK;EAC9D,IAAI,CAACF,OAAO,IAAI,CAACC,WAAW,EAAEE,MAAM,EAAE;IACpC,OAAO,IAAI;E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C;IACrC+C,aAAa,EAAE,GAAG;IAClBC,YAAY,EAAE,CAAC;IACfC,SAAS,EAAE;EACb,CAAC;EACDC,UAAU,EAAE;IACVnD,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE;EACV;AACF,CAAC,CAAC","ignoreList":[]}
@@ -1,28 +0,0 @@
1
- type AttachmentType = 'image' | 'video' | 'audio' | 'document' | 'file';
2
- interface AttachmentMetadata {
3
- path: string;
4
- filename?: string;
5
- size?: number;
6
- duration?: number;
7
- mimeType?: string;
8
- width?: number;
9
- height?: number;
10
- }
11
- interface AttachmentItem {
12
- metadata: AttachmentMetadata;
13
- uploadProgress: number;
14
- error: string | null;
15
- isUploading: boolean;
16
- uploadedUrl?: string;
17
- thumbnailUrl?: string;
18
- }
19
- interface AttachmentPreviewProps {
20
- visible: boolean;
21
- attachments?: Array<AttachmentItem & {
22
- type: AttachmentType;
23
- }>;
24
- onRemove: (type: AttachmentType, index: number) => void;
25
- }
26
- export declare const AttachmentPreview: import("react").MemoExoticComponent<({ visible, attachments, onRemove }: AttachmentPreviewProps) => import("react").JSX.Element>;
27
- export {};
28
- //# sourceMappingURL=AttachmentPreview.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AttachmentPreview.d.ts","sourceRoot":"","sources":["../../../../src/components/AttachmentPreview.tsx"],"names":[],"mappings":"AAIA,KAAK,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;AAExE,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,cAAc;IACtB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,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;CACvB;AAED,UAAU,sBAAsB;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,GAAG;QAAE,IAAI,EAAE,cAAc,CAAA;KAAE,CAAC,CAAC;IAC/D,QAAQ,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzD;AA2BD,eAAO,MAAM,iBAAiB,2EACS,sBAAsB,iCA4J5D,CAAC"}
@@ -1,310 +0,0 @@
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 totalSecs = Math.floor(seconds);
34
- const mins = Math.floor(totalSecs / 60);
35
- const secs = totalSecs % 60;
36
- return `${mins.toString().padStart(2, '0')}:${secs
37
- .toString()
38
- .padStart(2, '0')}`;
39
- };
40
-
41
- const getAttachmentIcon = (type: AttachmentType): string => {
42
- switch (type) {
43
- case 'image':
44
- return 'image';
45
- case 'video':
46
- return 'play-circle';
47
- case 'audio':
48
- return 'music';
49
- case 'document':
50
- return 'file-document';
51
- case 'file':
52
- default:
53
- return 'file';
54
- }
55
- };
56
-
57
- export const AttachmentPreview = memo(
58
- ({ visible, attachments, onRemove }: AttachmentPreviewProps) => {
59
- if (!visible || !attachments?.length) {
60
- return null;
61
- }
62
-
63
- return (
64
- <KContainer.View
65
- paddingH="0.75rem"
66
- // paddingV="0.75rem"
67
- brW={1}
68
- brC={KColors.palette.gray.w100}
69
- background={KColors.white}
70
- style={styles.container}
71
- >
72
- <KContainer.View row alignItems minH={70}>
73
- <KContainer.View flex>
74
- <ScrollView
75
- horizontal
76
- showsHorizontalScrollIndicator={false}
77
- scrollEventThrottle={16}
78
- contentContainerStyle={styles.scrollContent}
79
- >
80
- {attachments.map((item, index) => {
81
- const {
82
- type,
83
- metadata,
84
- uploadProgress,
85
- error,
86
- isUploading,
87
- thumbnailUrl,
88
- } = item;
89
-
90
- const isImage = type === 'image';
91
- const isVideo = type === 'video';
92
- const hasPreview = isImage || isVideo;
93
-
94
- return (
95
- <KContainer.View key={`${type}-${index}`}>
96
- <KContainer.View style={styles.thumbnail} center>
97
- {/* Video thumbnail */}
98
- {isVideo && thumbnailUrl && (
99
- <KImage.Base
100
- uri={thumbnailUrl}
101
- width={48}
102
- height={48}
103
- resizeMode="cover"
104
- />
105
- )}
106
-
107
- {/* Video placeholder (no thumbnail yet) */}
108
- {isVideo && !thumbnailUrl && (
109
- <KContainer.View
110
- style={[styles.videoBg, styles.videoThumbnail]}
111
- />
112
- )}
113
-
114
- {/* Image preview */}
115
- {isImage && (
116
- <KImage.Base
117
- uri={`file://${metadata.path}`}
118
- width={48}
119
- height={48}
120
- />
121
- )}
122
-
123
- {/* Show icon overlay for non-media files */}
124
- {!hasPreview && (
125
- <KContainer.View
126
- style={styles.iconOverlay}
127
- center
128
- background={KColors.palette.gray.w100}
129
- >
130
- <KImage.VectorIcons
131
- name={getAttachmentIcon(type)}
132
- provider="MaterialCommunityIcons"
133
- size={24}
134
- color={KColors.palette.primary.w400}
135
- />
136
- </KContainer.View>
137
- )}
138
-
139
- {/* Video duration badge */}
140
- {isVideo && !!metadata.duration && (
141
- <KContainer.View style={styles.durationBadge} center>
142
- <KLabel.Text
143
- typo="TextXsNormal"
144
- color={KColors.white}
145
- style={styles.durationText}
146
- >
147
- {formatDuration(metadata.duration / 1000)}
148
- </KLabel.Text>
149
- </KContainer.View>
150
- )}
151
-
152
- {/* Type icon for non-preview items */}
153
- {!hasPreview && (
154
- <KContainer.View style={styles.typeIcon} center>
155
- <KImage.VectorIcons
156
- name={getAttachmentIcon(type)}
157
- provider="MaterialCommunityIcons"
158
- size={14}
159
- color={KColors.white}
160
- />
161
- </KContainer.View>
162
- )}
163
-
164
- {/* Error state */}
165
- {error && (
166
- <KContainer.View style={styles.errorOverlay} center>
167
- <KImage.VectorIcons
168
- name="close-circle"
169
- provider="MaterialCommunityIcons"
170
- size={28}
171
- color={KColors.white}
172
- />
173
- </KContainer.View>
174
- )}
175
-
176
- {/* Progress overlay */}
177
- {isUploading && (
178
- <KContainer.View style={styles.progressOverlay} center>
179
- <KLabel.Text
180
- typo="TextSmNormal"
181
- color={KColors.white}
182
- >
183
- {uploadProgress}%
184
- </KLabel.Text>
185
- </KContainer.View>
186
- )}
187
- </KContainer.View>
188
- {/* Remove button */}
189
- <KContainer.Touchable
190
- style={styles.removeButton}
191
- center
192
- br="round"
193
- background={KColors.black}
194
- onPress={() => onRemove(type, index)}
195
- disabled={isUploading}
196
- hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
197
- >
198
- <KImage.VectorIcons
199
- name="close"
200
- provider="MaterialCommunityIcons"
201
- size={14}
202
- color={KColors.white}
203
- />
204
- </KContainer.Touchable>
205
- </KContainer.View>
206
- );
207
- })}
208
- </ScrollView>
209
- </KContainer.View>
210
- </KContainer.View>
211
- </KContainer.View>
212
- );
213
- }
214
- );
215
-
216
- AttachmentPreview.displayName = 'AttachmentPreview';
217
-
218
- const styles = StyleSheet.create({
219
- container: {
220
- // minHeight: 80,
221
- },
222
- scrollContent: {
223
- alignItems: 'center',
224
- },
225
- thumbnail: {
226
- position: 'relative',
227
- width: 48,
228
- height: 48,
229
- borderRadius: 4,
230
- overflow: 'hidden',
231
- marginRight: 8,
232
- backgroundColor: KColors.palette.gray.w50,
233
- },
234
- durationBadge: {
235
- position: 'absolute',
236
- bottom: 4,
237
- right: 4,
238
- backgroundColor: 'rgba(0, 0, 0, 0.8)',
239
- borderRadius: 3,
240
- paddingVertical: 2,
241
- paddingHorizontal: 4,
242
- },
243
- durationText: {
244
- fontSize: 11,
245
- fontWeight: '600',
246
- },
247
- iconOverlay: {
248
- width: 48,
249
- height: 48,
250
- borderRadius: 4,
251
- },
252
- videoIcon: {
253
- position: 'absolute',
254
- top: 2,
255
- right: 2,
256
- backgroundColor: 'rgba(0, 0, 0, 0.6)',
257
- borderRadius: 8,
258
- width: 20,
259
- height: 20,
260
- },
261
- typeIcon: {
262
- position: 'absolute',
263
- bottom: 2,
264
- right: 2,
265
- backgroundColor: 'rgba(0, 0, 0, 0.7)',
266
- borderRadius: 6,
267
- width: 16,
268
- height: 16,
269
- },
270
- videoBg: {
271
- width: 48,
272
- height: 48,
273
- borderRadius: 4,
274
- },
275
- videoThumbnail: {
276
- backgroundColor: KColors.black,
277
- },
278
- progressOverlay: {
279
- position: 'absolute',
280
- top: 0,
281
- left: 0,
282
- right: 0,
283
- bottom: 0,
284
- backgroundColor: 'rgba(0, 0, 0, 0.6)',
285
- },
286
- errorOverlay: {
287
- position: 'absolute',
288
- top: 0,
289
- left: 0,
290
- right: 0,
291
- bottom: 0,
292
- backgroundColor: 'rgba(255, 59, 48, 0.8)',
293
- },
294
- removeButton: {
295
- position: 'absolute',
296
- top: -8,
297
- right: 2,
298
- width: 22,
299
- height: 22,
300
- shadowColor: '#000',
301
- shadowOffset: { width: 0, height: 1 },
302
- shadowOpacity: 0.2,
303
- shadowRadius: 2,
304
- elevation: 3,
305
- },
306
- sendButton: {
307
- width: 48,
308
- height: 48,
309
- },
310
- });