@droppii-org/chat-mobile 0.2.24 → 0.2.26

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 (178) hide show
  1. package/lib/module/assets/images/btn_resend.png +0 -0
  2. package/lib/module/assets/images/index.js +2 -1
  3. package/lib/module/assets/images/index.js.map +1 -1
  4. package/lib/module/components/AttachmentPreview/FilePreview.js +1 -1
  5. package/lib/module/components/AttachmentPreview/FilePreview.js.map +1 -1
  6. package/lib/module/components/flows/inputButtons/index.js +3 -6
  7. package/lib/module/components/flows/inputButtons/index.js.map +1 -1
  8. package/lib/module/components/messages/MessageStatusIndicator.js +70 -0
  9. package/lib/module/components/messages/MessageStatusIndicator.js.map +1 -0
  10. package/lib/module/components/messages/fileMessage/index.js +1 -1
  11. package/lib/module/components/messages/fileMessage/index.js.map +1 -1
  12. package/lib/module/components/messages/imageMessage/index.js +60 -51
  13. package/lib/module/components/messages/imageMessage/index.js.map +1 -1
  14. package/lib/module/components/messages/linkMessage/index.js +17 -9
  15. package/lib/module/components/messages/linkMessage/index.js.map +1 -1
  16. package/lib/module/components/messages/mergedMessage/index.js +5 -8
  17. package/lib/module/components/messages/mergedMessage/index.js.map +1 -1
  18. package/lib/module/components/messages/styles.js +12 -0
  19. package/lib/module/components/messages/styles.js.map +1 -1
  20. package/lib/module/components/messages/textMessage/index.js +20 -9
  21. package/lib/module/components/messages/textMessage/index.js.map +1 -1
  22. package/lib/module/components/messages/videoMessage/index.js +7 -11
  23. package/lib/module/components/messages/videoMessage/index.js.map +1 -1
  24. package/lib/module/config/uploadLimits.js +1 -1
  25. package/lib/module/config/uploadLimits.js.map +1 -1
  26. package/lib/module/core/useChatListener.js +35 -4
  27. package/lib/module/core/useChatListener.js.map +1 -1
  28. package/lib/module/core/useUserListener.js +17 -7
  29. package/lib/module/core/useUserListener.js.map +1 -1
  30. package/lib/module/hooks/message/useSendMessage.js +62 -15
  31. package/lib/module/hooks/message/useSendMessage.js.map +1 -1
  32. package/lib/module/hooks/useChatCompose.js +39 -28
  33. package/lib/module/hooks/useChatCompose.js.map +1 -1
  34. package/lib/module/hooks/useChatMessages.js +39 -8
  35. package/lib/module/hooks/useChatMessages.js.map +1 -1
  36. package/lib/module/hooks/useFileAttachment.js +1 -1
  37. package/lib/module/hooks/useFileAttachment.js.map +1 -1
  38. package/lib/module/hooks/useFileDownload.js +1 -1
  39. package/lib/module/hooks/useFileDownload.js.map +1 -1
  40. package/lib/module/hooks/useImageAttachment.js +12 -3
  41. package/lib/module/hooks/useImageAttachment.js.map +1 -1
  42. package/lib/module/index.js +1 -0
  43. package/lib/module/index.js.map +1 -1
  44. package/lib/module/screens/chat-detail/ChatDetail.js +24 -1
  45. package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
  46. package/lib/module/screens/chat-detail/ChatListLegend.js +40 -28
  47. package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
  48. package/lib/module/screens/chat-detail/constants.js +3 -2
  49. package/lib/module/screens/chat-detail/constants.js.map +1 -1
  50. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +48 -15
  51. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -1
  52. package/lib/module/screens/chat-detail/messageToolbox/MessageToolboxMenu.js +98 -0
  53. package/lib/module/screens/chat-detail/messageToolbox/MessageToolboxMenu.js.map +1 -0
  54. package/lib/module/screens/chat-detail/messageToolbox/MessageToolboxOverlay.js +110 -0
  55. package/lib/module/screens/chat-detail/messageToolbox/MessageToolboxOverlay.js.map +1 -0
  56. package/lib/module/screens/chat-detail/messageToolbox/MessageToolboxWrapper.js +64 -0
  57. package/lib/module/screens/chat-detail/messageToolbox/MessageToolboxWrapper.js.map +1 -0
  58. package/lib/module/screens/chat-detail/messageToolbox/messageToolbox.utils.js +37 -0
  59. package/lib/module/screens/chat-detail/messageToolbox/messageToolbox.utils.js.map +1 -0
  60. package/lib/module/screens/chat-detail/messageToolbox/types.js +4 -0
  61. package/lib/module/screens/chat-detail/messageToolbox/types.js.map +1 -0
  62. package/lib/module/services/attachmentOrchestrator.js +34 -12
  63. package/lib/module/services/attachmentOrchestrator.js.map +1 -1
  64. package/lib/module/services/message.js +13 -5
  65. package/lib/module/services/message.js.map +1 -1
  66. package/lib/module/translation/resources/i18n.js +9 -3
  67. package/lib/module/translation/resources/i18n.js.map +1 -1
  68. package/lib/module/types/chat.js.map +1 -1
  69. package/lib/module/types/global.d.js +2 -0
  70. package/lib/module/types/global.d.js.map +1 -0
  71. package/lib/module/types/index.d.js +3 -0
  72. package/lib/module/types/index.d.js.map +1 -0
  73. package/lib/module/utils/UIUtils.js +37 -0
  74. package/lib/module/utils/UIUtils.js.map +1 -0
  75. package/lib/module/utils/ui.js +15 -13
  76. package/lib/module/utils/ui.js.map +1 -1
  77. package/lib/module/utils/videoThumbnailUpload.js +1 -1
  78. package/lib/module/utils/videoThumbnailUpload.js.map +1 -1
  79. package/lib/typescript/src/assets/images/index.d.ts +1 -0
  80. package/lib/typescript/src/assets/images/index.d.ts.map +1 -1
  81. package/lib/typescript/src/components/flows/inputButtons/index.d.ts.map +1 -1
  82. package/lib/typescript/src/components/messages/MessageStatusIndicator.d.ts +9 -0
  83. package/lib/typescript/src/components/messages/MessageStatusIndicator.d.ts.map +1 -0
  84. package/lib/typescript/src/components/messages/fileMessage/index.d.ts.map +1 -1
  85. package/lib/typescript/src/components/messages/imageMessage/index.d.ts.map +1 -1
  86. package/lib/typescript/src/components/messages/linkMessage/index.d.ts +3 -8
  87. package/lib/typescript/src/components/messages/linkMessage/index.d.ts.map +1 -1
  88. package/lib/typescript/src/components/messages/mergedMessage/index.d.ts.map +1 -1
  89. package/lib/typescript/src/components/messages/styles.d.ts +15 -3
  90. package/lib/typescript/src/components/messages/styles.d.ts.map +1 -1
  91. package/lib/typescript/src/components/messages/textMessage/index.d.ts +2 -8
  92. package/lib/typescript/src/components/messages/textMessage/index.d.ts.map +1 -1
  93. package/lib/typescript/src/components/messages/videoMessage/index.d.ts.map +1 -1
  94. package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
  95. package/lib/typescript/src/core/useUserListener.d.ts.map +1 -1
  96. package/lib/typescript/src/hooks/message/useSendMessage.d.ts +2 -0
  97. package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -1
  98. package/lib/typescript/src/hooks/useChatCompose.d.ts.map +1 -1
  99. package/lib/typescript/src/hooks/useChatMessages.d.ts.map +1 -1
  100. package/lib/typescript/src/hooks/useImageAttachment.d.ts.map +1 -1
  101. package/lib/typescript/src/index.d.ts +1 -0
  102. package/lib/typescript/src/index.d.ts.map +1 -1
  103. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
  104. package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts +1 -1
  105. package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -1
  106. package/lib/typescript/src/screens/chat-detail/constants.d.ts +2 -2
  107. package/lib/typescript/src/screens/chat-detail/constants.d.ts.map +1 -1
  108. package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts +4 -5
  109. package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -1
  110. package/lib/typescript/src/screens/chat-detail/messageToolbox/MessageToolboxMenu.d.ts +11 -0
  111. package/lib/typescript/src/screens/chat-detail/messageToolbox/MessageToolboxMenu.d.ts.map +1 -0
  112. package/lib/typescript/src/screens/chat-detail/messageToolbox/MessageToolboxOverlay.d.ts +10 -0
  113. package/lib/typescript/src/screens/chat-detail/messageToolbox/MessageToolboxOverlay.d.ts.map +1 -0
  114. package/lib/typescript/src/screens/chat-detail/messageToolbox/MessageToolboxWrapper.d.ts +11 -0
  115. package/lib/typescript/src/screens/chat-detail/messageToolbox/MessageToolboxWrapper.d.ts.map +1 -0
  116. package/lib/typescript/src/screens/chat-detail/messageToolbox/messageToolbox.utils.d.ts +18 -0
  117. package/lib/typescript/src/screens/chat-detail/messageToolbox/messageToolbox.utils.d.ts.map +1 -0
  118. package/lib/typescript/src/screens/chat-detail/messageToolbox/types.d.ts +12 -0
  119. package/lib/typescript/src/screens/chat-detail/messageToolbox/types.d.ts.map +1 -0
  120. package/lib/typescript/src/screens/chat-detail/types.d.ts +2 -0
  121. package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
  122. package/lib/typescript/src/services/attachmentOrchestrator.d.ts.map +1 -1
  123. package/lib/typescript/src/services/message.d.ts +7 -0
  124. package/lib/typescript/src/services/message.d.ts.map +1 -1
  125. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  126. package/lib/typescript/src/types/chat.d.ts +11 -0
  127. package/lib/typescript/src/types/chat.d.ts.map +1 -1
  128. package/lib/typescript/src/utils/UIUtils.d.ts +4 -0
  129. package/lib/typescript/src/utils/UIUtils.d.ts.map +1 -0
  130. package/lib/typescript/src/utils/ui.d.ts +1 -12
  131. package/lib/typescript/src/utils/ui.d.ts.map +1 -1
  132. package/package.json +4 -2
  133. package/src/assets/images/btn_resend.png +0 -0
  134. package/src/assets/images/index.ts +1 -0
  135. package/src/components/AttachmentPreview/FilePreview.tsx +1 -1
  136. package/src/components/flows/inputButtons/index.tsx +3 -5
  137. package/src/components/messages/MessageStatusIndicator.tsx +82 -0
  138. package/src/components/messages/fileMessage/index.tsx +0 -2
  139. package/src/components/messages/imageMessage/index.tsx +72 -58
  140. package/src/components/messages/linkMessage/index.tsx +16 -21
  141. package/src/components/messages/mergedMessage/index.tsx +13 -18
  142. package/src/components/messages/styles.ts +12 -0
  143. package/src/components/messages/textMessage/index.tsx +20 -20
  144. package/src/components/messages/videoMessage/index.tsx +8 -11
  145. package/src/config/uploadLimits.ts +1 -1
  146. package/src/core/useChatListener.ts +38 -4
  147. package/src/core/useUserListener.ts +17 -7
  148. package/src/hooks/message/useSendMessage.ts +103 -24
  149. package/src/hooks/useChatCompose.ts +42 -33
  150. package/src/hooks/useChatMessages.ts +54 -10
  151. package/src/hooks/useFileAttachment.ts +1 -1
  152. package/src/hooks/useFileDownload.ts +1 -1
  153. package/src/hooks/useImageAttachment.ts +13 -5
  154. package/src/index.tsx +2 -0
  155. package/src/screens/chat-detail/ChatDetail.tsx +29 -0
  156. package/src/screens/chat-detail/ChatListLegend.tsx +45 -28
  157. package/src/screens/chat-detail/constants.ts +3 -2
  158. package/src/screens/chat-detail/legend/LegendChatMessage.tsx +60 -15
  159. package/src/screens/chat-detail/messageToolbox/MessageToolboxMenu.tsx +114 -0
  160. package/src/screens/chat-detail/messageToolbox/MessageToolboxOverlay.tsx +130 -0
  161. package/src/screens/chat-detail/messageToolbox/MessageToolboxWrapper.tsx +99 -0
  162. package/src/screens/chat-detail/messageToolbox/messageToolbox.utils.ts +56 -0
  163. package/src/screens/chat-detail/messageToolbox/types.ts +13 -0
  164. package/src/screens/chat-detail/types.ts +2 -0
  165. package/src/services/attachmentOrchestrator.ts +45 -21
  166. package/src/services/message.ts +21 -4
  167. package/src/translation/resources/i18n.ts +11 -3
  168. package/src/types/chat.ts +6 -0
  169. package/src/types/global.d.ts +299 -0
  170. package/src/types/index.d.ts +1 -0
  171. package/src/utils/UIUtils.ts +31 -0
  172. package/src/utils/ui.ts +20 -16
  173. package/src/utils/videoThumbnailUpload.ts +1 -1
  174. package/lib/module/hooks/useVideoAttachment.js +0 -251
  175. package/lib/module/hooks/useVideoAttachment.js.map +0 -1
  176. package/lib/typescript/src/hooks/useVideoAttachment.d.ts +0 -29
  177. package/lib/typescript/src/hooks/useVideoAttachment.d.ts.map +0 -1
  178. package/src/hooks/useVideoAttachment.ts +0 -334
@@ -0,0 +1,299 @@
1
+ declare module 'UIUtils' {
2
+ import type { ParamListBase, NavigationProp } from '@react-navigation/native';
3
+ import type { NativeStackScreenProps } from '@react-navigation/native-stack';
4
+ import type { BottomTabScreenProps } from '@react-navigation/bottom-tabs';
5
+ import type { HeaderOptions, Layout } from '@react-navigation/elements';
6
+ import type {
7
+ KAlertProps,
8
+ KBottomSheetProps,
9
+ KHeaderNavigationProps,
10
+ KPopupProps,
11
+ KToastBarProps,
12
+ } from '@droppii/libs';
13
+ import type {
14
+ ActionSheetIOSOptions,
15
+ StyleProp,
16
+ ViewStyle,
17
+ } from 'react-native';
18
+
19
+ export interface KBottomSheetPropsEnhance extends KBottomSheetProps {
20
+ header: KBottomSheetProps['header'] & {
21
+ customRenderer?: (dismiss: () => void) => JSX.Element;
22
+ };
23
+ }
24
+
25
+ interface ScreenConfigProps {
26
+ __config: any;
27
+ }
28
+
29
+ export interface MonthPickerValue {
30
+ month?: number;
31
+ year?: number;
32
+ }
33
+
34
+ export interface KActionSheetProps extends ActionSheetIOSOptions {
35
+ callback: (index: number) => void;
36
+ }
37
+
38
+ export interface WithActionSheetProps {
39
+ open: (payload: KActionSheetProps) => void;
40
+ dismiss: () => void;
41
+ }
42
+
43
+ export interface WithAlertDialogProps {
44
+ open: (payload: KAlertProps) => void;
45
+ dismiss: () => void;
46
+ dismissAll: () => void;
47
+ }
48
+
49
+ export interface WithPopupProps {
50
+ open: (payload: KPopupProps) => void;
51
+ dismiss: () => void;
52
+ dismissAll: () => void;
53
+ }
54
+
55
+ export interface WithBottomSheetProps {
56
+ open: (payload: KBottomSheetPropsEnhance) => void;
57
+ dismiss: () => void;
58
+ }
59
+
60
+ export interface WithToastProps {
61
+ open: (
62
+ payload: KToastBarProps & { contentContainerStyle?: StyleProp<ViewStyle> }
63
+ ) => void;
64
+ dismiss: () => void;
65
+ }
66
+
67
+ export interface WithImageViewer {
68
+ open: (payload: ImageViewerParams) => void;
69
+ dismiss: () => void;
70
+ }
71
+
72
+ export interface WithModal {
73
+ open: (payload: JSX.Element) => void;
74
+ dismiss: () => void;
75
+ }
76
+
77
+ export interface IButton {
78
+ text: string;
79
+ onPress?: () => void;
80
+ skipUI?: boolean;
81
+ }
82
+
83
+ export interface IDialogParams {
84
+ title: string;
85
+ message?: string;
86
+ buttons?: Array<IButton>;
87
+ cancelIndex?: number;
88
+ icon?: any;
89
+ renderContent?: any;
90
+ ignoreStack?: boolean;
91
+ waitForDismiss?: boolean;
92
+ touchOutsideToDismiss?: boolean;
93
+ }
94
+
95
+ export type AddressLevel = 'province' | 'district' | 'ward';
96
+
97
+ export type CameraType = 'avatar' | 'identity-front' | 'identity-back';
98
+
99
+ export interface RequestCameraParams {
100
+ cameraType: CameraType;
101
+ onCaptured: (path: string) => void;
102
+ }
103
+
104
+ export interface IHeaderParams extends KHeaderNavigationProps {
105
+ onBack?: () => void;
106
+ isNested?: boolean;
107
+ }
108
+
109
+ export type Appearance = 'dark' | 'light';
110
+
111
+ export interface IModalParams {
112
+ Screen: React.ComponentType<any>;
113
+ screenProps?: any;
114
+ headerProps?: HeaderOptions & {
115
+ title?: string;
116
+ modal?: boolean;
117
+ layout?: Layout;
118
+ tintColor?: string;
119
+ noHeader?: boolean;
120
+ };
121
+ options?: {
122
+ disableGesture?: boolean;
123
+ };
124
+ }
125
+
126
+ export type NavigationBase = NavigationProp<ParamListBase, string, undefined>;
127
+
128
+ export interface StackScreenProps
129
+ extends
130
+ NativeStackScreenProps<ParamListBase, string, undefined>,
131
+ ScreenConfigProps {}
132
+
133
+ export interface TabScreenProps
134
+ extends
135
+ BottomTabScreenProps<ParamListBase, string, undefined>,
136
+ ScreenConfigProps {}
137
+
138
+ export interface TextModifiers {
139
+ fontSize?: number;
140
+ color?: string;
141
+ textCenter?: boolean;
142
+ fontFamily?: string;
143
+ fontStyle?: 'normal' | 'italic';
144
+ bold?: boolean;
145
+ letterSpacing?: number;
146
+ underline?: true;
147
+ underlineColor?: string;
148
+ textTransform?: 'none' | 'capitalize' | 'uppercase' | 'lowercase';
149
+ darkModeColor?: string;
150
+ typo?: TypographyModifiers;
151
+ textAlign?: 'center' | 'left' | 'right';
152
+ }
153
+
154
+ export interface LayoutModifiers {
155
+ flex?: number | true;
156
+ flexS?: number;
157
+ flexG?: number;
158
+ flexD?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
159
+ flexW?: 'wrap' | 'nowrap' | 'wrap-reverse';
160
+ alignItems?:
161
+ | true
162
+ | 'flex-start'
163
+ | 'flex-end'
164
+ | 'center'
165
+ | 'stretch'
166
+ | 'baseline';
167
+ alignSelf?:
168
+ | true
169
+ | 'auto'
170
+ | 'flex-start'
171
+ | 'flex-end'
172
+ | 'center'
173
+ | 'stretch'
174
+ | 'baseline';
175
+ justifyContent?:
176
+ | true
177
+ | 'flex-start'
178
+ | 'flex-end'
179
+ | 'center'
180
+ | 'space-between'
181
+ | 'space-around'
182
+ | 'space-evenly';
183
+ center?: boolean;
184
+ }
185
+
186
+ export interface SpacingModifiers {
187
+ padding?: number | string;
188
+ paddingL?: number | string;
189
+ paddingR?: number | string;
190
+ paddingT?: number | string;
191
+ paddingB?: number | string;
192
+ paddingH?: number | string;
193
+ paddingV?: number | string;
194
+ margin?: number;
195
+ marginL?: number | string | 'auto';
196
+ marginR?: number | string | 'auto';
197
+ marginT?: number | string | 'auto';
198
+ marginB?: number | string | 'auto';
199
+ marginH?: number | string | 'auto';
200
+ marginV?: number | string | 'auto';
201
+ width?: number | string;
202
+ height?: number | string;
203
+ minW?: number | string;
204
+ maxW?: number | string;
205
+ minH?: number | string;
206
+ maxH?: number | string;
207
+ sizeWH?: number;
208
+ }
209
+
210
+ export interface StylingModifiers {
211
+ background?: string;
212
+ opacity?: number;
213
+ br?: number;
214
+ brW?: number;
215
+ brC?: string;
216
+ brTL?: number;
217
+ brTR?: number;
218
+ brBL?: number;
219
+ brBR?: number;
220
+ brBW?: number;
221
+ brTW?: number;
222
+ brLW?: number;
223
+ brRW?: number;
224
+ brBC?: string;
225
+ brTC?: string;
226
+ brLC?: string;
227
+ brRC?: string;
228
+ }
229
+
230
+ export interface TestModifiers {
231
+ testID?: string;
232
+ }
233
+
234
+ export type TypographyModifiers =
235
+ | 'H1'
236
+ | 'H2'
237
+ | 'H3'
238
+ | 'H4'
239
+ | 'H5'
240
+ | 'H6'
241
+ | 'H7'
242
+ | 'B1'
243
+ | 'P1'
244
+ | 'P2'
245
+ | 'P3'
246
+ | 'S1'
247
+ | 'S2'
248
+ | 'S3'
249
+ | 'C1'
250
+ | 'C2'
251
+ | 'C3'
252
+ | 'A1'
253
+ | 'A2'
254
+ | 'A3';
255
+
256
+ export interface IProductMedia {
257
+ url?: string;
258
+ isVideo?: boolean;
259
+ }
260
+
261
+ export interface ImageViewerParams {
262
+ images: IProductMedia[];
263
+ initIndex?: number;
264
+ download?: boolean;
265
+ pagination?: boolean;
266
+ logParams?: any;
267
+ }
268
+
269
+ export type PickerType = 'all' | 'issue-place';
270
+
271
+ export interface DistrictEnhance {
272
+ wards?: Record<string, { name?: string; code?: string }>;
273
+ }
274
+
275
+ export interface ProvinceEnhance {
276
+ districts?: Record<string, DistrictEnhance>;
277
+ wards?: Record<string, { name?: string; code?: string }>;
278
+ }
279
+
280
+ export interface PickedAddress {
281
+ province: { name?: string; code?: string } | undefined;
282
+ district?: { name?: string; code?: string } | undefined;
283
+ ward: { name?: string; code?: string } | undefined;
284
+ }
285
+
286
+ export interface ImperativeProgress {
287
+ setProgress: (p: number) => void;
288
+ }
289
+
290
+ export interface InternalWebviewScreenProps {
291
+ closeVisible?: boolean;
292
+ closeColor?: string;
293
+ uri: string;
294
+ showAsYoutubePlayer?: boolean;
295
+ showNavigation?: boolean;
296
+ swipeToDismiss?: boolean;
297
+ hasEncode?: boolean;
298
+ }
299
+ }
@@ -0,0 +1 @@
1
+ /// <reference path="./global.d.ts" />
@@ -0,0 +1,31 @@
1
+ import { Alert } from 'react-native';
2
+ import type { ChatUIAdapter } from '../types/chat';
3
+
4
+ const openWithAlert = (params: { title?: string; message?: string }) => {
5
+ const { title = 'Message', message = '' } = params || {};
6
+ Alert.alert(title, message);
7
+ };
8
+
9
+ const defaultAdapter: Required<ChatUIAdapter> = {
10
+ toast: { open: openWithAlert },
11
+ alert: { open: openWithAlert },
12
+ popup: { open: openWithAlert },
13
+ };
14
+
15
+ let _adapter: ChatUIAdapter = {};
16
+
17
+ export const registerUIUtils = (adapter: ChatUIAdapter): void => {
18
+ _adapter = adapter;
19
+ };
20
+
21
+ export const UIUtils: Required<ChatUIAdapter> = {
22
+ toast: {
23
+ open: (params) => (_adapter.toast ?? defaultAdapter.toast).open(params),
24
+ },
25
+ alert: {
26
+ open: (params) => (_adapter.alert ?? defaultAdapter.alert).open(params),
27
+ },
28
+ popup: {
29
+ open: (params) => (_adapter.popup ?? defaultAdapter.popup).open(params),
30
+ },
31
+ };
package/src/utils/ui.ts CHANGED
@@ -1,19 +1,23 @@
1
- import { Alert } from 'react-native';
1
+ const hexToObject = (hex: string) => {
2
+ const [_, r = 0, g = 0, b = 0] =
3
+ /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})/i
4
+ .exec(hex)
5
+ ?.slice(0, 4)
6
+ .map((x) => parseInt(x, 16)) ?? [];
2
7
 
3
- interface ToastConfig {
4
- title?: string;
5
- message?: string;
6
- theme?: 'success' | 'danger' | 'warning' | 'info';
7
- }
8
-
9
- const UIUtils = {
10
- toast: {
11
- open: (config: ToastConfig) => {
12
- const { title = 'Message', message = '' } = config;
13
- Alert.alert(title, message);
14
- },
15
- },
8
+ return { r, g, b };
16
9
  };
17
10
 
18
- export default UIUtils;
19
- export { UIUtils };
11
+ export function opacityToSolid(
12
+ foregroundColor: string,
13
+ backgroundColor: string,
14
+ alpha: number
15
+ ) {
16
+ const fg = hexToObject(foregroundColor);
17
+ const bg = hexToObject(backgroundColor);
18
+ const r = Math.round(fg.r * alpha + bg.r * (1 - alpha));
19
+ const g = Math.round(fg.g * alpha + bg.g * (1 - alpha));
20
+ const b = Math.round(fg.b * alpha + bg.b * (1 - alpha));
21
+
22
+ return `rgb(${r}, ${g}, ${b})`;
23
+ }
@@ -1,7 +1,7 @@
1
1
  import RNFS from 'react-native-fs';
2
2
  import VideoThumbnailUtil from './videoThumbnail';
3
3
  import { ImageUploadAPI } from '../services/imageUpload';
4
- import UIUtils from './ui';
4
+ import { UIUtils } from './UIUtils';
5
5
  import type { Video as PickedVideo } from 'react-native-image-crop-picker';
6
6
  import type { ImageWithUploadStatus } from '../hooks/useImageAttachment';
7
7
 
@@ -1,251 +0,0 @@
1
- "use strict";
2
-
3
- import { useCallback, useState } from 'react';
4
- import RNFS from 'react-native-fs';
5
- import DeviceUtils from "../utils/device.js";
6
- import UIUtils from "../utils/ui.js";
7
- import { trans } from "../translation/index.js";
8
- import { getMimeType } from "../utils/imageUtils.js";
9
- import { UPLOAD_LIMITS } from "../config/uploadLimits.js";
10
- import { ImageUploadAPI } from "../services/imageUpload.js";
11
- import VideoThumbnailUtil from "../utils/videoThumbnail.js";
12
- export const useVideoAttachment = () => {
13
- const [selectedVideos, setSelectedVideos] = useState([]);
14
- const [isVideoPreviewVisible, setIsVideoPreviewVisible] = useState(false);
15
- const updateVideoStatus = useCallback((index, updates) => {
16
- setSelectedVideos(prev => {
17
- const newVideos = [...prev];
18
- if (newVideos[index]) {
19
- newVideos[index] = {
20
- ...newVideos[index],
21
- ...updates
22
- };
23
- }
24
- return newVideos;
25
- });
26
- }, []);
27
- const uploadVideo = useCallback(async (index, video) => {
28
- console.log('UploadVideo', 'Step 1: Starting upload for video', {
29
- index
30
- });
31
- let cachedFilePath = null;
32
- try {
33
- console.log('UploadVideo', 'Step 2: Updating status to uploading...');
34
- updateVideoStatus(index, {
35
- isUploading: true,
36
- error: null,
37
- uploadProgress: 0
38
- });
39
- try {
40
- console.log('UploadVideo', 'Step 3: Preparing file...', {
41
- originalPath: video.path,
42
- filename: video.filename
43
- });
44
- const ext = video.filename?.split('.').pop() || 'mp4';
45
- const fileName = `temp-video-${Date.now()}-${index}.${ext}`;
46
- cachedFilePath = `${RNFS.DocumentDirectoryPath}/${fileName}`;
47
- console.log('UploadVideo', 'Step 4: Copying file to cache...', {
48
- from: video.path,
49
- to: cachedFilePath
50
- });
51
- await RNFS.copyFile(video.path, cachedFilePath);
52
- console.log('UploadVideo', 'Step 5: File copied successfully');
53
- } catch (fileError) {
54
- console.error('UploadVideo', 'File copy error', fileError);
55
- throw new Error(`Failed to prepare file: ${fileError?.message || 'Unknown error'}`);
56
- }
57
- const filename = video.filename || 'video.mp4';
58
- const setProgress = progress => {
59
- try {
60
- console.log('UploadVideo', 'Progress', {
61
- percentage: progress
62
- });
63
- updateVideoStatus(index, {
64
- uploadProgress: progress
65
- });
66
- } catch (err) {
67
- console.error('UploadVideo', 'Progress update error', err);
68
- }
69
- };
70
- let uploadedVideo;
71
- try {
72
- console.log('UploadVideo', 'Step 6: Uploading to server...', {
73
- filename,
74
- size: video.size,
75
- duration: video.duration
76
- });
77
- uploadedVideo = await ImageUploadAPI.uploadImageFile({
78
- path: cachedFilePath || '',
79
- filename,
80
- size: video.size || 0,
81
- width: video.width || 0,
82
- height: video.height || 0,
83
- mime: getMimeType(filename)
84
- }, setProgress);
85
- console.log('UploadVideo', 'Step 7: Upload successful!', {
86
- url: uploadedVideo?.url
87
- });
88
- } catch (uploadError) {
89
- console.error('UploadVideo', 'Server upload error', uploadError);
90
- throw new Error(`Upload failed: ${uploadError?.message || 'Unknown error'}`);
91
- }
92
- if (!uploadedVideo?.url) {
93
- throw new Error('No URL returned from server');
94
- }
95
- console.log('UploadVideo', 'Step 8: Video upload complete');
96
-
97
- // Step 8.5: Generate and upload thumbnail (REQUIRED before ready to send)
98
- let thumbnailUrl;
99
- let thumbnailPath;
100
- let thumbnailSize;
101
- try {
102
- console.log('UploadVideo', 'Step 8.5a: Generating thumbnail...');
103
- const thumbnail = await VideoThumbnailUtil.generateThumbnail(video.path, {
104
- time: 1000,
105
- quality: 80
106
- } // time in milliseconds (1 second)
107
- );
108
- if (!thumbnail) {
109
- throw new Error('Failed to generate thumbnail from video');
110
- }
111
- thumbnailPath = thumbnail.path;
112
- console.log('✅ [UploadVideo] THUMBNAIL PATH:', thumbnail.path);
113
- console.log('UploadVideo', 'Step 8.5b: Thumbnail generated', {
114
- path: thumbnail.path,
115
- width: thumbnail.width,
116
- height: thumbnail.height
117
- });
118
- console.log('UploadVideo', 'Step 8.5c: Uploading thumbnail...');
119
- const uploadedThumbnail = await ImageUploadAPI.uploadImageFile({
120
- path: thumbnail.path,
121
- filename: `thumb-${filename}`,
122
- size: 0,
123
- width: thumbnail.width || 320,
124
- height: thumbnail.height || 180,
125
- mime: 'image/jpeg'
126
- }, progress => {
127
- console.log('UploadVideo', 'Thumbnail upload progress', {
128
- percentage: progress
129
- });
130
- });
131
- if (!uploadedThumbnail?.url) {
132
- throw new Error('Thumbnail URL not returned from server');
133
- }
134
- thumbnailUrl = uploadedThumbnail.url;
135
- thumbnailSize = uploadedThumbnail.size || 0;
136
- console.log('✅ [UploadVideo] THUMBNAIL URL READY:', thumbnailUrl);
137
- console.log('UploadVideo', 'Step 8.5d: Thumbnail uploaded', {
138
- url: thumbnailUrl,
139
- size: `${thumbnailSize} bytes`
140
- });
141
- } catch (thumbError) {
142
- const errorMsg = thumbError?.message || 'Failed to generate/upload thumbnail';
143
- console.error('❌ [UploadVideo] THUMBNAIL ERROR:', errorMsg);
144
- throw new Error(errorMsg);
145
- }
146
- console.log('UploadVideo', 'Step 9: Preparing data...');
147
- updateVideoStatus(index, {
148
- isUploading: false,
149
- uploadProgress: 100,
150
- uploadedUrl: uploadedVideo.url,
151
- thumbnailUrl,
152
- thumbnailPath,
153
- thumbnailSize
154
- });
155
- console.log('UploadVideo', 'Step 10: Ready to send - waiting for user confirmation');
156
- console.log('UploadVideo', 'Step 11: Cleaning up cache files...');
157
- try {
158
- if (cachedFilePath) {
159
- await ImageUploadAPI.cleanupImageFile(cachedFilePath);
160
- }
161
- if (thumbnailPath) {
162
- await VideoThumbnailUtil.cleanupThumbnail(thumbnailPath);
163
- }
164
- } catch (cleanupError) {
165
- console.warn('UploadVideo', 'Cleanup warning', cleanupError);
166
- }
167
- console.log('UploadVideo', 'Step 12: COMPLETE ✓');
168
- } catch (error) {
169
- console.error('UploadVideo', 'ERROR', error);
170
- const errorMsg = error?.message || trans('chat:video_upload_failed');
171
- updateVideoStatus(index, {
172
- isUploading: false,
173
- error: errorMsg
174
- });
175
- try {
176
- if (cachedFilePath) {
177
- await ImageUploadAPI.cleanupImageFile(cachedFilePath);
178
- }
179
- } catch (cleanupError) {
180
- console.warn('UploadVideo', 'Cleanup after error', cleanupError);
181
- }
182
- console.error('uploadVideo', 'Full error', error);
183
- }
184
- }, [updateVideoStatus]);
185
- const handleVideoAttach = useCallback(async () => {
186
- console.log('VideoAttach', 'Step 1: User tapped video attachment button');
187
- try {
188
- console.log('VideoAttach', 'Step 2: Opening video picker...');
189
- const videos = await DeviceUtils.openVideoPicker();
190
- if (!videos || videos.length === 0) {
191
- console.log('VideoAttach', 'Step 3: User cancelled picker');
192
- return;
193
- }
194
- console.log('VideoAttach', 'Step 4: Videos picked', {
195
- count: videos.length
196
- });
197
- const oversizedVideos = videos.filter(vid => (vid.size || 0) > UPLOAD_LIMITS.video);
198
- if (oversizedVideos.length > 0) {
199
- console.warn('VideoAttach', 'Step 5: Some videos too large', {
200
- count: oversizedVideos.length,
201
- maxSize: UPLOAD_LIMITS.video
202
- });
203
- UIUtils.toast.open({
204
- title: trans('chat:video_too_large'),
205
- theme: 'danger'
206
- });
207
- const validVideos = videos.filter(vid => (vid.size || 0) <= UPLOAD_LIMITS.video);
208
- if (validVideos.length === 0) return;
209
- videos.splice(0, videos.length, ...validVideos);
210
- }
211
- console.log('VideoAttach', 'Step 6: Size validation passed');
212
- const startIndex = selectedVideos.length;
213
- console.log('VideoAttach', 'Step 7: Adding to preview list', {
214
- count: videos.length,
215
- startIndex
216
- });
217
- setSelectedVideos(prev => [...prev, ...videos.map(video => ({
218
- type: 'video',
219
- video,
220
- uploadProgress: 0,
221
- error: null,
222
- isUploading: true
223
- }))]);
224
- setIsVideoPreviewVisible(true);
225
- console.log('VideoAttach', 'Step 8: Starting uploads...');
226
- await Promise.all(videos.map((video, offset) => uploadVideo(startIndex + offset, video)));
227
- } catch (error) {
228
- console.error('VideoAttach', 'ERROR', error);
229
- UIUtils.toast.open({
230
- title: trans('chat:video_pick_failed'),
231
- message: error instanceof Error ? error.message : 'Unknown error',
232
- theme: 'danger'
233
- });
234
- }
235
- }, [selectedVideos.length, uploadVideo]);
236
- const handleVideoRemove = useCallback(index => {
237
- setSelectedVideos(prev => prev.filter((_, i) => i !== index));
238
- }, []);
239
- const clearAllVideos = useCallback(() => {
240
- setSelectedVideos([]);
241
- setIsVideoPreviewVisible(false);
242
- }, []);
243
- return {
244
- selectedVideos,
245
- isVideoPreviewVisible,
246
- handleVideoAttach,
247
- handleVideoRemove,
248
- clearAllVideos
249
- };
250
- };
251
- //# sourceMappingURL=useVideoAttachment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useCallback","useState","RNFS","DeviceUtils","UIUtils","trans","getMimeType","UPLOAD_LIMITS","ImageUploadAPI","VideoThumbnailUtil","useVideoAttachment","selectedVideos","setSelectedVideos","isVideoPreviewVisible","setIsVideoPreviewVisible","updateVideoStatus","index","updates","prev","newVideos","uploadVideo","video","console","log","cachedFilePath","isUploading","error","uploadProgress","originalPath","path","filename","ext","split","pop","fileName","Date","now","DocumentDirectoryPath","from","to","copyFile","fileError","Error","message","setProgress","progress","percentage","err","uploadedVideo","size","duration","uploadImageFile","width","height","mime","url","uploadError","thumbnailUrl","thumbnailPath","thumbnailSize","thumbnail","generateThumbnail","time","quality","uploadedThumbnail","thumbError","errorMsg","uploadedUrl","cleanupImageFile","cleanupThumbnail","cleanupError","warn","handleVideoAttach","videos","openVideoPicker","length","count","oversizedVideos","filter","vid","maxSize","toast","open","title","theme","validVideos","splice","startIndex","map","type","Promise","all","offset","handleVideoRemove","_","i","clearAllVideos"],"sourceRoot":"../../../src","sources":["hooks/useVideoAttachment.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AAC7C,OAAOC,IAAI,MAAM,iBAAiB;AAClC,OAAOC,WAAW,MAAM,oBAAiB;AACzC,OAAOC,OAAO,MAAM,gBAAa;AACjC,SAASC,KAAK,QAAQ,yBAAgB;AACtC,SAASC,WAAW,QAAQ,wBAAqB;AACjD,SAASC,aAAa,Q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O,CAAC6E,KAAK,CAACC,IAAI,CAAC;QACjBC,KAAK,EAAE9E,KAAK,CAAC,wBAAwB,CAAC;QACtCsC,OAAO,EAAEjB,KAAK,YAAYgB,KAAK,GAAGhB,KAAK,CAACiB,OAAO,GAAG,eAAe;QACjEyC,KAAK,EAAE;MACT,CAAC,CAAC;IACJ;EACF,CAAC,EAAE,CAACzE,cAAc,CAACgE,MAAM,EAAEvD,WAAW,CAAC,CAAC;EAExC,MAAMyE,iBAAiB,GAAG7F,WAAW,CAAEgB,KAAa,IAAK;IACvDJ,iBAAiB,CAAEM,IAAI,IAAKA,IAAI,CAAC4D,MAAM,CAAC,CAACgB,CAAC,EAAEC,CAAC,KAAKA,CAAC,KAAK/E,KAAK,CAAC,CAAC;EACjE,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMgF,cAAc,GAAGhG,WAAW,CAAC,MAAM;IACvCY,iBAAiB,CAAC,EAAE,CAAC;IACrBE,wBAAwB,CAAC,KAAK,CAAC;EACjC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACLH,cAAc;IACdE,qBAAqB;IACrB2D,iBAAiB;IACjBqB,iBAAiB;IACjBG;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -1,29 +0,0 @@
1
- interface PickedVideo {
2
- path: string;
3
- filename?: string;
4
- size?: number;
5
- width?: number;
6
- height?: number;
7
- duration?: number;
8
- }
9
- interface VideoWithUploadStatus {
10
- type: 'video';
11
- video: PickedVideo;
12
- uploadProgress: number;
13
- error: string | null;
14
- isUploading: boolean;
15
- uploadedUrl?: string;
16
- thumbnailUrl?: string;
17
- thumbnailPath?: string;
18
- thumbnailSize?: number;
19
- }
20
- export interface UseVideoAttachmentReturn {
21
- selectedVideos: VideoWithUploadStatus[];
22
- isVideoPreviewVisible: boolean;
23
- handleVideoAttach: () => Promise<void>;
24
- handleVideoRemove: (index: number) => void;
25
- clearAllVideos: () => void;
26
- }
27
- export declare const useVideoAttachment: () => UseVideoAttachmentReturn;
28
- export {};
29
- //# sourceMappingURL=useVideoAttachment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useVideoAttachment.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useVideoAttachment.ts"],"names":[],"mappings":"AAUA,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,qBAAqB;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,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;IACvB,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,wBAsSrC,CAAC"}