@ethora/chat-component-rn 26.7.4 → 26.7.5

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 (288) hide show
  1. package/CHANGELOG.md +0 -54
  2. package/README.md +8 -31
  3. package/lib/commonjs/assets/icons.js +2 -7
  4. package/lib/commonjs/assets/icons.js.map +1 -1
  5. package/lib/commonjs/components/Header/HeaderRoomList.js +6 -20
  6. package/lib/commonjs/components/Header/HeaderRoomList.js.map +1 -1
  7. package/lib/commonjs/components/MainComponents/ChatRoom.js +14 -36
  8. package/lib/commonjs/components/MainComponents/ChatRoom.js.map +1 -1
  9. package/lib/commonjs/components/MainComponents/MessageList.js +23 -7
  10. package/lib/commonjs/components/MainComponents/MessageList.js.map +1 -1
  11. package/lib/commonjs/components/MainComponents/ProfileImagePlaceholder.js +13 -14
  12. package/lib/commonjs/components/MainComponents/ProfileImagePlaceholder.js.map +1 -1
  13. package/lib/commonjs/components/MainComponents/RoomList.js +32 -62
  14. package/lib/commonjs/components/MainComponents/RoomList.js.map +1 -1
  15. package/lib/commonjs/components/Menu/HeaderRoomListMenu.js +98 -309
  16. package/lib/commonjs/components/Menu/HeaderRoomListMenu.js.map +1 -1
  17. package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js +110 -320
  18. package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
  19. package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js +213 -552
  20. package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
  21. package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js +2 -6
  22. package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
  23. package/lib/commonjs/components/Modals/Modal/Modal.js +0 -8
  24. package/lib/commonjs/components/Modals/Modal/Modal.js.map +1 -1
  25. package/lib/commonjs/components/Modals/NewChatModal/ModalContent.js +1 -2
  26. package/lib/commonjs/components/Modals/NewChatModal/ModalContent.js.map +1 -1
  27. package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js +104 -202
  28. package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
  29. package/lib/commonjs/components/Modals/NewChatModal/UpdNewChatModal.js +0 -8
  30. package/lib/commonjs/components/Modals/NewChatModal/UpdNewChatModal.js.map +1 -1
  31. package/lib/commonjs/components/Modals/SelectUsersModal/SelectUsersModal.js +2 -4
  32. package/lib/commonjs/components/Modals/SelectUsersModal/SelectUsersModal.js.map +1 -1
  33. package/lib/commonjs/components/Modals/UserProfileModal/EditUserModal.js +21 -7
  34. package/lib/commonjs/components/Modals/UserProfileModal/EditUserModal.js.map +1 -1
  35. package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js +244 -507
  36. package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
  37. package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js +46 -74
  38. package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
  39. package/lib/commonjs/components/Modals/styledModalComponents.js +2 -9
  40. package/lib/commonjs/components/Modals/styledModalComponents.js.map +1 -1
  41. package/lib/commonjs/components/RoomComponents/ChatRoomItem.js +7 -17
  42. package/lib/commonjs/components/RoomComponents/ChatRoomItem.js.map +1 -1
  43. package/lib/commonjs/components/styled/SendInput.js +11 -80
  44. package/lib/commonjs/components/styled/SendInput.js.map +1 -1
  45. package/lib/commonjs/components/styled/StyledComponents.js +3 -9
  46. package/lib/commonjs/components/styled/StyledComponents.js.map +1 -1
  47. package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js +4 -11
  48. package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
  49. package/lib/commonjs/context/xmppProvider.js +35 -6
  50. package/lib/commonjs/context/xmppProvider.js.map +1 -1
  51. package/lib/commonjs/helpers/updateMessagesTillLast.js +40 -12
  52. package/lib/commonjs/helpers/updateMessagesTillLast.js.map +1 -1
  53. package/lib/commonjs/hooks/useChatRoomFocus.js +9 -3
  54. package/lib/commonjs/hooks/useChatRoomFocus.js.map +1 -1
  55. package/lib/commonjs/hooks/useLogout.js +5 -0
  56. package/lib/commonjs/hooks/useLogout.js.map +1 -1
  57. package/lib/commonjs/hooks/useSendMessage.js +50 -23
  58. package/lib/commonjs/hooks/useSendMessage.js.map +1 -1
  59. package/lib/commonjs/i18n/strings.js +1 -121
  60. package/lib/commonjs/i18n/strings.js.map +1 -1
  61. package/lib/commonjs/main.js +0 -6
  62. package/lib/commonjs/main.js.map +1 -1
  63. package/lib/commonjs/networking/api-requests/user.api.js +0 -59
  64. package/lib/commonjs/networking/api-requests/user.api.js.map +1 -1
  65. package/lib/commonjs/networking/outboundQueue.js +18 -0
  66. package/lib/commonjs/networking/outboundQueue.js.map +1 -1
  67. package/lib/commonjs/networking/stanzaHandlers.js +10 -1
  68. package/lib/commonjs/networking/stanzaHandlers.js.map +1 -1
  69. package/lib/commonjs/networking/xmppClient.js +107 -7
  70. package/lib/commonjs/networking/xmppClient.js.map +1 -1
  71. package/lib/commonjs/roomStore/chatSettingsSlice.js +1 -3
  72. package/lib/commonjs/roomStore/chatSettingsSlice.js.map +1 -1
  73. package/lib/commonjs/roomStore/roomsSlice.js +22 -3
  74. package/lib/commonjs/roomStore/roomsSlice.js.map +1 -1
  75. package/lib/module/assets/icons.js +1 -6
  76. package/lib/module/assets/icons.js.map +1 -1
  77. package/lib/module/components/Header/HeaderRoomList.js +6 -20
  78. package/lib/module/components/Header/HeaderRoomList.js.map +1 -1
  79. package/lib/module/components/MainComponents/ChatRoom.js +14 -36
  80. package/lib/module/components/MainComponents/ChatRoom.js.map +1 -1
  81. package/lib/module/components/MainComponents/MessageList.js +24 -8
  82. package/lib/module/components/MainComponents/MessageList.js.map +1 -1
  83. package/lib/module/components/MainComponents/ProfileImagePlaceholder.js +13 -14
  84. package/lib/module/components/MainComponents/ProfileImagePlaceholder.js.map +1 -1
  85. package/lib/module/components/MainComponents/RoomList.js +32 -62
  86. package/lib/module/components/MainComponents/RoomList.js.map +1 -1
  87. package/lib/module/components/Menu/HeaderRoomListMenu.js +101 -311
  88. package/lib/module/components/Menu/HeaderRoomListMenu.js.map +1 -1
  89. package/lib/module/components/Modals/AttachSheet/AttachSheet.js +113 -311
  90. package/lib/module/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
  91. package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js +217 -555
  92. package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
  93. package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js +2 -6
  94. package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
  95. package/lib/module/components/Modals/Modal/Modal.js +1 -9
  96. package/lib/module/components/Modals/Modal/Modal.js.map +1 -1
  97. package/lib/module/components/Modals/NewChatModal/ModalContent.js +1 -2
  98. package/lib/module/components/Modals/NewChatModal/ModalContent.js.map +1 -1
  99. package/lib/module/components/Modals/NewChatModal/NewChatModal.js +106 -205
  100. package/lib/module/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
  101. package/lib/module/components/Modals/NewChatModal/UpdNewChatModal.js +0 -8
  102. package/lib/module/components/Modals/NewChatModal/UpdNewChatModal.js.map +1 -1
  103. package/lib/module/components/Modals/SelectUsersModal/SelectUsersModal.js +2 -4
  104. package/lib/module/components/Modals/SelectUsersModal/SelectUsersModal.js.map +1 -1
  105. package/lib/module/components/Modals/UserProfileModal/EditUserModal.js +23 -9
  106. package/lib/module/components/Modals/UserProfileModal/EditUserModal.js.map +1 -1
  107. package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js +248 -509
  108. package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
  109. package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js +48 -76
  110. package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
  111. package/lib/module/components/Modals/styledModalComponents.js +2 -9
  112. package/lib/module/components/Modals/styledModalComponents.js.map +1 -1
  113. package/lib/module/components/RoomComponents/ChatRoomItem.js +7 -17
  114. package/lib/module/components/RoomComponents/ChatRoomItem.js.map +1 -1
  115. package/lib/module/components/styled/SendInput.js +12 -81
  116. package/lib/module/components/styled/SendInput.js.map +1 -1
  117. package/lib/module/components/styled/StyledComponents.js +3 -9
  118. package/lib/module/components/styled/StyledComponents.js.map +1 -1
  119. package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js +4 -11
  120. package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
  121. package/lib/module/context/xmppProvider.js +35 -6
  122. package/lib/module/context/xmppProvider.js.map +1 -1
  123. package/lib/module/helpers/updateMessagesTillLast.js +41 -13
  124. package/lib/module/helpers/updateMessagesTillLast.js.map +1 -1
  125. package/lib/module/hooks/useChatRoomFocus.js +9 -3
  126. package/lib/module/hooks/useChatRoomFocus.js.map +1 -1
  127. package/lib/module/hooks/useLogout.js +5 -0
  128. package/lib/module/hooks/useLogout.js.map +1 -1
  129. package/lib/module/hooks/useSendMessage.js +51 -24
  130. package/lib/module/hooks/useSendMessage.js.map +1 -1
  131. package/lib/module/i18n/strings.js +1 -121
  132. package/lib/module/i18n/strings.js.map +1 -1
  133. package/lib/module/main.js +1 -1
  134. package/lib/module/main.js.map +1 -1
  135. package/lib/module/networking/api-requests/user.api.js +0 -56
  136. package/lib/module/networking/api-requests/user.api.js.map +1 -1
  137. package/lib/module/networking/outboundQueue.js +17 -0
  138. package/lib/module/networking/outboundQueue.js.map +1 -1
  139. package/lib/module/networking/stanzaHandlers.js +10 -1
  140. package/lib/module/networking/stanzaHandlers.js.map +1 -1
  141. package/lib/module/networking/xmppClient.js +107 -7
  142. package/lib/module/networking/xmppClient.js.map +1 -1
  143. package/lib/module/roomStore/chatSettingsSlice.js +1 -3
  144. package/lib/module/roomStore/chatSettingsSlice.js.map +1 -1
  145. package/lib/module/roomStore/roomsSlice.js +20 -2
  146. package/lib/module/roomStore/roomsSlice.js.map +1 -1
  147. package/lib/typescript/assets/icons.d.ts +0 -16
  148. package/lib/typescript/assets/icons.d.ts.map +1 -1
  149. package/lib/typescript/components/Header/HeaderRoomList.d.ts.map +1 -1
  150. package/lib/typescript/components/MainComponents/ChatRoom.d.ts.map +1 -1
  151. package/lib/typescript/components/MainComponents/MessageList.d.ts.map +1 -1
  152. package/lib/typescript/components/MainComponents/ProfileImagePlaceholder.d.ts.map +1 -1
  153. package/lib/typescript/components/MainComponents/RoomList.d.ts.map +1 -1
  154. package/lib/typescript/components/Menu/HeaderRoomListMenu.d.ts +0 -3
  155. package/lib/typescript/components/Menu/HeaderRoomListMenu.d.ts.map +1 -1
  156. package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts +0 -9
  157. package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts.map +1 -1
  158. package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts +0 -10
  159. package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts.map +1 -1
  160. package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts.map +1 -1
  161. package/lib/typescript/components/Modals/Modal/Modal.d.ts.map +1 -1
  162. package/lib/typescript/components/Modals/NewChatModal/ModalContent.d.ts +2 -4
  163. package/lib/typescript/components/Modals/NewChatModal/ModalContent.d.ts.map +1 -1
  164. package/lib/typescript/components/Modals/NewChatModal/NewChatModal.d.ts +1 -1
  165. package/lib/typescript/components/Modals/NewChatModal/NewChatModal.d.ts.map +1 -1
  166. package/lib/typescript/components/Modals/NewChatModal/UpdNewChatModal.d.ts.map +1 -1
  167. package/lib/typescript/components/Modals/SelectUsersModal/SelectUsersModal.d.ts +1 -6
  168. package/lib/typescript/components/Modals/SelectUsersModal/SelectUsersModal.d.ts.map +1 -1
  169. package/lib/typescript/components/Modals/UserProfileModal/EditUserModal.d.ts.map +1 -1
  170. package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts +0 -16
  171. package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts.map +1 -1
  172. package/lib/typescript/components/Modals/UserSettingsModal/UserSettingsModal.d.ts +0 -1
  173. package/lib/typescript/components/Modals/UserSettingsModal/UserSettingsModal.d.ts.map +1 -1
  174. package/lib/typescript/components/Modals/styledModalComponents.d.ts.map +1 -1
  175. package/lib/typescript/components/RoomComponents/ChatRoomItem.d.ts.map +1 -1
  176. package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
  177. package/lib/typescript/components/styled/StyledComponents.d.ts.map +1 -1
  178. package/lib/typescript/components/styled/StyledInputComponents/StyledInputComponents.d.ts.map +1 -1
  179. package/lib/typescript/context/xmppProvider.d.ts.map +1 -1
  180. package/lib/typescript/helpers/updateMessagesTillLast.d.ts.map +1 -1
  181. package/lib/typescript/hooks/useChatRoomFocus.d.ts.map +1 -1
  182. package/lib/typescript/hooks/useLogout.d.ts.map +1 -1
  183. package/lib/typescript/hooks/useSendMessage.d.ts.map +1 -1
  184. package/lib/typescript/i18n/strings.d.ts.map +1 -1
  185. package/lib/typescript/main.d.ts +1 -1
  186. package/lib/typescript/main.d.ts.map +1 -1
  187. package/lib/typescript/networking/api-requests/user.api.d.ts +0 -27
  188. package/lib/typescript/networking/api-requests/user.api.d.ts.map +1 -1
  189. package/lib/typescript/networking/outboundQueue.d.ts +16 -0
  190. package/lib/typescript/networking/outboundQueue.d.ts.map +1 -1
  191. package/lib/typescript/networking/stanzaHandlers.d.ts.map +1 -1
  192. package/lib/typescript/networking/xmppClient.d.ts +33 -1
  193. package/lib/typescript/networking/xmppClient.d.ts.map +1 -1
  194. package/lib/typescript/roomStore/chatSettingsSlice.d.ts.map +1 -1
  195. package/lib/typescript/roomStore/roomsSlice.d.ts +18 -1
  196. package/lib/typescript/roomStore/roomsSlice.d.ts.map +1 -1
  197. package/lib/typescript/types/models/room.model.d.ts +15 -0
  198. package/lib/typescript/types/models/room.model.d.ts.map +1 -1
  199. package/lib/typescript/types/types.d.ts +20 -20
  200. package/lib/typescript/types/types.d.ts.map +1 -1
  201. package/package.json +1 -6
  202. package/src/assets/icons.tsx +9 -48
  203. package/src/components/Header/HeaderRoomList.tsx +5 -20
  204. package/src/components/MainComponents/ChatRoom.tsx +20 -38
  205. package/src/components/MainComponents/MessageList.tsx +24 -8
  206. package/src/components/MainComponents/ProfileImagePlaceholder.tsx +14 -21
  207. package/src/components/MainComponents/RoomList.tsx +34 -65
  208. package/src/components/Menu/HeaderRoomListMenu.tsx +71 -310
  209. package/src/components/Modals/AttachSheet/AttachSheet.tsx +97 -331
  210. package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +279 -598
  211. package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +2 -4
  212. package/src/components/Modals/Modal/Modal.tsx +0 -7
  213. package/src/components/Modals/NewChatModal/ModalContent.tsx +3 -6
  214. package/src/components/Modals/NewChatModal/NewChatModal.tsx +117 -219
  215. package/src/components/Modals/NewChatModal/UpdNewChatModal.tsx +1 -12
  216. package/src/components/Modals/SelectUsersModal/SelectUsersModal.tsx +4 -14
  217. package/src/components/Modals/UserProfileModal/EditUserModal.tsx +25 -9
  218. package/src/components/Modals/UserProfileModal/UserProfileModal.tsx +307 -617
  219. package/src/components/Modals/UserSettingsModal/UserSettingsModal.tsx +58 -75
  220. package/src/components/Modals/styledModalComponents.tsx +2 -9
  221. package/src/components/RoomComponents/ChatRoomItem.tsx +7 -14
  222. package/src/components/styled/SendInput.tsx +12 -83
  223. package/src/components/styled/StyledComponents.ts +3 -9
  224. package/src/components/styled/StyledInputComponents/StyledInputComponents.tsx +4 -11
  225. package/src/context/xmppProvider.tsx +41 -8
  226. package/src/helpers/updateMessagesTillLast.tsx +42 -17
  227. package/src/hooks/useChatRoomFocus.ts +11 -3
  228. package/src/hooks/useLogout.tsx +7 -0
  229. package/src/hooks/useSendMessage.tsx +60 -24
  230. package/src/i18n/strings.ts +1 -121
  231. package/src/main.ts +1 -1
  232. package/src/networking/api-requests/user.api.ts +0 -71
  233. package/src/networking/outboundQueue.ts +29 -0
  234. package/src/networking/stanzaHandlers.ts +9 -1
  235. package/src/networking/xmppClient.ts +118 -7
  236. package/src/roomStore/chatSettingsSlice.ts +1 -3
  237. package/src/roomStore/roomsSlice.ts +20 -2
  238. package/src/types/models/room.model.ts +15 -0
  239. package/src/types/types.ts +20 -22
  240. package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js +0 -226
  241. package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js.map +0 -1
  242. package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js +0 -556
  243. package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js.map +0 -1
  244. package/lib/commonjs/components/Modals/ProfileHeader/ProfileMenu.js +0 -210
  245. package/lib/commonjs/components/Modals/ProfileHeader/ProfileMenu.js.map +0 -1
  246. package/lib/commonjs/helpers/getChatBackground.js +0 -23
  247. package/lib/commonjs/helpers/getChatBackground.js.map +0 -1
  248. package/lib/commonjs/helpers/mediaLibraryRuntime.js +0 -31
  249. package/lib/commonjs/helpers/mediaLibraryRuntime.js.map +0 -1
  250. package/lib/commonjs/helpers/pickImageAsset.js +0 -68
  251. package/lib/commonjs/helpers/pickImageAsset.js.map +0 -1
  252. package/lib/commonjs/helpers/sheetGestures.js +0 -32
  253. package/lib/commonjs/helpers/sheetGestures.js.map +0 -1
  254. package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js +0 -223
  255. package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js.map +0 -1
  256. package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js +0 -548
  257. package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js.map +0 -1
  258. package/lib/module/components/Modals/ProfileHeader/ProfileMenu.js +0 -205
  259. package/lib/module/components/Modals/ProfileHeader/ProfileMenu.js.map +0 -1
  260. package/lib/module/helpers/getChatBackground.js +0 -18
  261. package/lib/module/helpers/getChatBackground.js.map +0 -1
  262. package/lib/module/helpers/mediaLibraryRuntime.js +0 -25
  263. package/lib/module/helpers/mediaLibraryRuntime.js.map +0 -1
  264. package/lib/module/helpers/pickImageAsset.js +0 -63
  265. package/lib/module/helpers/pickImageAsset.js.map +0 -1
  266. package/lib/module/helpers/sheetGestures.js +0 -26
  267. package/lib/module/helpers/sheetGestures.js.map +0 -1
  268. package/lib/typescript/components/Modals/ChatProfileModal/ReportChatModal.d.ts +0 -9
  269. package/lib/typescript/components/Modals/ChatProfileModal/ReportChatModal.d.ts.map +0 -1
  270. package/lib/typescript/components/Modals/ProfileHeader/ProfileHeader.d.ts +0 -75
  271. package/lib/typescript/components/Modals/ProfileHeader/ProfileHeader.d.ts.map +0 -1
  272. package/lib/typescript/components/Modals/ProfileHeader/ProfileMenu.d.ts +0 -25
  273. package/lib/typescript/components/Modals/ProfileHeader/ProfileMenu.d.ts.map +0 -1
  274. package/lib/typescript/helpers/getChatBackground.d.ts +0 -15
  275. package/lib/typescript/helpers/getChatBackground.d.ts.map +0 -1
  276. package/lib/typescript/helpers/mediaLibraryRuntime.d.ts +0 -3
  277. package/lib/typescript/helpers/mediaLibraryRuntime.d.ts.map +0 -1
  278. package/lib/typescript/helpers/pickImageAsset.d.ts +0 -27
  279. package/lib/typescript/helpers/pickImageAsset.d.ts.map +0 -1
  280. package/lib/typescript/helpers/sheetGestures.d.ts +0 -20
  281. package/lib/typescript/helpers/sheetGestures.d.ts.map +0 -1
  282. package/src/components/Modals/ChatProfileModal/ReportChatModal.tsx +0 -244
  283. package/src/components/Modals/ProfileHeader/ProfileHeader.tsx +0 -615
  284. package/src/components/Modals/ProfileHeader/ProfileMenu.tsx +0 -217
  285. package/src/helpers/getChatBackground.ts +0 -18
  286. package/src/helpers/mediaLibraryRuntime.ts +0 -25
  287. package/src/helpers/pickImageAsset.ts +0 -68
  288. package/src/helpers/sheetGestures.ts +0 -25
@@ -1,41 +1,19 @@
1
1
  /** @format */
2
2
 
3
- import React, { useCallback, useEffect, useRef, useState } from 'react';
3
+ import React, { useEffect, useRef, useState } from 'react';
4
4
  import {
5
- ActivityIndicator,
6
5
  Animated,
7
6
  Easing,
8
- Image,
9
7
  Modal,
10
- PanResponder,
11
8
  Platform,
12
- ScrollView,
13
9
  StyleSheet,
14
10
  Text,
15
11
  TouchableOpacity,
16
12
  View,
17
13
  } from 'react-native';
18
- import { CameraIcon, DocumentIcon } from '../../../assets/icons';
14
+ import { CameraIcon, DocumentIcon, MediaIcon } from '../../../assets/icons';
19
15
  import { useChatSettingState } from '../../../hooks/useChatSettingState';
20
16
  import { chatTextStyle } from '../../../helpers/typography';
21
- import { getMediaLibrary } from '../../../helpers/mediaLibraryRuntime';
22
- import {
23
- shouldClaimVerticalDrag,
24
- shouldDismissOnDrag,
25
- } from '../../../helpers/sheetGestures';
26
-
27
- interface RecentItem {
28
- id: string;
29
- uri: string;
30
- filename: string;
31
- }
32
-
33
- export interface PickedMedia {
34
- uri: string;
35
- name: string;
36
- mimeType?: string;
37
- isVideo: boolean;
38
- }
39
17
 
40
18
  interface AttachSheetProps {
41
19
  visible: boolean;
@@ -43,54 +21,13 @@ interface AttachSheetProps {
43
21
  onCamera: () => void;
44
22
  onGallery: () => void;
45
23
  onDocument: () => void;
46
- onPickMedia?: (media: PickedMedia) => void;
47
24
  primaryColor?: string;
48
25
  }
49
26
 
50
27
  // Starting translateY for the sheet. Larger than any realistic sheet
51
28
  // height so it sits fully below the viewport before opening; the exact
52
29
  // number doesn't matter visually because it animates to 0.
53
- const SHEET_OFFSCREEN = 800;
54
- // Re-exported so this sheet's own tests keep addressing them here.
55
- export { shouldClaimVerticalDrag, shouldDismissOnDrag };
56
-
57
- const RECENTS_COUNT = 12;
58
- const THUMB_SIZE = 88;
59
- const THUMB_DECODE = THUMB_SIZE * 2;
60
-
61
- const EXT_MIME: Record<string, string> = {
62
- jpg: 'image/jpeg',
63
- jpeg: 'image/jpeg',
64
- png: 'image/png',
65
- gif: 'image/gif',
66
- webp: 'image/webp',
67
- heic: 'image/heic',
68
- heif: 'image/heif',
69
- };
70
-
71
- const guessMimeType = (name: string) => {
72
- const ext = name.split('.').pop()?.toLowerCase() ?? '';
73
- return EXT_MIME[ext] ?? 'image/jpeg';
74
- };
75
-
76
- const toRecentItem = async (
77
- MediaLibrary: any,
78
- asset: any
79
- ): Promise<RecentItem | null> => {
80
- const filename = asset?.filename || `photo_${asset?.id ?? Date.now()}`;
81
- if (asset?.uri && !asset.uri.startsWith('ph://')) {
82
- return { id: asset.id, uri: asset.uri, filename };
83
- }
84
- try {
85
- const info = await MediaLibrary?.getAssetInfoAsync?.(asset, {
86
- shouldDownloadFromNetwork: false,
87
- });
88
- if (!info?.localUri) {return null;}
89
- return { id: asset.id, uri: info.localUri, filename };
90
- } catch {
91
- return null;
92
- }
93
- };
30
+ const SHEET_OFFSCREEN = 600;
94
31
 
95
32
  const AttachSheet: React.FC<AttachSheetProps> = ({
96
33
  visible,
@@ -98,17 +35,16 @@ const AttachSheet: React.FC<AttachSheetProps> = ({
98
35
  onCamera,
99
36
  onGallery,
100
37
  onDocument,
101
- onPickMedia,
102
38
  primaryColor = '#0052CD',
103
39
  }) => {
104
40
  const { config } = useChatSettingState();
105
41
  const ts = config?.typography?.attachSheet;
42
+ // Pending handler captured on row tap — runs once the EXIT animation
43
+ // finishes so iOS doesn't try to present an image picker over a
44
+ // still-dismissing modal (was the original reason for the
45
+ // platform-split + Modal.onDismiss dance). The animation completion
46
+ // callback now drives this on both platforms.
106
47
  const pendingRef = useRef<(() => void) | null>(null);
107
- const runPending = () => {
108
- const fn = pendingRef.current;
109
- pendingRef.current = null;
110
- fn?.();
111
- };
112
48
 
113
49
  // Local "modal stays mounted while animating out" state. The parent
114
50
  // controls `visible`; we mirror it but delay unmount until the exit
@@ -127,9 +63,6 @@ const AttachSheet: React.FC<AttachSheetProps> = ({
127
63
  new Animated.Value(SHEET_OFFSCREEN)
128
64
  ).current;
129
65
 
130
- const onCloseRef = useRef(onClose);
131
- onCloseRef.current = onClose;
132
-
133
66
  useEffect(() => {
134
67
  if (visible) {
135
68
  setMounted(true);
@@ -162,6 +95,8 @@ const AttachSheet: React.FC<AttachSheetProps> = ({
162
95
  return () => cancelAnimationFrame(raf);
163
96
  }
164
97
  if (!mounted) {return;}
98
+ // Exit: fade the backdrop, slide the sheet down, then unmount and
99
+ // fire any pending picker handler.
165
100
  Animated.parallel([
166
101
  Animated.timing(backdropOpacity, {
167
102
  toValue: 0,
@@ -178,133 +113,43 @@ const AttachSheet: React.FC<AttachSheetProps> = ({
178
113
  ]).start(({ finished }) => {
179
114
  if (!finished) {return;} // interrupted (rapid re-open) → leave state alone
180
115
  setMounted(false);
181
- if (Platform.OS !== 'ios') {
182
- runPending();
183
- }
116
+ const fn = pendingRef.current;
117
+ pendingRef.current = null;
118
+ fn?.();
184
119
  });
185
120
  return undefined;
186
121
  }, [visible]); // eslint-disable-line react-hooks/exhaustive-deps
187
122
 
188
- const makeDragResponder = (claimOnStart: boolean) =>
189
- PanResponder.create({
190
- onStartShouldSetPanResponder: () => claimOnStart,
191
- // Capture, so a pull that starts on a row (whose Touchable grabbed
192
- // the responder on touch-down) still drags the sheet.
193
- onMoveShouldSetPanResponderCapture: (_evt, g) =>
194
- claimOnStart || shouldClaimVerticalDrag(g.dy, g.dx),
195
- onMoveShouldSetPanResponder: (_evt, g) =>
196
- claimOnStart || shouldClaimVerticalDrag(g.dy, g.dx),
197
- onPanResponderTerminationRequest: () => false,
198
- onPanResponderMove: (_evt, g) => {
199
- sheetTranslateY.setValue(Math.max(0, g.dy));
200
- },
201
- onPanResponderRelease: (_evt, g) => {
202
- if (shouldDismissOnDrag(g.dy, g.vy)) {
203
- onCloseRef.current();
204
- return;
205
- }
206
- Animated.spring(sheetTranslateY, {
207
- toValue: 0,
208
- tension: 90,
209
- friction: 14,
210
- useNativeDriver: true,
211
- }).start();
212
- },
213
- onPanResponderTerminate: () => {
214
- Animated.spring(sheetTranslateY, {
215
- toValue: 0,
216
- tension: 90,
217
- friction: 14,
218
- useNativeDriver: true,
219
- }).start();
220
- },
221
- });
222
-
223
- const sheetPanRef = useRef<ReturnType<typeof makeDragResponder> | null>(null);
224
- const grabberPanRef = useRef<ReturnType<typeof makeDragResponder> | null>(null);
225
- if (!sheetPanRef.current) {sheetPanRef.current = makeDragResponder(false);}
226
- if (!grabberPanRef.current) {grabberPanRef.current = makeDragResponder(true);}
227
- const sheetPan = sheetPanRef.current;
228
- const grabberPan = grabberPanRef.current;
229
-
230
- const [recents, setRecents] = useState<RecentItem[]>([]);
231
- const [loadingRecents, setLoadingRecents] = useState(false);
232
- const lastLoadRef = useRef(0);
233
- const RECENTS_TTL_MS = 15000;
234
-
235
- const loadRecents = useCallback(async () => {
236
- const MediaLibrary = getMediaLibrary();
237
- if (!MediaLibrary?.getAssetsAsync) {
238
- setLoadingRecents(false);
239
- return;
240
- }
241
- try {
242
- const perm = await MediaLibrary.getPermissionsAsync();
243
- if (!perm?.granted) {
244
- setRecents([]);
245
- return;
246
- }
247
- const page = await MediaLibrary.getAssetsAsync({
248
- first: RECENTS_COUNT,
249
- sortBy: [MediaLibrary.SortBy?.creationTime ?? 'creationTime'],
250
- mediaType: [MediaLibrary.MediaType?.photo ?? 'photo'],
251
- });
252
- const items = await Promise.all(
253
- (page?.assets ?? []).map((asset: any) => toRecentItem(MediaLibrary, asset))
254
- );
255
- lastLoadRef.current = Date.now();
256
- setRecents(items.filter(Boolean) as RecentItem[]);
257
- } catch (err) {
258
- console.warn('AttachSheet: could not read recent media', err);
259
- setRecents([]);
260
- } finally {
261
- setLoadingRecents(false);
262
- }
263
- }, []);
264
-
265
- useEffect(() => {
266
- if (!visible) {return undefined;}
267
- if (recents.length && Date.now() - lastLoadRef.current < RECENTS_TTL_MS) {
268
- return undefined;
269
- }
270
- setLoadingRecents(true);
271
- const timer = setTimeout(() => {
272
- loadRecents();
273
- }, 250);
274
- return () => clearTimeout(timer);
275
- }, [visible]);
276
-
277
123
  const trigger = (handler: () => void) => () => {
124
+ // Capture the handler and ask parent to close. The exit-animation
125
+ // completion above fires `handler` AFTER the sheet has slid away,
126
+ // so iOS no longer tries to present a picker over a dismissing
127
+ // modal — and Android no longer needs the ad-hoc 150ms setTimeout.
278
128
  pendingRef.current = handler;
279
- if (Platform.OS === 'ios') {
280
- setMounted(false);
281
- }
282
129
  onClose();
283
130
  };
284
131
 
285
- const handleRecentPress = (item: RecentItem) =>
286
- trigger(() => {
287
- if (onPickMedia) {
288
- onPickMedia({
289
- uri: item.uri,
290
- name: item.filename,
291
- mimeType: guessMimeType(item.filename),
292
- isVideo: false,
293
- });
294
- } else {
295
- onGallery();
296
- }
297
- });
298
-
299
132
  const rows: {
300
- id: string;
301
133
  label: string;
134
+ hint: string;
302
135
  Icon: React.ComponentType<any>;
303
136
  handler: () => void;
304
137
  }[] = [
305
138
  {
306
- id: 'Document',
307
- label: 'Upload a File',
139
+ label: 'Take photo',
140
+ hint: 'Capture with the camera',
141
+ Icon: CameraIcon,
142
+ handler: onCamera,
143
+ },
144
+ {
145
+ label: 'Photo or video',
146
+ hint: 'Pick from your library',
147
+ Icon: MediaIcon,
148
+ handler: onGallery,
149
+ },
150
+ {
151
+ label: 'Document',
152
+ hint: 'Choose a file',
308
153
  Icon: DocumentIcon,
309
154
  handler: onDocument,
310
155
  },
@@ -321,13 +166,11 @@ const AttachSheet: React.FC<AttachSheetProps> = ({
321
166
  onRequestClose={onClose}
322
167
  // Hardware-back / iOS gesture also routes through onClose, which
323
168
  // flips `visible` and triggers our exit animation above.
324
- onDismiss={Platform.OS === 'ios' ? runPending : undefined}
325
169
  >
326
170
  <Animated.View
327
171
  style={[styles.backdrop, { opacity: backdropOpacity }]}
328
172
  >
329
173
  <TouchableOpacity
330
- testID="attach-backdrop"
331
174
  style={StyleSheet.absoluteFill}
332
175
  activeOpacity={1}
333
176
  onPress={onClose}
@@ -337,101 +180,42 @@ const AttachSheet: React.FC<AttachSheetProps> = ({
337
180
  styles.sheet,
338
181
  { transform: [{ translateY: sheetTranslateY }] },
339
182
  ]}
340
- {...sheetPan.panHandlers}
341
183
  >
342
- <View
343
- testID="attach-grabber"
344
- style={styles.grabberArea}
345
- {...grabberPan.panHandlers}
346
- >
184
+ <TouchableOpacity activeOpacity={1}>
347
185
  <View style={styles.grabber} />
348
- </View>
349
-
350
- {/* Photos & Videos ------------------------------------------------ */}
351
- <View style={styles.sectionHeader}>
352
- <Text style={[styles.sectionTitle, chatTextStyle(ts?.title)]}>
353
- Photos & Videos
354
- </Text>
355
- <TouchableOpacity
356
- testID="attach-view-library"
357
- activeOpacity={0.6}
358
- onPress={trigger(onGallery)}
359
- hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
360
- >
361
- <Text
186
+ <Text style={[styles.title, chatTextStyle(ts?.title)]}>Attach</Text>
187
+ {rows.map(({ label, hint, Icon, handler }, idx) => (
188
+ <TouchableOpacity
189
+ key={label}
190
+ activeOpacity={0.6}
362
191
  style={[
363
- styles.sectionAction,
364
- { color: primaryColor },
365
- chatTextStyle(ts?.viewLibrary),
192
+ styles.row,
193
+ idx < rows.length - 1 && styles.rowDivider,
366
194
  ]}
195
+ onPress={trigger(handler)}
367
196
  >
368
- View Library
369
- </Text>
370
- </TouchableOpacity>
371
- </View>
372
-
373
- <ScrollView
374
- horizontal
375
- showsHorizontalScrollIndicator={false}
376
- contentContainerStyle={styles.strip}
377
- keyboardShouldPersistTaps="handled"
378
- >
379
- {/* Camera tile — always first, works without library access. */}
380
- <TouchableOpacity
381
- testID="attach-row-Camera"
382
- activeOpacity={0.7}
383
- style={styles.cameraTile}
384
- onPress={trigger(onCamera)}
385
- >
386
- <CameraIcon color="#8A8A8E" width={26} height={26} />
387
- </TouchableOpacity>
388
-
389
- {loadingRecents && recents.length === 0 && (
390
- <View style={styles.loadingTile}>
391
- <ActivityIndicator color="#8A8A8E" />
392
- </View>
393
- )}
394
-
395
- {recents.map((item) => (
396
- <TouchableOpacity
397
- key={item.id}
398
- testID={`attach-recent-${item.id}`}
399
- activeOpacity={0.8}
400
- style={styles.thumbWrap}
401
- onPress={handleRecentPress(item)}
402
- >
403
- <Image
404
- source={{
405
- uri: item.uri,
406
- width: THUMB_DECODE,
407
- height: THUMB_DECODE,
408
- }}
409
- style={styles.thumb}
410
- resizeMethod="resize"
411
- resizeMode="cover"
412
- fadeDuration={0}
413
- />
197
+ <View
198
+ style={[
199
+ styles.iconBubble,
200
+ { backgroundColor: primaryColor + '14' },
201
+ ]}
202
+ >
203
+ <Icon color={primaryColor} width={20} height={20} />
204
+ </View>
205
+ <View style={styles.rowText}>
206
+ <Text style={[styles.rowLabel, chatTextStyle(ts?.rowLabel)]}>{label}</Text>
207
+ <Text style={[styles.rowHint, chatTextStyle(ts?.rowHint)]}>{hint}</Text>
208
+ </View>
414
209
  </TouchableOpacity>
415
210
  ))}
416
- </ScrollView>
417
-
418
- <View style={styles.rowsDivider} />
419
- {rows.map(({ id, label, Icon, handler }) => (
420
211
  <TouchableOpacity
421
- key={id}
422
- testID={`attach-row-${id}`}
423
212
  activeOpacity={0.6}
424
- style={styles.row}
425
- onPress={trigger(handler)}
213
+ style={styles.cancelRow}
214
+ onPress={onClose}
426
215
  >
427
- <View style={styles.rowIcon}>
428
- <Icon color="#1C1C1E" width={20} height={20} />
429
- </View>
430
- <Text style={[styles.rowLabel, chatTextStyle(ts?.rowLabel)]}>
431
- {label}
432
- </Text>
216
+ <Text style={[styles.cancelLabel, chatTextStyle(ts?.cancelButton)]}>Cancel</Text>
433
217
  </TouchableOpacity>
434
- ))}
218
+ </TouchableOpacity>
435
219
  </Animated.View>
436
220
  </Animated.View>
437
221
  </Modal>
@@ -448,7 +232,7 @@ const styles = StyleSheet.create({
448
232
  backgroundColor: '#fff',
449
233
  borderTopLeftRadius: 24,
450
234
  borderTopRightRadius: 24,
451
- paddingTop: 4,
235
+ paddingTop: 8,
452
236
  paddingBottom: Platform.OS === 'ios' ? 32 : 20,
453
237
  shadowColor: '#000',
454
238
  shadowOffset: { width: 0, height: -2 },
@@ -456,83 +240,65 @@ const styles = StyleSheet.create({
456
240
  shadowRadius: 12,
457
241
  elevation: 16,
458
242
  },
459
- grabberArea: {
460
- alignItems: 'center',
461
- paddingTop: 10,
462
- paddingBottom: 14,
463
- },
464
243
  grabber: {
244
+ alignSelf: 'center',
465
245
  width: 40,
466
246
  height: 4,
467
247
  borderRadius: 2,
468
248
  backgroundColor: '#D9D9DE',
249
+ marginBottom: 12,
469
250
  },
470
- sectionHeader: {
251
+ title: {
252
+ fontSize: 13,
253
+ fontWeight: '600',
254
+ color: '#8A8A8E',
255
+ letterSpacing: 0.4,
256
+ textTransform: 'uppercase',
257
+ paddingHorizontal: 20,
258
+ paddingBottom: 8,
259
+ },
260
+ row: {
471
261
  flexDirection: 'row',
472
262
  alignItems: 'center',
473
- justifyContent: 'space-between',
474
263
  paddingHorizontal: 20,
475
- paddingBottom: 12,
264
+ paddingVertical: 14,
476
265
  },
477
- sectionTitle: {
478
- fontSize: 17,
479
- fontWeight: '700',
480
- color: '#1C1C1E',
266
+ rowDivider: {
267
+ borderBottomWidth: StyleSheet.hairlineWidth,
268
+ borderBottomColor: '#EFEFF2',
481
269
  },
482
- sectionAction: {
483
- fontSize: 15,
484
- fontWeight: '500',
485
- },
486
- strip: {
487
- paddingHorizontal: 16,
488
- paddingBottom: 16,
489
- gap: 8,
490
- },
491
- cameraTile: {
492
- width: THUMB_SIZE,
493
- height: THUMB_SIZE,
494
- borderRadius: 16,
495
- borderWidth: 1,
496
- borderColor: '#E4E4E9',
497
- backgroundColor: '#FAFAFC',
498
- alignItems: 'center',
499
- justifyContent: 'center',
500
- },
501
- loadingTile: {
502
- width: THUMB_SIZE,
503
- height: THUMB_SIZE,
270
+ iconBubble: {
271
+ width: 40,
272
+ height: 40,
273
+ borderRadius: 20,
504
274
  alignItems: 'center',
505
275
  justifyContent: 'center',
276
+ marginRight: 14,
506
277
  },
507
- thumbWrap: {
508
- width: THUMB_SIZE,
509
- height: THUMB_SIZE,
510
- borderRadius: 16,
511
- overflow: 'hidden',
512
- backgroundColor: '#EFEFF2',
513
- },
514
- thumb: {
515
- width: '100%',
516
- height: '100%',
278
+ rowText: {
279
+ flex: 1,
517
280
  },
518
- rowsDivider: {
519
- height: StyleSheet.hairlineWidth,
520
- backgroundColor: '#EFEFF2',
281
+ rowLabel: {
282
+ fontSize: 16,
283
+ fontWeight: '500',
284
+ color: '#1C1C1E',
521
285
  },
522
- row: {
523
- flexDirection: 'row',
524
- alignItems: 'center',
525
- paddingHorizontal: 20,
526
- paddingVertical: 16,
286
+ rowHint: {
287
+ fontSize: 12,
288
+ color: '#8A8A8E',
289
+ marginTop: 2,
527
290
  },
528
- rowIcon: {
529
- width: 28,
291
+ cancelRow: {
292
+ marginTop: 8,
293
+ marginHorizontal: 16,
294
+ paddingVertical: 14,
295
+ borderRadius: 14,
530
296
  alignItems: 'center',
531
- marginRight: 12,
297
+ backgroundColor: '#F2F2F7',
532
298
  },
533
- rowLabel: {
299
+ cancelLabel: {
534
300
  fontSize: 16,
535
- fontWeight: '500',
301
+ fontWeight: '600',
536
302
  color: '#1C1C1E',
537
303
  },
538
304
  });