chat 1.0.8 → 3.0.0

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 (318) hide show
  1. package/package.json +2 -96
  2. package/readme.md +1 -201
  3. package/lib/module/ChatContext/index.js +0 -2
  4. package/lib/module/ChatContext/index.js.map +0 -1
  5. package/lib/module/ChatContext/types.js +0 -2
  6. package/lib/module/ChatContext/types.js.map +0 -1
  7. package/lib/module/classes/Chat/index.js +0 -2
  8. package/lib/module/classes/Chat/index.js.map +0 -1
  9. package/lib/module/classes/Chat/types.js +0 -2
  10. package/lib/module/classes/Chat/types.js.map +0 -1
  11. package/lib/module/classes/Inbox/index.js +0 -2
  12. package/lib/module/classes/Inbox/index.js.map +0 -1
  13. package/lib/module/classes/Inbox/types.js +0 -2
  14. package/lib/module/classes/Inbox/types.js.map +0 -1
  15. package/lib/module/classes/Message/index.js +0 -2
  16. package/lib/module/classes/Message/index.js.map +0 -1
  17. package/lib/module/classes/Message/types.js +0 -2
  18. package/lib/module/classes/Message/types.js.map +0 -1
  19. package/lib/module/classes/Reaction/index.js +0 -2
  20. package/lib/module/classes/Reaction/index.js.map +0 -1
  21. package/lib/module/classes/Reaction/types.js +0 -2
  22. package/lib/module/classes/Reaction/types.js.map +0 -1
  23. package/lib/module/classes/Room/index.js +0 -2
  24. package/lib/module/classes/Room/index.js.map +0 -1
  25. package/lib/module/classes/Room/types.js +0 -2
  26. package/lib/module/classes/Room/types.js.map +0 -1
  27. package/lib/module/classes/index.js +0 -2
  28. package/lib/module/classes/index.js.map +0 -1
  29. package/lib/module/components/Avatar/index.js +0 -2
  30. package/lib/module/components/Avatar/index.js.map +0 -1
  31. package/lib/module/components/Chat/Bubble/index.js +0 -2
  32. package/lib/module/components/Chat/Bubble/index.js.map +0 -1
  33. package/lib/module/components/Chat/Composer/Input/index.js +0 -2
  34. package/lib/module/components/Chat/Composer/Input/index.js.map +0 -1
  35. package/lib/module/components/Chat/Composer/Send/index.js +0 -2
  36. package/lib/module/components/Chat/Composer/Send/index.js.map +0 -1
  37. package/lib/module/components/Chat/Composer/index.js +0 -2
  38. package/lib/module/components/Chat/Composer/index.js.map +0 -1
  39. package/lib/module/components/Chat/Media/Image/index.js +0 -2
  40. package/lib/module/components/Chat/Media/Image/index.js.map +0 -1
  41. package/lib/module/components/Chat/Media/index.js +0 -2
  42. package/lib/module/components/Chat/Media/index.js.map +0 -1
  43. package/lib/module/components/Chat/Message/Swiper/Action/index.js +0 -2
  44. package/lib/module/components/Chat/Message/Swiper/Action/index.js.map +0 -1
  45. package/lib/module/components/Chat/Message/Swiper/index.js +0 -2
  46. package/lib/module/components/Chat/Message/Swiper/index.js.map +0 -1
  47. package/lib/module/components/Chat/Message/Touchable/index.js +0 -2
  48. package/lib/module/components/Chat/Message/Touchable/index.js.map +0 -1
  49. package/lib/module/components/Chat/Message/index.js +0 -2
  50. package/lib/module/components/Chat/Message/index.js.map +0 -1
  51. package/lib/module/components/Chat/SystemMessage/index.js +0 -2
  52. package/lib/module/components/Chat/SystemMessage/index.js.map +0 -1
  53. package/lib/module/components/Chat/TypingFooter/index.js +0 -2
  54. package/lib/module/components/Chat/TypingFooter/index.js.map +0 -1
  55. package/lib/module/components/Chat/index.js +0 -2
  56. package/lib/module/components/Chat/index.js.map +0 -1
  57. package/lib/module/components/Chat/types.js +0 -2
  58. package/lib/module/components/Chat/types.js.map +0 -1
  59. package/lib/module/components/Chat-Old/Bubble/index.js +0 -2
  60. package/lib/module/components/Chat-Old/Bubble/index.js.map +0 -1
  61. package/lib/module/components/Chat-Old/Composer/Input/index.js +0 -2
  62. package/lib/module/components/Chat-Old/Composer/Input/index.js.map +0 -1
  63. package/lib/module/components/Chat-Old/Composer/Send/index.js +0 -2
  64. package/lib/module/components/Chat-Old/Composer/Send/index.js.map +0 -1
  65. package/lib/module/components/Chat-Old/Composer/index.js +0 -2
  66. package/lib/module/components/Chat-Old/Composer/index.js.map +0 -1
  67. package/lib/module/components/Chat-Old/Message/index.js +0 -2
  68. package/lib/module/components/Chat-Old/Message/index.js.map +0 -1
  69. package/lib/module/components/Chat-Old/Swiper/Action/index.js +0 -2
  70. package/lib/module/components/Chat-Old/Swiper/Action/index.js.map +0 -1
  71. package/lib/module/components/Chat-Old/Swiper/index.js +0 -2
  72. package/lib/module/components/Chat-Old/Swiper/index.js.map +0 -1
  73. package/lib/module/components/Chat-Old/SystemMessage/index.js +0 -2
  74. package/lib/module/components/Chat-Old/SystemMessage/index.js.map +0 -1
  75. package/lib/module/components/Chat-Old/index.js +0 -2
  76. package/lib/module/components/Chat-Old/index.js.map +0 -1
  77. package/lib/module/components/Chat-Old/types.js +0 -2
  78. package/lib/module/components/Chat-Old/types.js.map +0 -1
  79. package/lib/module/components/ChatProvider/index.js +0 -2
  80. package/lib/module/components/ChatProvider/index.js.map +0 -1
  81. package/lib/module/components/ChatProvider/types.js +0 -2
  82. package/lib/module/components/ChatProvider/types.js.map +0 -1
  83. package/lib/module/components/Inbox/Item/Circle/index.js +0 -2
  84. package/lib/module/components/Inbox/Item/Circle/index.js.map +0 -1
  85. package/lib/module/components/Inbox/Item/Circle/types.js +0 -2
  86. package/lib/module/components/Inbox/Item/Circle/types.js.map +0 -1
  87. package/lib/module/components/Inbox/Item/Initials/index.js +0 -2
  88. package/lib/module/components/Inbox/Item/Initials/index.js.map +0 -1
  89. package/lib/module/components/Inbox/Item/ItemDate/index.js +0 -2
  90. package/lib/module/components/Inbox/Item/ItemDate/index.js.map +0 -1
  91. package/lib/module/components/Inbox/Item/Separator/index.js +0 -2
  92. package/lib/module/components/Inbox/Item/Separator/index.js.map +0 -1
  93. package/lib/module/components/Inbox/Item/Subtitle/index.js +0 -2
  94. package/lib/module/components/Inbox/Item/Subtitle/index.js.map +0 -1
  95. package/lib/module/components/Inbox/Item/Swipeable/index.js +0 -2
  96. package/lib/module/components/Inbox/Item/Swipeable/index.js.map +0 -1
  97. package/lib/module/components/Inbox/Item/Title/index.js +0 -2
  98. package/lib/module/components/Inbox/Item/Title/index.js.map +0 -1
  99. package/lib/module/components/Inbox/Item/UnreadIndicator/index.js +0 -2
  100. package/lib/module/components/Inbox/Item/UnreadIndicator/index.js.map +0 -1
  101. package/lib/module/components/Inbox/Item/index.js +0 -2
  102. package/lib/module/components/Inbox/Item/index.js.map +0 -1
  103. package/lib/module/components/Inbox/index.js +0 -2
  104. package/lib/module/components/Inbox/index.js.map +0 -1
  105. package/lib/module/components/Inbox/question.md +0 -21
  106. package/lib/module/components/Inbox/readme.md +0 -21
  107. package/lib/module/components/Inbox/types.js +0 -2
  108. package/lib/module/components/Inbox/types.js.map +0 -1
  109. package/lib/module/components/RoomCreator/Content/Footer/Button/index.js +0 -2
  110. package/lib/module/components/RoomCreator/Content/Footer/Button/index.js.map +0 -1
  111. package/lib/module/components/RoomCreator/Content/Footer/Input/index.js +0 -2
  112. package/lib/module/components/RoomCreator/Content/Footer/Input/index.js.map +0 -1
  113. package/lib/module/components/RoomCreator/Content/Footer/index.js +0 -2
  114. package/lib/module/components/RoomCreator/Content/Footer/index.js.map +0 -1
  115. package/lib/module/components/RoomCreator/Content/Item/Icon/index.js +0 -2
  116. package/lib/module/components/RoomCreator/Content/Item/Icon/index.js.map +0 -1
  117. package/lib/module/components/RoomCreator/Content/Item/index.js +0 -2
  118. package/lib/module/components/RoomCreator/Content/Item/index.js.map +0 -1
  119. package/lib/module/components/RoomCreator/Content/index.js +0 -2
  120. package/lib/module/components/RoomCreator/Content/index.js.map +0 -1
  121. package/lib/module/components/RoomCreator/Header/index.js +0 -2
  122. package/lib/module/components/RoomCreator/Header/index.js.map +0 -1
  123. package/lib/module/components/RoomCreator/index.js +0 -2
  124. package/lib/module/components/RoomCreator/index.js.map +0 -1
  125. package/lib/module/components/RoomCreator/types.js +0 -2
  126. package/lib/module/components/RoomCreator/types.js.map +0 -1
  127. package/lib/module/components/TypingIndicator/index.js +0 -2
  128. package/lib/module/components/TypingIndicator/index.js.map +0 -1
  129. package/lib/module/components/index.js +0 -2
  130. package/lib/module/components/index.js.map +0 -1
  131. package/lib/module/helpers/getInitials.js +0 -2
  132. package/lib/module/helpers/getInitials.js.map +0 -1
  133. package/lib/module/helpers/sortByAvatar.js +0 -2
  134. package/lib/module/helpers/sortByAvatar.js.map +0 -1
  135. package/lib/module/hooks/index.js +0 -2
  136. package/lib/module/hooks/index.js.map +0 -1
  137. package/lib/module/hooks/useCreateRoom/index.js +0 -2
  138. package/lib/module/hooks/useCreateRoom/index.js.map +0 -1
  139. package/lib/module/hooks/useCreator/index.js +0 -2
  140. package/lib/module/hooks/useCreator/index.js.map +0 -1
  141. package/lib/module/hooks/useInbox/index.js +0 -2
  142. package/lib/module/hooks/useInbox/index.js.map +0 -1
  143. package/lib/module/hooks/useInbox/types.js +0 -2
  144. package/lib/module/hooks/useInbox/types.js.map +0 -1
  145. package/lib/module/hooks/useMessages/index.js +0 -2
  146. package/lib/module/hooks/useMessages/index.js.map +0 -1
  147. package/lib/module/hooks/useMessages/types.js +0 -2
  148. package/lib/module/hooks/useMessages/types.js.map +0 -1
  149. package/lib/module/hooks/useRoom/index.js +0 -2
  150. package/lib/module/hooks/useRoom/index.js.map +0 -1
  151. package/lib/module/hooks/useRoom/types.js +0 -2
  152. package/lib/module/hooks/useRoom/types.js.map +0 -1
  153. package/lib/module/hooks/useSend/useSendToGroup/index.js +0 -2
  154. package/lib/module/hooks/useSend/useSendToGroup/index.js.map +0 -1
  155. package/lib/module/hooks/useSend/useSendToPeople/index.js +0 -2
  156. package/lib/module/hooks/useSend/useSendToPeople/index.js.map +0 -1
  157. package/lib/module/hooks/useTyping/index.js +0 -2
  158. package/lib/module/hooks/useTyping/index.js.map +0 -1
  159. package/lib/module/hooks/useTypingOLD/index.js +0 -2
  160. package/lib/module/hooks/useTypingOLD/index.js.map +0 -1
  161. package/lib/module/hooks/useTypingOLD/types.js +0 -2
  162. package/lib/module/hooks/useTypingOLD/types.js.map +0 -1
  163. package/lib/module/hooks/useViewMessages/index.js +0 -2
  164. package/lib/module/hooks/useViewMessages/index.js.map +0 -1
  165. package/lib/module/hooks/useViewMessages/types.js +0 -2
  166. package/lib/module/hooks/useViewMessages/types.js.map +0 -1
  167. package/lib/module/hooks/useViewMessagesOld/index.js +0 -2
  168. package/lib/module/hooks/useViewMessagesOld/index.js.map +0 -1
  169. package/lib/module/index.js +0 -2
  170. package/lib/module/index.js.map +0 -1
  171. package/lib/typescript/ChatContext/index.d.ts +0 -2
  172. package/lib/typescript/ChatContext/types.d.ts +0 -4
  173. package/lib/typescript/classes/Chat/index.d.ts +0 -14
  174. package/lib/typescript/classes/Chat/types.d.ts +0 -21
  175. package/lib/typescript/classes/Inbox/types.d.ts +0 -2
  176. package/lib/typescript/classes/Message/index.d.ts +0 -47
  177. package/lib/typescript/classes/Message/types.d.ts +0 -66
  178. package/lib/typescript/classes/Reaction/index.d.ts +0 -17
  179. package/lib/typescript/classes/Reaction/types.d.ts +0 -33
  180. package/lib/typescript/classes/Room/index.d.ts +0 -42
  181. package/lib/typescript/classes/Room/types.d.ts +0 -112
  182. package/lib/typescript/classes/index.d.ts +0 -4
  183. package/lib/typescript/components/Avatar/index.d.ts +0 -4
  184. package/lib/typescript/components/Chat/Bubble/index.d.ts +0 -4
  185. package/lib/typescript/components/Chat/Composer/Input/index.d.ts +0 -7
  186. package/lib/typescript/components/Chat/Composer/Send/index.d.ts +0 -4
  187. package/lib/typescript/components/Chat/Composer/index.d.ts +0 -8
  188. package/lib/typescript/components/Chat/Media/Image/index.d.ts +0 -7
  189. package/lib/typescript/components/Chat/Media/index.d.ts +0 -4
  190. package/lib/typescript/components/Chat/Message/Touchable/index.d.ts +0 -4
  191. package/lib/typescript/components/Chat/Message/index.d.ts +0 -8
  192. package/lib/typescript/components/Chat/SystemMessage/index.d.ts +0 -4
  193. package/lib/typescript/components/Chat/TypingFooter/index.d.ts +0 -4
  194. package/lib/typescript/components/Chat/index.d.ts +0 -8
  195. package/lib/typescript/components/Chat/types.d.ts +0 -843
  196. package/lib/typescript/components/ChatProvider/index.d.ts +0 -10
  197. package/lib/typescript/components/ChatProvider/types.d.ts +0 -7
  198. package/lib/typescript/components/Inbox/Item/Initials/index.d.ts +0 -4
  199. package/lib/typescript/components/Inbox/Item/ItemDate/index.d.ts +0 -4
  200. package/lib/typescript/components/Inbox/Item/Separator/index.d.ts +0 -6
  201. package/lib/typescript/components/Inbox/Item/Subtitle/index.d.ts +0 -3
  202. package/lib/typescript/components/Inbox/Item/Swipeable/index.d.ts +0 -4
  203. package/lib/typescript/components/Inbox/Item/Title/index.d.ts +0 -3
  204. package/lib/typescript/components/Inbox/Item/UnreadIndicator/index.d.ts +0 -4
  205. package/lib/typescript/components/Inbox/Item/index.d.ts +0 -6
  206. package/lib/typescript/components/Inbox/index.d.ts +0 -4
  207. package/lib/typescript/components/Inbox/types.d.ts +0 -304
  208. package/lib/typescript/components/RoomCreator/Content/Footer/Button/index.d.ts +0 -4
  209. package/lib/typescript/components/RoomCreator/Content/Footer/Input/index.d.ts +0 -4
  210. package/lib/typescript/components/RoomCreator/Content/Footer/index.d.ts +0 -3
  211. package/lib/typescript/components/RoomCreator/Content/Item/Icon/index.d.ts +0 -4
  212. package/lib/typescript/components/RoomCreator/Content/Item/index.d.ts +0 -4
  213. package/lib/typescript/components/RoomCreator/Content/index.d.ts +0 -4
  214. package/lib/typescript/components/RoomCreator/Header/index.d.ts +0 -4
  215. package/lib/typescript/components/RoomCreator/index.d.ts +0 -4
  216. package/lib/typescript/components/RoomCreator/types.d.ts +0 -208
  217. package/lib/typescript/components/TypingIndicator/index.d.ts +0 -9
  218. package/lib/typescript/components/index.d.ts +0 -12
  219. package/lib/typescript/helpers/getInitials.d.ts +0 -1
  220. package/lib/typescript/hooks/index.d.ts +0 -8
  221. package/lib/typescript/hooks/useCreator/index.d.ts +0 -27
  222. package/lib/typescript/hooks/useInbox/index.d.ts +0 -29
  223. package/lib/typescript/hooks/useInbox/types.d.ts +0 -5
  224. package/lib/typescript/hooks/useMessages/index.d.ts +0 -24
  225. package/lib/typescript/hooks/useMessages/types.d.ts +0 -5
  226. package/lib/typescript/hooks/useRoom/index.d.ts +0 -26
  227. package/lib/typescript/hooks/useRoom/types.d.ts +0 -5
  228. package/lib/typescript/hooks/useSend/useSendToGroup/index.d.ts +0 -6
  229. package/lib/typescript/hooks/useSend/useSendToPeople/index.d.ts +0 -6
  230. package/lib/typescript/hooks/useTyping/index.d.ts +0 -36
  231. package/lib/typescript/hooks/useViewMessages/index.d.ts +0 -18
  232. package/lib/typescript/hooks/useViewMessages/types.d.ts +0 -20
  233. package/lib/typescript/index.d.ts +0 -11
  234. package/src/ChatContext/index.tsx +0 -9
  235. package/src/ChatContext/types.ts +0 -4
  236. package/src/classes/Chat/index.ts +0 -46
  237. package/src/classes/Chat/types.ts +0 -23
  238. package/src/classes/Inbox/index.ts +0 -12
  239. package/src/classes/Inbox/types.ts +0 -3
  240. package/src/classes/Message/index.ts +0 -310
  241. package/src/classes/Message/types.ts +0 -118
  242. package/src/classes/Reaction/index.ts +0 -108
  243. package/src/classes/Reaction/types.ts +0 -37
  244. package/src/classes/Room/index.ts +0 -323
  245. package/src/classes/Room/types.ts +0 -161
  246. package/src/classes/index.ts +0 -4
  247. package/src/components/Avatar/index.tsx +0 -25
  248. package/src/components/Chat/Bubble/index.tsx +0 -139
  249. package/src/components/Chat/Composer/Input/index.tsx +0 -45
  250. package/src/components/Chat/Composer/Send/index.tsx +0 -51
  251. package/src/components/Chat/Composer/index.tsx +0 -187
  252. package/src/components/Chat/Media/Image/index.tsx +0 -26
  253. package/src/components/Chat/Media/index.tsx +0 -11
  254. package/src/components/Chat/Message/Swiper/Action/index.tsx +0 -7
  255. package/src/components/Chat/Message/Swiper/index.tsx +0 -32
  256. package/src/components/Chat/Message/Touchable/index.tsx +0 -60
  257. package/src/components/Chat/Message/index.tsx +0 -328
  258. package/src/components/Chat/SystemMessage/index.tsx +0 -44
  259. package/src/components/Chat/TypingFooter/index.tsx +0 -48
  260. package/src/components/Chat/index.tsx +0 -596
  261. package/src/components/Chat/types.ts +0 -913
  262. package/src/components/Chat-Old/Bubble/index.tsx +0 -58
  263. package/src/components/Chat-Old/Composer/Input/index.tsx +0 -34
  264. package/src/components/Chat-Old/Composer/Send/index.tsx +0 -37
  265. package/src/components/Chat-Old/Composer/index.tsx +0 -131
  266. package/src/components/Chat-Old/Message/index.tsx +0 -160
  267. package/src/components/Chat-Old/Swiper/Action/index.tsx +0 -7
  268. package/src/components/Chat-Old/Swiper/index.tsx +0 -30
  269. package/src/components/Chat-Old/SystemMessage/index.tsx +0 -44
  270. package/src/components/Chat-Old/index.tsx +0 -356
  271. package/src/components/Chat-Old/types.ts +0 -752
  272. package/src/components/ChatProvider/index.tsx +0 -31
  273. package/src/components/ChatProvider/types.ts +0 -8
  274. package/src/components/Inbox/Item/Circle/index.tsx +0 -47
  275. package/src/components/Inbox/Item/Circle/types.ts +0 -8
  276. package/src/components/Inbox/Item/Initials/index.tsx +0 -41
  277. package/src/components/Inbox/Item/ItemDate/index.tsx +0 -26
  278. package/src/components/Inbox/Item/Separator/index.tsx +0 -13
  279. package/src/components/Inbox/Item/Subtitle/index.tsx +0 -23
  280. package/src/components/Inbox/Item/Swipeable/index.tsx +0 -143
  281. package/src/components/Inbox/Item/Title/index.tsx +0 -23
  282. package/src/components/Inbox/Item/UnreadIndicator/index.tsx +0 -84
  283. package/src/components/Inbox/Item/index.tsx +0 -307
  284. package/src/components/Inbox/index.tsx +0 -315
  285. package/src/components/Inbox/question.md +0 -21
  286. package/src/components/Inbox/readme.md +0 -21
  287. package/src/components/Inbox/types.ts +0 -371
  288. package/src/components/RoomCreator/Content/Footer/Button/index.tsx +0 -55
  289. package/src/components/RoomCreator/Content/Footer/Input/index.tsx +0 -27
  290. package/src/components/RoomCreator/Content/Footer/index.tsx +0 -72
  291. package/src/components/RoomCreator/Content/Item/Icon/index.tsx +0 -16
  292. package/src/components/RoomCreator/Content/Item/index.tsx +0 -87
  293. package/src/components/RoomCreator/Content/index.tsx +0 -75
  294. package/src/components/RoomCreator/Header/index.tsx +0 -74
  295. package/src/components/RoomCreator/index.tsx +0 -177
  296. package/src/components/RoomCreator/types.ts +0 -233
  297. package/src/components/TypingIndicator/index.tsx +0 -169
  298. package/src/components/index.ts +0 -18
  299. package/src/helpers/getInitials.ts +0 -11
  300. package/src/helpers/sortByAvatar.ts +0 -1
  301. package/src/hooks/index.ts +0 -8
  302. package/src/hooks/useCreateRoom/index.ts +0 -34
  303. package/src/hooks/useCreator/index.ts +0 -33
  304. package/src/hooks/useInbox/index.ts +0 -76
  305. package/src/hooks/useInbox/types.ts +0 -6
  306. package/src/hooks/useMessages/index.ts +0 -109
  307. package/src/hooks/useMessages/types.ts +0 -6
  308. package/src/hooks/useRoom/index.ts +0 -82
  309. package/src/hooks/useRoom/types.ts +0 -6
  310. package/src/hooks/useSend/useSendToGroup/index.ts +0 -38
  311. package/src/hooks/useSend/useSendToPeople/index.ts +0 -38
  312. package/src/hooks/useTyping/index.ts +0 -154
  313. package/src/hooks/useTypingOLD/index.ts +0 -67
  314. package/src/hooks/useTypingOLD/types.ts +0 -7
  315. package/src/hooks/useViewMessages/index.ts +0 -61
  316. package/src/hooks/useViewMessages/types.ts +0 -22
  317. package/src/hooks/useViewMessagesOld/index.ts +0 -39
  318. package/src/index.ts +0 -13
@@ -1,913 +0,0 @@
1
- import {
2
- TextInputProps,
3
- TextStyle,
4
- StyleProp,
5
- ViewStyle,
6
- Animated,
7
- Image,
8
- ListRenderItemInfo,
9
- FlatListProps,
10
- FlatList,
11
- View,
12
- ScrollViewProps,
13
- TextInput,
14
- } from 'react-native'
15
- import { ComponentType, ReactNode, ReactElement, MutableRefObject } from 'react'
16
- import { NewMessageModel, MessageMedia } from '../../classes/Message/types'
17
- import { AvatarProps, InitialsProps } from '../../components/Inbox/types'
18
- import { TypingIndicatorProps } from '../../components/TypingIndicator'
19
-
20
- // TODO improve name position, styles, etc
21
-
22
- /**
23
- * Component that provides a full-on chat screen. Inspired by GiftedChat and works directly with the chat backend.
24
- /**
25
- * Chat props
26
- * @template MessageModel
27
- */
28
- export interface ChatProps<
29
- MessageModel extends NewMessageModel = NewMessageModel
30
- > {
31
- // id: string
32
- /**
33
- * **Required:** Array of messages to be rendered.
34
- *
35
- * The default schema looks like this:
36
- * ```ts
37
- * interface NewMessageModel {
38
- * text: string
39
- * createdAt: Date
40
- * user: {
41
- * id: string
42
- * name: string
43
- * avatar: string
44
- * }
45
- * system?: boolean
46
- * media?: MessageMedia
47
- * // Any additional custom parameters are passed through
48
- * }
49
- * ```
50
- *
51
- * If you want to customize the schema using typescript, you can import and extend the `NewMessageModel`.
52
- */
53
- messages: MessageModel[]
54
- // TODO make multiple prop type options so they fail if they aren't together
55
- /**
56
- * Text input state value.
57
- * If you use this prop, you must also use the onInputTextChanged prop with it to handle the text state on your own.
58
- */
59
- text?: ComposerProps['text']
60
- /**
61
- * Function called whenever the composer text changes (when a message is sent or someone types).
62
- * **IMPORTANT**
63
- * If you use this prop, you must also use the `text` prop with it.
64
- */
65
- onInputTextChanged?: ComposerProps['onInputTextChanged']
66
- /**
67
- * Callback function called whenever a message is sent.
68
- * @param messages - An array of messages. The reason this is an array is because you might have an image and text, and you might want to send them as separate messages.
69
- */
70
- onSend: (messages: (MessageModel | NewMessageModel)[]) => void
71
- /**
72
- * Props passed to the TextInput component. See [react-native's docs](https://facebook.github.io/react-native/docs/textinput.html)
73
- */
74
- textInputProps?: InputProps['inputProps']
75
- /**
76
- * Optional styles for the view that wraps the entire component.
77
- * Default: { flex: 1 }
78
- *
79
- * If you're new to react native, see the docs for styles [here](https://facebook.github.io/react-native/docs/style)
80
- */
81
- containerStyle?: ViewStyle
82
- /**
83
- * Optional styles for FlatList's contentContainerStyle. [See React Native Docs](https://facebook.github.io/react-native/docs/scrollview.html#contentcontainerstyle)
84
- */
85
- contentContainerStyle?: ViewStyle
86
- /**
87
- * Custom React component that wraps the entire Chat component. By default, it is an Animated.View from react-native-reanimated, nested inside
88
- */
89
- ContainerComponent?: ComponentType
90
- /**
91
- * Disable reanimated's transition API when new messages send, someone starts/stops typing, etc.
92
- *
93
- * _Shout-out to Krzysztof Magiera for the awesome react-native-reanimated lib._
94
- */
95
- disableTransitions?: boolean
96
- /**
97
- * Optional custom transition for the reanimated transitions API. [See docs for transitions](https://github.com/kmagiera/react-native-reanimated#transitions-) (you'll see more in their examples/).
98
- * Will fire this transition whenever a new message is sent/received, or when someone else starts/stops typing (unless typing indicators are disabled.)
99
- *
100
- * **Default:**
101
- * ```javascript
102
- * const transitionConfig = (
103
- * <Transition.Sequence>
104
- * <Transition.Together>
105
- * <Transition.Out type="fade" />
106
- * <Transition.Change interpolation="easeOut" />
107
- * </Transition.Together>
108
- * <Transition.In type="fade" />
109
- * </Transition.Sequence>
110
- * )
111
- * ```
112
- *
113
- *
114
- */
115
- transitionConfig?: ReactNode
116
- /**
117
- * Default false.
118
- * If true, disables the reanimated Transition on the initial mount / load of messages
119
- */
120
- disableTransitionOnMount?: boolean
121
- /**
122
- * **Important** Be sure to use `useCallback` for this value if you're using react hooks to avoid re-renders.
123
- * Style prop for the bubble text, based on whether or not the user sent it (`me`) or someone else did (`others`)
124
- *
125
- * @example
126
- * ``` javascript
127
- * const bubbleTextStyle = useCallback(({ isMe }) => ({ color: isMe ? 'white' : 'green' }), [])
128
- * return <Messages bubbleTextStyle={bubbleTextStyle} />
129
- * ```
130
- */
131
- bubbleTextStyle?: PartialUserOptions<MessageProps['bubbleTextStyle']>
132
- /**
133
- * **Important** Be sure to use `useCallback` for this value if you're using react hooks to avoid re-renders.
134
- * Style prop for the bubble view, based on whether or not the user sent it (`me`) or someone else did (`others`):
135
- *
136
- * @example
137
- * ``` javascript
138
- * const bubbleStyle = useCallback(({ isMe }) => ({ backgroundColor: isMe ? 'green' : 'white' }), [])
139
- * return <Messages bubbleStyle={bubbleStyle} />
140
- * ```
141
- */
142
- bubbleStyle?: PartialUserOptions<MessageProps['bubbleStyle']>
143
- /**
144
- * **Important** Be sure to use `useCallback` for this value if you're using react hooks to avoid re-renders.
145
- * Style prop for the bubble's container view, based on whether or not the user sent it (`me`) or someone else did (`others`).
146
- *
147
- * **Note:** The container is not the bubble itself, rather the view that holds the bubble, responsible for choosing which side of the screen it goes on, etc.
148
- * If you want to edit the bubble directly, see bubbleStyle or bubbleTextStyle props.
149
- *
150
- * @example
151
- * ``` javascript
152
- * const messageContainerStyle = useCallback(({ isMe }) => ({ justifyContent: isMe ? 'flex-end' : 'flex-start' }), [])
153
- * return <Messages messageContainerStyle={messageContainerStyle} />
154
- * ```
155
- */
156
- messageContainerStyle?: PartialUserOptions<
157
- MessageProps['messageContainerStyle']
158
- >
159
- /**
160
- * Style prop for the bubble's wrapper view, based on whether or not the user sent it (`me`) or someone else did (`others`).
161
- *
162
- * This view is _inside_ of the bubble's container view. It wraps the bubble *and* the avatar. You might use this if you want to switch which side the avatar is on.
163
- *
164
- * @remarks
165
- * - To change which side of the screen a message bubble actually shows up on, see `messageContainerStyle` prop.
166
- * - To change the background color and other styles of a bubble, see `bubbleStyle` prop.
167
- * - To update bubble text, see `bubbleTextStyle` prop.
168
- *
169
- * @example
170
- * ``` javascript
171
- * // switch "my" avatar to show up on the left instead of the right.
172
- * const messageWrapperStyle = useCallback(({ isMe }) => ({ flexDirection: isMe ? 'row-reverse' : undefined }), [])
173
- * return <Messages messageWrapperStyle={messageWrapperStyle} />
174
- * ```
175
- */
176
- messageWrapperStyle?: PartialUserOptions<MessageProps['messageWrapperStyle']>
177
- /**
178
- * Boolean that disables the swipe-from-side actions on specific messages. Overrides the `swipeActions` prop.
179
- */
180
- disableSwipeActions?: boolean
181
- /**
182
- * A dictionary { left, right }, each value of which is an array of pre-made actions that let you swipe on a message and do something with it (for instance, reply or react to one).
183
- * Default: { right: ['reply'] }
184
- *
185
- * Options: ['reply', 'react', 'edit', 'delete']
186
- *
187
- * if `disableSwipeActions` prop is true, then this prop is ignored.
188
- */
189
- swipeActions?: SwipeableProps['swipeActions']
190
- /**
191
- * Which side the actions swipe from. Defaults to right.
192
- *
193
- * For example, the swipe to reply to message will swipe from right if this is right.
194
- *
195
- * If you're using react navigation's stack navigator, I'd suggesting leaving this as the default.
196
- * That said, you could customize react-navigation's gesture distance (see:
197
- * [react-navigation's docs](https://reactnavigation.org/docs/en/stack-navigator.html#gestureresponsedistance)
198
- * )
199
- */
200
- // swipeActionsFrom?: 'right' | 'left'
201
- /**
202
- * React node that replaces the default actions when swiping a message.
203
- *
204
- * @param props - { action: string, drag: Animated.Value, progress: Animated.AnimatedInterpolation }
205
- *
206
- * Perhaps you only want to use a custom icon when replying, for example.
207
- * @example
208
- * ```js
209
- * return (
210
- * <Messages
211
- * renderSwipeAction={props => (
212
- * props.action === 'reply ? <YourCustomAction {} /> : <Messages.SwipeAction {...props} />
213
- * )}
214
- * />
215
- * )
216
- *
217
- * ```
218
- *
219
- * See related props: `swipeActions`, `disableSwipeActions`, `swipeActionWidth`
220
- */
221
- renderSwipeAction?: SwipeableProps['renderSwipeAction']
222
- /**
223
- * How wide the swipe actions are. Default: 80
224
- *
225
- * See related props: `swipeActions`, `disableSwipeActions`, `renderSwipeAction`
226
- */
227
- swipeActionWidth?: SwipeableProps['actionWidth']
228
- /**
229
- * Custom function to render the media that's in a message. It could be a image or video.
230
- */
231
- renderMessageMedia?: MessageProps['renderMedia']
232
- messageVerticalMargin?: number
233
- /**
234
- * Function that generates a random ID for messages that are sent. By default, it uses uuid.v4()
235
- */
236
- messageIdGenerator?: () => string
237
- /**
238
- * _Deprecated_ use the `namesOfUsersTyping` prop instead.
239
- *
240
- * Boolean to indicate if users are typing. Can be used with the `useMessages` hook.
241
- * @example
242
- * ```
243
- * const [{data}, {usersAreTyping}] = useMessages({ id: 'someRoomId' })
244
- *
245
- * return <Messages messages={data} usersAreTyping={usersAreTyping} />
246
- * ```
247
- */
248
- // usersAreTyping?: boolean
249
- /**
250
- * List of the names of people typing. This can be useful if you want to show text like:
251
- * "Michael, Jim & Jan are typing..."
252
- *
253
- * Can be used with the `useMessages` hook.
254
- * @example
255
- * ```
256
- * // namesOfUsersTyping will not include you if you are typing.
257
- * const [{data}, {namesOfUsersTyping}] = useMessages({ id: 'someRoomId' })
258
- *
259
- * return <Chat messages={data} namesOfUsersTyping={namesOfUsersTyping} />
260
- * ```
261
- */
262
- namesOfUsersTyping?: string[]
263
- /**
264
- * Function to replace the normal <TypingIndicator /> component.
265
- *
266
- * **Note:** This is not a necessary prop to customize the typing indicator. There are many props to customize the typing indicator without rendering a fully new one.
267
- * See `typingIndicatorProps` and `typingIndicatorContainerStyle`
268
- */
269
- renderTypingIndicator?: (props: TypingProps) => ReactNode
270
- extraData?: FlatListProps<MessageModel>['extraData']
271
- MessageComponent?: ComponentType
272
- user: NewMessageModel['user']
273
- hideMyAvatar?: boolean
274
- showAvatarForEveryMessage?: boolean
275
- renderAvatar?: ((props: AvatarProps) => ReactNode) | null
276
- renderMessageFooter?: MessageProps['renderFooter']
277
- /**
278
- * (Optional) Use this to render a custom message component.
279
- * @param props Receives MessageProps
280
- *
281
- * If you're looking to entirely override the message render function in the FlatList component, use the renderItem prop.
282
- */
283
- renderMessage?: null | ((props: MessageProps) => ReactElement)
284
- /**
285
- * (Optional) Use this to render a custom bubble component. This will render inside of the messageWrapper. Not the same as renderMessage, which renders the top-level message component.
286
- * @param props - receives BubbleProps
287
- */
288
- renderBubble?: null | ((props: BubbleProps) => ReactNode)
289
- /**
290
- * If you're thinking of using this, there's a good change you're looking for the renderMessageProp
291
- * (Advanced) You probably shouldn't use this prop unless you want a high level of customization.
292
- * This overrides the default renderItem function for the FlatList.
293
- * See React Native's FlatList renderItem docs.
294
- */
295
- renderItem?: (props: ListRenderItemInfo<MessageModel>) => ReactElement
296
- /**
297
- * (Optional) override default FlatList keyExtractor: (item) => item.id
298
- */
299
- keyExtractor?: FlatListProps<MessageModel>['keyExtractor']
300
- /**
301
- * Render component under the TextInput, similar to the way iMessage does.
302
- * @param props: Same props passed to the Composer
303
- */
304
- renderComposerFooter?: (props: ComposerFooterProps) => ReactNode
305
- /**
306
- * Extend the props for the ListView that renders the messages.
307
- */
308
- flatListProps?: Omit<Omit<FlatListProps<MessageModel>, 'renderItem'>, 'data'>
309
- /**
310
- * Renders at the end of the messages list. Different from renderFooter, which is fixed at the bottom, this moves with the scroll.
311
- */
312
- ListFooterComponent?: FlatListProps<MessageModel>['ListFooterComponent']
313
- /**
314
- * Render React component above the messages.
315
- * For instance, maybe you want to render "New messages ^" to indicate someone should scroll up
316
- */
317
- renderHeader?: () => ReactNode
318
- /**
319
- * Render React component fixed at the bottom below the messages list. Different from ListFooterComponent prop, which scrolls with messages.
320
- */
321
- renderFooter?: () => ReactNode
322
- /**
323
- * Custom composer component. The "Composer" encapsulates the entire creation bar at the bottom.
324
- */
325
- renderComposer?: (props: ComposerProps) => ReactNode
326
- /**
327
- * Custom TextInput component inside the composer. Different from the renderComposer prop, which renders the entire composer component.
328
- */
329
- renderTextInput?: ComposerProps['renderTextInput']
330
- /**
331
- * Custom send button component. The "Composer" encapsulates the entire creation bar at the bottom.
332
- */
333
- renderSendButton?: ComposerProps['renderSendButton']
334
- /**
335
- * Custom view style for the container holding the send button. To edit the background color, see `tintColor` prop.
336
- */
337
- sendButtonContainerStyle?: SendButtonProps['containerStyle']
338
- /**
339
- * Function called when message is pressed.
340
- */
341
- onPressMessage?: (message: MessageModel) => void
342
- /**
343
- * Function called when message is double tapped.
344
- */
345
- onDoubleTapMessage?: (message: MessageModel) => void
346
- /**
347
- * Function called when message is long pressed.
348
- */
349
- onLongPressMessage?: (message: MessageModel) => void
350
- /**
351
- * How long the interval should be to detect a long press.
352
- *
353
- * *Default: 400ms
354
- */
355
- messageLongPressDelay?: MessageProps['longPressDelay']
356
- /**
357
- * What kind of "press" method should work for clicking a message.
358
- * Can be "single" or "double".
359
- *
360
- * Related: messageDoubleTapDelay prop
361
- */
362
- // messagePressType?: MessageProps['pressType']
363
- /**
364
- * How long the interval should be between taps to detect a double tap.
365
- * **Important** The `messagePressType` prop must be set to "double" for this to apply.
366
- *
367
- * *Default: 200ms*
368
- */
369
- messageDoubleTapDelay?: MessageProps['doubleTapDelay']
370
- /**
371
- * See [react-native docs](https://www.google.com/search?q=image+props+react+native&oq=image+props+react+native&aqs=chrome.0.0l5j69i64.1740j0j7&sourceid=chrome&ie=UTF-8) for image props.
372
- */
373
- imageProps?: MessageProps['imageProps']
374
- initialText?: string
375
- /**
376
- * Text that sits in TextInput when it's empty. Defaults to "Type a message..."
377
- */
378
- placeholderText?: InputProps['placeholderText']
379
- /**
380
- * Color for text that sits in TextInput when it's empty.
381
- */
382
- placeholderColor?: InputProps['placeholderColor']
383
- /**
384
- * Boolean to set whether or not the Chat component container should be wrapped with a SafeAreaView.
385
- * Default: `false`
386
- */
387
- safeArea?: boolean
388
- /**
389
- * Override the composer's local media state.
390
- * This can be useful if you're using redux or another similar state manager.
391
- *
392
- * **Note:** must be used with the `onMediaChanged` prop.
393
- */
394
- media?: MessageMedia[]
395
- /**
396
- * Handle the composer's media selection on your own.
397
- * This can be useful if you're using redux or another similar state manager.
398
- *
399
- * **Note:** must be used with the `media` prop.
400
- */
401
- onChangeMedia?: (media: NewMessageModel[]) => void
402
- /**
403
- * funtion that returns a custom component to render composer media
404
- * @params props - ({ media }) => ReactNode
405
- * where media is an array of media items
406
- *
407
- * @example
408
- * ```jsx
409
- * <Messages
410
- * renderComposerMedia={({ media }) =>
411
- * media.map(item => item.contentType === 'image' ? <Image uri={{ uri: item.uri } style={{ height: 100, width: 100 }} /> : null)
412
- * }
413
- * />
414
- * ```
415
- */
416
- renderComposerMedia?: (props: {
417
- media: Omit<MessageMedia, 'url'>
418
- }) => ReactNode
419
- /**
420
- * Dictionary to customize the send button mode based on the input text length. Mode be one of these strings: 'icon', 'text', 'hidden'.
421
- *
422
- * **Default:**
423
-
424
- * ```javascript
425
- * const sendButtonMode = {
426
- * withText: 'icon',
427
- * empty: 'hidden'
428
- * }
429
- * ```
430
- */
431
- sendButtonMode?: PartialInputOptions<SendButtonMode>
432
- /**
433
- * Default: `false`
434
- * Set `true` if you don't want the messages to scroll to the end when you send a new message.
435
- */
436
- disableScrollToBottomOnSend?: boolean
437
- /**
438
- * Optional react-native animated value that tracks the position of the scroll.
439
- *
440
- */
441
- animatedScrollNode?: Animated.Value
442
- /**
443
- * If true, messages will scroll to bottom every time a new message comes in, regardless of who sends it.
444
- * Default: `false`.
445
- * If true, this prop overrides `disableScrollToBottomOnSend`.
446
- */
447
- scrollToBottomOnAllNewMessages?: boolean
448
- /**
449
- * Callback function for when messages are viewed
450
- * @param viewInfo - Dictionary with details about the messages being viewed
451
- * @param viewInfo.visibleMessages - Array of current messages that are visible
452
- * @param viewInfo.latestMessageId - If the most recent message in this chat room is visible, then this will return its ID. Otherwise, this will be null.
453
- *
454
- * `chat` uses the logic from latestMessageId to clear unread counts. This is helpful if you want to avoid uploading to your backend every single time a message is viewed, and instead only when you view the most recent one (since you can clear out the previous.)
455
- * @example
456
- * ```javascript
457
- * export default ({ id }) => {
458
- * const [{ data }, { send }] = useMessages({ id })
459
- * const onViewMessages = useViewMessages({ roomId: id })
460
- *
461
- * return <Messages messages={data} onSend={send} onViewMessages={onViewMessages} />
462
- * }
463
- * ```
464
- */
465
- onViewMessages?: (viewInfo: {
466
- visibleMessages: MessageModel[]
467
- latestMessageId: string | null
468
- }) => void
469
- /**
470
- * **🚨** If you're using this prop to track viewed messages, see the `onViewMessages` prop instead.
471
- *
472
- * Optional FlatList prop. [See react native docs](https://facebook.github.io/react-native/docs/0.18/flatlist#onviewableitemschanged).
473
- */
474
- onViewableItemsChanged?: FlatList<
475
- MessageModel
476
- >['props']['onViewableItemsChanged']
477
- /**
478
- * General tint color for the chat, used for the buttons, text, etc.
479
- */
480
- tintColor?: string
481
- /**
482
- * If true, component will implement its own KeyboardAvoidingView component for ios and android.
483
- *
484
- * Default: `true`
485
- *
486
- * **Note:** If you're using react navigation's stack navigator, this can have bugs. For some reason, the react-navigation's Header component pushes down the view. One solution is to set the stack to `headerTransparent`: `true`. The downside of this is you'll have to set the FlatList's contentContainerStyle to have a top padding to offset the header height. If you're using a bottom tab navigator too, just disable the hiding on keyboard show prop for that navigator.
487
- */
488
- avoidKeyboard?: boolean
489
- /**
490
- * Style the outer container of the composer (not to be confused with `inputContainerStyle`)
491
- */
492
- composerContainerStyle?: StyleProp<ViewStyle>
493
- /**
494
- * Style the container immediately wrapping the TextInput (not to be confused with `composerContainerStyle`)
495
- */
496
- inputContainerStyle?: StyleProp<ViewStyle>
497
- /**
498
- * Directly style the TextInput component.
499
- */
500
- inputStyle?: TextInputProps['style']
501
- // TODO
502
- /**
503
- * **Note:** For basic system message customizations, see these props instead: `systemMessageTextStyle`, `systemMessageTextStyle`, `systemMessageContainerStyle`, `systemMessageDateStyle`, systemMessageDateToStringFunc
504
- *
505
- * This prop is a function that returns a custom system message component. You can also extend the <SystemMessage /> component if you'd like.
506
- *
507
- * @example
508
- * ```javascript
509
- * return <Messages renderSystemMessage={props => (
510
- * <SystemMessage
511
- * {...props}
512
- * // custom props
513
- * />
514
- * )} />
515
- * ```
516
- */
517
- renderSystemMessage?: null | ((props: SystemMessageProps) => ReactElement)
518
- /**
519
- * Style the text for a custom message.
520
- */
521
- systemMessageTextStyle?: StyleProp<TextStyle>
522
- /**
523
- * Style the view that wraps a system message and its date.
524
- */
525
- systemMessageContainerStyle?: StyleProp<ViewStyle>
526
- /**
527
- * Style the text for a system message's date.
528
- */
529
- systemMessageDateStyle?: StyleProp<TextStyle>
530
- /**
531
- * System that dates in a date and returns a string to be printed as the date for system messages.
532
- *
533
- * By default, uses moment.js. This is the default function:
534
- * ```javascript
535
- * import moment from 'moment'
536
- *
537
- * date => moment(date).calendar(undefined, {
538
- * lastDay: '[Yesterday]',
539
- * sameDay: 'LT',
540
- * nextDay: '[Tomorrow at] LT',
541
- * lastWeek: 'dddd',
542
- * nextWeek: '[Next] dddd',
543
- * sameElse: 'L'
544
- * })
545
- * ```
546
- */
547
- systemMessageDateToStringFunc?: SystemMessageProps['dateToStringFunc']
548
- /**
549
- * Style the text that shows a person's name above their message.
550
- */
551
- nameStyle?: TextStyle
552
- /**
553
- * Boolean to enable name being shown every time someone else sends a message. Default `false`.
554
- *
555
- * @remarks
556
- * To enable name for messages the user sends too, see the `showMyName` prop.
557
- */
558
- showNameForEveryMessage?: boolean
559
- /**
560
- * Boolean to enable name being for the person sending messages. Default `false`
561
- */
562
- showMyName?: boolean
563
- /**
564
- * Custom function to render a date in between messages. Dates are rendered in between messages when messages are sent on a new day.
565
- */
566
- renderDate?: null | ((date: Date) => ReactNode)
567
- /**
568
- * See React Native's ScrollView docs. This prop manages whether or not the chat scrollview should persist through taps when keyboard is open.
569
- */
570
- keyboardShouldPersistTaps?: ScrollViewProps['keyboardShouldPersistTaps']
571
- /**
572
- * See React Native's ScrollView docs. This prop manages the way the keyboard is closed when someone scrolls
573
- */
574
- keyboardDismissMode?: ScrollViewProps['keyboardDismissMode']
575
- /**
576
- * Ref that gets forwarded to the Messages component. Exposes the following methods:
577
- *
578
- * - `focusInput` (for input)
579
- * - `blurInput` (for input)
580
- * - `scrollToEnd` Remember that this FlatList is inverted so you should think of 0 as the bottom of the screen. (see: [FlatList docs](https://facebook.github.io/react-native/docs/flatlist.html#scrolltoend))
581
- * - `scrollToIndex` (see: [FlatList docs](https://facebook.github.io/react-native/docs/flatlist.html#scrolltoindex))
582
- * - `scrollToItem` (see: [FlatList docs](https://facebook.github.io/react-native/docs/flatlist.html#scrolltoitem))
583
- * - `scrollToOffset` Remember that this FlatList is inverted so you should think of 0 as the bottom of the screen. (see: [FlatList docs](https://facebook.github.io/react-native/docs/flatlist.html#scrolltooffset))
584
- *
585
- */
586
- chatRef?: MutableRefObject<ChatRef<MessageModel>>
587
- /**
588
- * size for the avatar/initials component that renders next to messages
589
- * default: `40`
590
- */
591
- avatarSize?: number
592
- /**
593
- * React Native Image props passed to the avatar. For max customization, see `renderAvatar` prop.
594
- */
595
- avatarImageProps?: AvatarProps['imageProps']
596
- /**
597
- * Background color for the initials component that will show in the absense of an avatar.
598
- */
599
- initialsBackgroundColor?: PartialUserOptions<string>
600
- /**
601
- * Text color for the initials component that will show in the absense of an avatar.
602
- */
603
- initialsTextColor?: PartialUserOptions<string>
604
- /**
605
- * Custom component to render the Initials component when there isn't an avatar present.
606
- * Takes one argument (InitialsProps).
607
- *
608
- * @example
609
- * ```javascript
610
- * return <Messages renderInitials={props => <Initials {...props} />} />
611
- * ```
612
- */
613
- renderInitials?: (props: InitialsProps) => ReactNode
614
- /**
615
- * **Important** Use React's `useCallback` hook for this value if you're using react hooks to avoid re-renders.
616
- *
617
- * Function receives one argument: a dictionary with boolean `isMe` value. If true, then this is the screen for the person sending the message.
618
- *
619
- * The return value of this function determines the background color for message bubbles. If an array is returned, it will make a gradient background color.
620
- * This function can return one of the following: 1) string (solid color background), 2) array of strings (for gradient), 3) function that returns a string, or 4) function that returns an array of strings for a gradient.
621
- *
622
- * If a function is returned, it will receive the message as its only argument. This is very useful if you want to have different colors determined by who sent the message, what kind of content it has, etc.
623
- *
624
- * @remarks
625
- * If you return a function, it will receive a dictionary containing the message information, and the message's id as the only argument. It must return an array or string.
626
- *
627
- * @example
628
- * ```js
629
- * const bubbleBackgroundColor = useCallback(({ isMe }) => {
630
- * if (isMe) {
631
- * return 'darkblue' // if you want, you can just return a string for one color
632
- *
633
- * // you can also pass an array of colors for a gradient
634
- * return ['lightgray', 'darkblue']
635
- * }
636
- *
637
- * // instead of a string or array of strings, you could also pass a function:
638
- * // passing a function that returns a color (or array of colors for a gradient) lets you use message data to determine the colors
639
- * return message => message.user.id === 'user_1' ? 'lavender' : 'green'
640
- *
641
- * // or, if you want a gradient, you could do this:
642
- * return message => message.user.name === 'Fernando' ? ['darkgreen', 'lightgray'] : ['lavender', 'lightgray']
643
- *
644
- * }, [])
645
- * return <Messages bubbleBackgroundColor={bubbleBackgroundColor} />
646
- * ```
647
- */
648
- bubbleBackgroundColor?: PartialUserOptions<
649
- MessageProps['bubbleBackgroundColor']
650
- >
651
- /**
652
- * **Important** Be sure to use `useCallback` for this value if you're using react hooks to avoid re-renders.
653
- * Edit the bubble's text color based on who sent a message. Takes a dictionary {me, others} where each key optionally takes a color string argument.
654
- *
655
- * @example
656
- * ```js
657
- * const bubbleTextColor = useCallback(({ isMe }) => ({ color: isMe ? 'white' : 'black' }), [])
658
- * return <Messages bubbleTextColor={bubbleTextColor} />
659
- * ```
660
- */
661
- bubbleTextColor?: PartialUserOptions<BubbleProps['textColor']>
662
- /**
663
- * Custom React Component to replace the default React Native image. Perhaps you use fast image or expo image cache here.
664
- */
665
- AvatarImageComponent?: ComponentType
666
- /**
667
- * Pass props to the `<TypingIndicator />` component.
668
- * If using react hooks, be sure to use `useMemo` for the props you pass to avoid re-render.
669
- */
670
- typingIndicatorProps?: TypingIndicatorProps
671
- /**
672
- * React native `View` props, passed to the view that holds the typing indicator whenever someone is typing.
673
- */
674
- typingIndicatorContainerStyle?: ViewStyle
675
- /**
676
- * Boolean. If `true`, the names of people typing will show up next to the typing indicator.
677
- * If `false`, names won't show up.
678
- *
679
- * Fredrick, Franklin, and Finkleberry are typing...
680
- */
681
- showTypingText?: boolean
682
- /**
683
- * Allow send when you press enter.
684
- */
685
- sendOnKeyboardReturn?: boolean
686
- /**
687
- * Optional function that returns a react element to render the text of a message. Receives the message as props.
688
- */
689
- renderMessageText?: (props: {
690
- text: string
691
- style: StyleProp<TextStyle>
692
- }) => ReactNode
693
- }
694
-
695
- export interface MessageProps<
696
- MessageModel extends NewMessageModel = NewMessageModel
697
- > {
698
- renderText?: ChatProps['renderMessageText']
699
- id: string
700
- isMe: boolean
701
- text: MessageModel['text']
702
- system: MessageModel['system']
703
- bubbleTextStyle?: StyleProp<TextStyle>
704
- bubbleStyle?: StyleProp<ViewStyle>
705
- messageContainerStyle?: StyleProp<ViewStyle>
706
- messageWrapperStyle?: StyleProp<ViewStyle>
707
- name: MessageModel['user']['name']
708
- delivered?: boolean
709
- read?: boolean
710
- renderFooter?: (props: { id: string }) => ReactNode
711
- // flatten media props
712
- mediaHeight?: MessageMedia['height']
713
- mediaWidth?: MessageMedia['width']
714
- mediaUrl?: MessageMedia['url']
715
- mediaUri?: MessageMedia['uri']
716
- mediaContentType?: MessageMedia['contentType']
717
- renderMedia?: (props: { media: MessageMedia }) => ReactNode
718
- // onPress?: (message: MessageModel) => void
719
- // onLongPress?: (message: MessageModel) => void
720
- // onDoubleTap?: (message: MessageModel) => void
721
- onPress?: TouchableProps['onPress']
722
- onLongPress?: TouchableProps['onLongPress']
723
- onDoubleTap?: TouchableProps['onDoubleTap']
724
- doubleTapDelay?: number
725
- longPressDelay?: number
726
- imageProps?: Image['props']
727
- // pressType: 'single' | 'double'
728
- disableSwipeActions?: SwipeableProps['disableSwipeActions']
729
- swipeActions?: SwipeableProps['swipeActions']
730
- renderSwipeAction?: SwipeableProps['renderSwipeAction']
731
- swipeActionWidth?: SwipeableProps['actionWidth']
732
- showName?: boolean
733
- avatar?: string
734
- avatarImageProps?: ChatProps['avatarImageProps']
735
- avatarSize?: ChatProps['avatarSize']
736
- renderAvatar?: ChatProps['renderAvatar']
737
- showAvatar?: boolean
738
- initialsBackgroundColor?: string
739
- initialsTextColor?: string
740
- renderInitials?: ChatProps['renderInitials']
741
- tintColor?: string
742
- nameStyle?: ChatProps['nameStyle']
743
- bubbleBackgroundColor?: BubbleBackgroundColor
744
- bubbleTextColor?: BubbleProps['textColor']
745
- userId?: MessageModel['user']['id']
746
- userName?: MessageModel['user']['name']
747
- AvatarImageComponent?: ChatProps['AvatarImageComponent']
748
- /**
749
- * boolean to indicate whether or not this message creates a new "bunch", meaning the person sending it is different from the person who sent the previous message.
750
- * This is useful for adding extra margin between messages sent by different people.
751
- */
752
- createsNewBunch?: boolean
753
- createdAt: Date
754
- }
755
-
756
- export interface ChatRef<
757
- MessageModel extends NewMessageModel = NewMessageModel
758
- > extends Partial<FlatList<MessageModel>> {
759
- focusInput: () => void
760
- blurInput: () => void
761
- }
762
-
763
- export interface BubbleProps {
764
- renderText?: ChatProps['renderMessageText']
765
- style?: StyleProp<ViewStyle>
766
- textStyle?: StyleProp<ViewStyle>
767
- isMe?: boolean
768
- text?: string
769
- bubbleRef?: MutableRefObject<View>
770
- backgroundColor?: string[]
771
- textColor?: string
772
- mediaHeight?: MessageProps['mediaHeight']
773
- mediaWidth?: MessageProps['mediaWidth']
774
- mediaUrl?: MessageProps['mediaUrl']
775
- mediaUri?: MessageProps['mediaUri']
776
- mediaContentType?: MessageProps['mediaContentType']
777
- renderMedia?: MessageProps['renderMedia']
778
- }
779
-
780
- type BubbleBackgroundColor<
781
- MessageModel extends NewMessageModel = NewMessageModel
782
- > = string | string[] | ((message: MessageModel) => string | string[])
783
- // | ((message: {
784
- // user: MessageModel['user']
785
- // id: MessageModel['id']
786
- // }) => string | string[])
787
-
788
- export interface SystemMessageProps<
789
- MessageModel extends NewMessageModel = NewMessageModel
790
- > {
791
- textStyle?: StyleProp<TextStyle>
792
- dateStyle?: StyleProp<TextStyle>
793
- containerStyle?: StyleProp<ViewStyle>
794
- text: MessageModel['text']
795
- createdAt: MessageModel['createdAt']
796
- dateToStringFunc?: (date: Date) => string
797
- }
798
-
799
- export interface ComposerProps<
800
- MessageModel extends NewMessageModel = NewMessageModel
801
- > {
802
- renderTextInput?: (props: InputProps) => ReactNode
803
- renderSendButton?: (props: SendButtonProps) => ReactNode
804
- sendButtonContainerStyle?: SendButtonProps['containerStyle']
805
- textInputProps?: InputProps<MessageModel>['inputProps']
806
- text?: InputProps<MessageModel>['text']
807
- onInputTextChanged?: (text: string) => void
808
- placeholderText?: InputProps<MessageModel>['placeholderText']
809
- placeholderColor?: InputProps<MessageModel>['placeholderColor']
810
- initialText?: string
811
- media?: MessageMedia[]
812
- user: ChatProps<MessageModel>['user']
813
- onChangeMedia?: ChatProps<MessageModel>['onChangeMedia']
814
- onSend: ChatProps<MessageModel>['onSend']
815
- sendButtonMode?: ChatProps['sendButtonMode']
816
- tintColor?: string
817
- containerStyle?: ChatProps['composerContainerStyle']
818
- inputContainerStyle?: ChatProps['inputContainerStyle']
819
- inputStyle?: ChatProps['inputStyle']
820
- inputRef?: MutableRefObject<TextInput>
821
- /**
822
- * Allow send when you press enter.
823
- */
824
- sendOnKeyboardReturn?: boolean
825
- }
826
-
827
- export interface InputProps<
828
- MessageModel extends NewMessageModel = NewMessageModel
829
- > {
830
- text: string
831
- onChangeText: ChatProps<MessageModel>['onInputTextChanged']
832
- inputProps?: TextInputProps
833
- placeholderText?: string
834
- placeholderColor?: string
835
- tintColor?: string
836
- containerStyle?: ChatProps['inputContainerStyle']
837
- style?: ChatProps['inputStyle']
838
- inputRef?: MutableRefObject<TextInput>
839
- /**
840
- * Allow send when you press enter.
841
- */
842
- sendOnKeyboardReturn?: boolean
843
- onSubmitEditing?: TextInputProps['onSubmitEditing']
844
- }
845
-
846
- export interface ComposerFooterProps<
847
- MessageModel extends NewMessageModel = NewMessageModel
848
- > {
849
- text: ComposerProps<MessageModel>['text']
850
- }
851
-
852
- export interface SendButtonProps<
853
- MessageModel extends NewMessageModel = NewMessageModel
854
- > {
855
- text?: string
856
- onSend: () => void
857
- media?: MessageMedia[]
858
- user?: MessageModel['user']
859
- mode: SendButtonMode
860
- containerStyle?: ViewStyle
861
- tintColor?: string
862
- }
863
-
864
- export type SwipeAction = 'reply' | 'edit' | 'delete' | 'react'
865
- export type SendButtonMode = 'icon' | 'text' | 'hidden'
866
-
867
- // TODO add a function validator that confirms that there's a keyof one of these values
868
- export type UserOptions<OptionType> = (info: { isMe: boolean }) => OptionType
869
-
870
- // export interface InputOptions<Option, EmtpyOption = null> {
871
- // withText: EmtpyOption | Option
872
- // empty: Option
873
- // }
874
- export type InputOptions<Option> = (info: { hasText: boolean }) => Option
875
- export type PartialInputOptions<Option> = InputOptions<Option>
876
-
877
- // export type PartialInputOptions<Option> = Partial<InputOptions<Option>>
878
-
879
- // export type PartialUserOptions<OptionType> = Partial<UserOptions<OptionType>>
880
- export type PartialUserOptions<OptionType> = UserOptions<OptionType>
881
-
882
- export interface SwipeableProps {
883
- disableSwipeActions?: boolean
884
- swipeActions?: { right?: SwipeAction[]; left?: SwipeAction[] }
885
- renderSwipeAction?: (action: SwipeActionProps) => ReactNode
886
- actionWidth?: SwipeActionProps['width']
887
- }
888
-
889
- export interface SwipeActionProps {
890
- progress?: Animated.Value | Animated.AnimatedInterpolation
891
- drag?: Animated.AnimatedInterpolation
892
- action: SwipeAction
893
- width?: number
894
- }
895
-
896
- export interface TypingFooterProps extends TypingIndicatorProps, TypingProps {
897
- containerStyle?: ViewStyle
898
- typingText?: string
899
- }
900
-
901
- export interface TypingProps {
902
- // usersAreTyping: boolean
903
- numberOfUsersTyping?: number
904
- }
905
-
906
- export interface TouchableProps {
907
- id: string
908
- onPress?: (id: string) => void
909
- onLongPress?: (id: string) => void
910
- onDoubleTap?: (id: string) => void
911
- longPressDelay?: ChatProps['messageLongPressDelay']
912
- doubleTapDelay?: ChatProps['messageDoubleTapDelay']
913
- }