react-native-gifted-chat 3.3.0 → 3.3.3

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 (326) hide show
  1. package/CHANGELOG.md +435 -0
  2. package/README.md +68 -12
  3. package/lib/Actions.d.ts +16 -0
  4. package/lib/Actions.d.ts.map +1 -0
  5. package/lib/Actions.js +65 -0
  6. package/lib/Actions.js.map +1 -0
  7. package/lib/Avatar.d.ts +19 -0
  8. package/lib/Avatar.d.ts.map +1 -0
  9. package/lib/Avatar.js +93 -0
  10. package/lib/Avatar.js.map +1 -0
  11. package/lib/Bubble/index.d.ts +6 -0
  12. package/lib/Bubble/index.d.ts.map +1 -0
  13. package/lib/Bubble/index.js +269 -0
  14. package/lib/Bubble/index.js.map +1 -0
  15. package/lib/Bubble/styles.d.ts +57 -0
  16. package/lib/Bubble/styles.d.ts.map +1 -0
  17. package/lib/Bubble/styles.js +59 -0
  18. package/lib/Bubble/styles.js.map +1 -0
  19. package/lib/Bubble/types.d.ts +59 -0
  20. package/lib/Bubble/types.d.ts.map +1 -0
  21. package/lib/Bubble/types.js +2 -0
  22. package/lib/Bubble/types.js.map +1 -0
  23. package/lib/Color.d.ts +18 -0
  24. package/lib/Color.d.ts.map +1 -0
  25. package/lib/Color.js +18 -0
  26. package/lib/Color.js.map +1 -0
  27. package/lib/Composer.d.ts +9 -0
  28. package/lib/Composer.d.ts.map +1 -0
  29. package/lib/Composer.js +56 -0
  30. package/lib/Composer.js.map +1 -0
  31. package/lib/Constant.d.ts +8 -0
  32. package/lib/Constant.d.ts.map +1 -0
  33. package/lib/Constant.js +8 -0
  34. package/lib/Constant.js.map +1 -0
  35. package/lib/Day/index.d.ts +5 -0
  36. package/lib/Day/index.d.ts.map +1 -0
  37. package/lib/Day/index.js +40 -0
  38. package/lib/Day/index.js.map +1 -0
  39. package/lib/Day/styles.d.ts +21 -0
  40. package/lib/Day/styles.d.ts.map +1 -0
  41. package/lib/Day/styles.js +22 -0
  42. package/lib/Day/styles.js.map +1 -0
  43. package/lib/Day/types.d.ts +11 -0
  44. package/lib/Day/types.d.ts.map +1 -0
  45. package/lib/Day/types.js +2 -0
  46. package/lib/Day/types.js.map +1 -0
  47. package/lib/GiftedAvatar.d.ts +12 -0
  48. package/lib/GiftedAvatar.d.ts.map +1 -0
  49. package/lib/GiftedAvatar.js +101 -0
  50. package/lib/GiftedAvatar.js.map +1 -0
  51. package/lib/GiftedChat/index.d.ts +10 -0
  52. package/lib/GiftedChat/index.d.ts.map +1 -0
  53. package/lib/GiftedChat/index.js +241 -0
  54. package/lib/GiftedChat/index.js.map +1 -0
  55. package/lib/GiftedChat/styles.d.ts +13 -0
  56. package/lib/GiftedChat/styles.d.ts.map +1 -0
  57. package/lib/GiftedChat/styles.js +13 -0
  58. package/lib/GiftedChat/styles.js.map +1 -0
  59. package/lib/GiftedChat/types.d.ts +90 -0
  60. package/lib/GiftedChat/types.d.ts.map +1 -0
  61. package/lib/GiftedChat/types.js +2 -0
  62. package/lib/GiftedChat/types.js.map +1 -0
  63. package/lib/GiftedChatContext.d.ts +11 -0
  64. package/lib/GiftedChatContext.d.ts.map +1 -0
  65. package/lib/GiftedChatContext.js +10 -0
  66. package/lib/GiftedChatContext.js.map +1 -0
  67. package/lib/InputToolbar.d.ts +36 -0
  68. package/lib/InputToolbar.d.ts.map +1 -0
  69. package/lib/InputToolbar.js +108 -0
  70. package/lib/InputToolbar.js.map +1 -0
  71. package/lib/LoadEarlierMessages.d.ts +17 -0
  72. package/lib/LoadEarlierMessages.d.ts.map +1 -0
  73. package/lib/LoadEarlierMessages.js +45 -0
  74. package/lib/LoadEarlierMessages.js.map +1 -0
  75. package/lib/Message/index.d.ts +6 -0
  76. package/lib/Message/index.d.ts.map +1 -0
  77. package/lib/Message/index.js +180 -0
  78. package/lib/Message/index.js.map +1 -0
  79. package/lib/Message/styles.d.ts +18 -0
  80. package/lib/Message/styles.d.ts.map +1 -0
  81. package/lib/Message/styles.js +18 -0
  82. package/lib/Message/styles.js.map +1 -0
  83. package/lib/Message/types.d.ts +25 -0
  84. package/lib/Message/types.d.ts.map +1 -0
  85. package/lib/Message/types.js +2 -0
  86. package/lib/Message/types.js.map +1 -0
  87. package/lib/MessageAudio.d.ts +3 -0
  88. package/lib/MessageAudio.d.ts.map +1 -0
  89. package/lib/MessageAudio.js +25 -0
  90. package/lib/MessageAudio.js.map +1 -0
  91. package/lib/MessageImage.d.ts +12 -0
  92. package/lib/MessageImage.d.ts.map +1 -0
  93. package/lib/MessageImage.js +164 -0
  94. package/lib/MessageImage.js.map +1 -0
  95. package/lib/MessageReply.d.ts +15 -0
  96. package/lib/MessageReply.d.ts.map +1 -0
  97. package/lib/MessageReply.js +103 -0
  98. package/lib/MessageReply.js.map +1 -0
  99. package/lib/MessageText.d.ts +24 -0
  100. package/lib/MessageText.d.ts.map +1 -0
  101. package/lib/MessageText.js +41 -0
  102. package/lib/MessageText.js.map +1 -0
  103. package/lib/MessageVideo.d.ts +3 -0
  104. package/lib/MessageVideo.d.ts.map +1 -0
  105. package/lib/MessageVideo.js +25 -0
  106. package/lib/MessageVideo.js.map +1 -0
  107. package/lib/MessagesContainer/components/DayAnimated/index.d.ts +5 -0
  108. package/lib/MessagesContainer/components/DayAnimated/index.d.ts.map +1 -0
  109. package/lib/MessagesContainer/components/DayAnimated/index.js +92 -0
  110. package/lib/MessagesContainer/components/DayAnimated/index.js.map +1 -0
  111. package/lib/MessagesContainer/components/DayAnimated/styles.d.ts +12 -0
  112. package/lib/MessagesContainer/components/DayAnimated/styles.d.ts.map +1 -0
  113. package/lib/MessagesContainer/components/DayAnimated/styles.js +12 -0
  114. package/lib/MessagesContainer/components/DayAnimated/styles.js.map +1 -0
  115. package/lib/MessagesContainer/components/DayAnimated/types.d.ts +18 -0
  116. package/lib/MessagesContainer/components/DayAnimated/types.d.ts.map +1 -0
  117. package/lib/MessagesContainer/components/DayAnimated/types.js +2 -0
  118. package/lib/MessagesContainer/components/DayAnimated/types.js.map +1 -0
  119. package/lib/MessagesContainer/components/Item/index.d.ts +23 -0
  120. package/lib/MessagesContainer/components/Item/index.d.ts.map +1 -0
  121. package/lib/MessagesContainer/components/Item/index.js +120 -0
  122. package/lib/MessagesContainer/components/Item/index.js.map +1 -0
  123. package/lib/MessagesContainer/components/Item/types.d.ts +19 -0
  124. package/lib/MessagesContainer/components/Item/types.d.ts.map +1 -0
  125. package/lib/MessagesContainer/components/Item/types.js +2 -0
  126. package/lib/MessagesContainer/components/Item/types.js.map +1 -0
  127. package/lib/MessagesContainer/index.d.ts +6 -0
  128. package/lib/MessagesContainer/index.d.ts.map +1 -0
  129. package/lib/MessagesContainer/index.js +258 -0
  130. package/lib/MessagesContainer/index.js.map +1 -0
  131. package/lib/MessagesContainer/styles.d.ts +55 -0
  132. package/lib/MessagesContainer/styles.d.ts.map +1 -0
  133. package/lib/MessagesContainer/styles.js +42 -0
  134. package/lib/MessagesContainer/styles.js.map +1 -0
  135. package/lib/MessagesContainer/types.d.ts +88 -0
  136. package/lib/MessagesContainer/types.d.ts.map +1 -0
  137. package/lib/MessagesContainer/types.js +10 -0
  138. package/lib/MessagesContainer/types.js.map +1 -0
  139. package/lib/Models.d.ts +58 -0
  140. package/lib/Models.d.ts.map +1 -0
  141. package/lib/Models.js +2 -0
  142. package/lib/Models.js.map +1 -0
  143. package/lib/QuickReplies.d.ts +16 -0
  144. package/lib/QuickReplies.d.ts.map +1 -0
  145. package/lib/QuickReplies.js +108 -0
  146. package/lib/QuickReplies.js.map +1 -0
  147. package/lib/Reply/index.d.ts +2 -0
  148. package/lib/Reply/index.d.ts.map +1 -0
  149. package/lib/Reply/index.js +2 -0
  150. package/lib/Reply/index.js.map +1 -0
  151. package/lib/Reply/types.d.ts +72 -0
  152. package/lib/Reply/types.d.ts.map +1 -0
  153. package/lib/Reply/types.js +2 -0
  154. package/lib/Reply/types.js.map +1 -0
  155. package/lib/ReplyPreview.d.ts +14 -0
  156. package/lib/ReplyPreview.d.ts.map +1 -0
  157. package/lib/ReplyPreview.js +95 -0
  158. package/lib/ReplyPreview.js.map +1 -0
  159. package/lib/Send.d.ts +19 -0
  160. package/lib/Send.d.ts.map +1 -0
  161. package/lib/Send.js +57 -0
  162. package/lib/Send.js.map +1 -0
  163. package/lib/SystemMessage.d.ts +14 -0
  164. package/lib/SystemMessage.d.ts.map +1 -0
  165. package/lib/SystemMessage.js +42 -0
  166. package/lib/SystemMessage.js.map +1 -0
  167. package/lib/Time.d.ts +12 -0
  168. package/lib/Time.d.ts.map +1 -0
  169. package/lib/Time.js +39 -0
  170. package/lib/Time.js.map +1 -0
  171. package/lib/TypingIndicator/index.d.ts +5 -0
  172. package/lib/TypingIndicator/index.d.ts.map +1 -0
  173. package/lib/TypingIndicator/index.js +94 -0
  174. package/lib/TypingIndicator/index.js.map +1 -0
  175. package/lib/TypingIndicator/styles.d.ts +21 -0
  176. package/lib/TypingIndicator/styles.d.ts.map +1 -0
  177. package/lib/TypingIndicator/styles.js +22 -0
  178. package/lib/TypingIndicator/styles.js.map +1 -0
  179. package/lib/TypingIndicator/types.d.ts +6 -0
  180. package/lib/TypingIndicator/types.d.ts.map +1 -0
  181. package/lib/TypingIndicator/types.js +2 -0
  182. package/lib/TypingIndicator/types.js.map +1 -0
  183. package/lib/components/MessageReply.d.ts +29 -0
  184. package/lib/components/MessageReply.d.ts.map +1 -0
  185. package/lib/components/MessageReply.js +87 -0
  186. package/lib/components/MessageReply.js.map +1 -0
  187. package/lib/components/ReplyPreview.d.ts +17 -0
  188. package/lib/components/ReplyPreview.d.ts.map +1 -0
  189. package/lib/components/ReplyPreview.js +148 -0
  190. package/lib/components/ReplyPreview.js.map +1 -0
  191. package/lib/components/TouchableOpacity.d.ts +9 -0
  192. package/lib/components/TouchableOpacity.d.ts.map +1 -0
  193. package/lib/components/TouchableOpacity.js +37 -0
  194. package/lib/components/TouchableOpacity.js.map +1 -0
  195. package/lib/hooks/useColorScheme.d.ts +8 -0
  196. package/lib/hooks/useColorScheme.d.ts.map +1 -0
  197. package/lib/hooks/useColorScheme.js +17 -0
  198. package/lib/hooks/useColorScheme.js.map +1 -0
  199. package/lib/hooks/useUpdateLayoutEffect.d.ts +9 -0
  200. package/lib/hooks/useUpdateLayoutEffect.d.ts.map +1 -0
  201. package/lib/hooks/useUpdateLayoutEffect.js +17 -0
  202. package/lib/hooks/useUpdateLayoutEffect.js.map +1 -0
  203. package/lib/index.d.ts +31 -0
  204. package/lib/index.d.ts.map +1 -0
  205. package/lib/index.js +31 -0
  206. package/lib/index.js.map +1 -0
  207. package/lib/linkParser.d.ts +39 -0
  208. package/lib/linkParser.d.ts.map +1 -0
  209. package/lib/linkParser.js +154 -0
  210. package/lib/linkParser.js.map +1 -0
  211. package/lib/logging.d.ts +3 -0
  212. package/lib/logging.d.ts.map +1 -0
  213. package/lib/logging.js +5 -0
  214. package/lib/logging.js.map +1 -0
  215. package/lib/styles.d.ts +14 -0
  216. package/lib/styles.d.ts.map +1 -0
  217. package/lib/styles.js +23 -0
  218. package/lib/styles.js.map +1 -0
  219. package/lib/types.d.ts +19 -0
  220. package/lib/types.d.ts.map +1 -0
  221. package/lib/types.js +2 -0
  222. package/lib/types.js.map +1 -0
  223. package/lib/utils.d.ts +8 -0
  224. package/lib/utils.d.ts.map +1 -0
  225. package/lib/utils.js +105 -0
  226. package/lib/utils.js.map +1 -0
  227. package/package.json +12 -11
  228. package/src/Actions.tsx +0 -110
  229. package/src/Avatar.tsx +0 -169
  230. package/src/Bubble/index.tsx +0 -407
  231. package/src/Bubble/styles.ts +0 -66
  232. package/src/Bubble/types.ts +0 -104
  233. package/src/Color.ts +0 -17
  234. package/src/Composer.tsx +0 -100
  235. package/src/Constant.ts +0 -8
  236. package/src/Day/index.tsx +0 -63
  237. package/src/Day/styles.ts +0 -22
  238. package/src/Day/types.ts +0 -15
  239. package/src/GiftedAvatar.tsx +0 -187
  240. package/src/GiftedChat/index.tsx +0 -420
  241. package/src/GiftedChat/styles.ts +0 -10
  242. package/src/GiftedChat/types.ts +0 -156
  243. package/src/GiftedChatContext.ts +0 -25
  244. package/src/InputToolbar.tsx +0 -177
  245. package/src/LoadEarlierMessages.tsx +0 -94
  246. package/src/Message/index.tsx +0 -273
  247. package/src/Message/styles.ts +0 -18
  248. package/src/Message/types.ts +0 -26
  249. package/src/MessageAudio.tsx +0 -29
  250. package/src/MessageImage.tsx +0 -251
  251. package/src/MessageReply.tsx +0 -160
  252. package/src/MessageText.tsx +0 -111
  253. package/src/MessageVideo.tsx +0 -29
  254. package/src/MessagesContainer/components/DayAnimated/index.tsx +0 -151
  255. package/src/MessagesContainer/components/DayAnimated/styles.ts +0 -12
  256. package/src/MessagesContainer/components/DayAnimated/types.ts +0 -12
  257. package/src/MessagesContainer/components/Item/index.tsx +0 -197
  258. package/src/MessagesContainer/components/Item/types.ts +0 -13
  259. package/src/MessagesContainer/index.tsx +0 -434
  260. package/src/MessagesContainer/styles.ts +0 -42
  261. package/src/MessagesContainer/types.ts +0 -102
  262. package/src/Models.ts +0 -66
  263. package/src/QuickReplies.tsx +0 -181
  264. package/src/Reply/index.ts +0 -1
  265. package/src/Reply/types.ts +0 -80
  266. package/src/ReplyPreview.tsx +0 -132
  267. package/src/Send.tsx +0 -115
  268. package/src/SystemMessage.tsx +0 -79
  269. package/src/Time.tsx +0 -64
  270. package/src/TypingIndicator/index.tsx +0 -155
  271. package/src/TypingIndicator/styles.ts +0 -22
  272. package/src/TypingIndicator/types.ts +0 -6
  273. package/src/__tests__/Actions.test.tsx +0 -9
  274. package/src/__tests__/Avatar.test.tsx +0 -17
  275. package/src/__tests__/Bubble.test.tsx +0 -17
  276. package/src/__tests__/Color.test.tsx +0 -5
  277. package/src/__tests__/Composer.test.tsx +0 -10
  278. package/src/__tests__/Constant.test.tsx +0 -5
  279. package/src/__tests__/Day.test.tsx +0 -20
  280. package/src/__tests__/DayAnimated.test.tsx +0 -46
  281. package/src/__tests__/GiftedAvatar.test.tsx +0 -10
  282. package/src/__tests__/GiftedChat.test.tsx +0 -60
  283. package/src/__tests__/InputToolbar.test.tsx +0 -10
  284. package/src/__tests__/LoadEarlier.test.tsx +0 -10
  285. package/src/__tests__/Message.test.tsx +0 -67
  286. package/src/__tests__/MessageImage.test.tsx +0 -24
  287. package/src/__tests__/MessageReply.test.tsx +0 -54
  288. package/src/__tests__/MessageText.test.tsx +0 -15
  289. package/src/__tests__/MessagesContainer.test.tsx +0 -38
  290. package/src/__tests__/ReplyPreview.test.tsx +0 -41
  291. package/src/__tests__/Send.test.tsx +0 -21
  292. package/src/__tests__/SystemMessage.test.tsx +0 -24
  293. package/src/__tests__/Time.test.tsx +0 -26
  294. package/src/__tests__/__snapshots__/Actions.test.tsx.snap +0 -40
  295. package/src/__tests__/__snapshots__/Avatar.test.tsx.snap +0 -17
  296. package/src/__tests__/__snapshots__/Bubble.test.tsx.snap +0 -121
  297. package/src/__tests__/__snapshots__/Color.test.tsx.snap +0 -21
  298. package/src/__tests__/__snapshots__/Composer.test.tsx.snap +0 -51
  299. package/src/__tests__/__snapshots__/Constant.test.tsx.snap +0 -13
  300. package/src/__tests__/__snapshots__/Day.test.tsx.snap +0 -99
  301. package/src/__tests__/__snapshots__/DayAnimated.test.tsx.snap +0 -5
  302. package/src/__tests__/__snapshots__/GiftedAvatar.test.tsx.snap +0 -24
  303. package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +0 -169
  304. package/src/__tests__/__snapshots__/InputToolbar.test.tsx.snap +0 -145
  305. package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +0 -33
  306. package/src/__tests__/__snapshots__/Message.test.tsx.snap +0 -510
  307. package/src/__tests__/__snapshots__/MessageImage.test.tsx.snap +0 -293
  308. package/src/__tests__/__snapshots__/MessageReply.test.tsx.snap +0 -181
  309. package/src/__tests__/__snapshots__/MessageText.test.tsx.snap +0 -29
  310. package/src/__tests__/__snapshots__/ReplyPreview.test.tsx.snap +0 -403
  311. package/src/__tests__/__snapshots__/Send.test.tsx.snap +0 -214
  312. package/src/__tests__/__snapshots__/SystemMessage.test.tsx.snap +0 -77
  313. package/src/__tests__/__snapshots__/Time.test.tsx.snap +0 -22
  314. package/src/__tests__/data.ts +0 -8
  315. package/src/__tests__/utils.test.ts +0 -31
  316. package/src/components/MessageReply.tsx +0 -156
  317. package/src/components/ReplyPreview.tsx +0 -230
  318. package/src/components/TouchableOpacity.tsx +0 -67
  319. package/src/hooks/useColorScheme.ts +0 -18
  320. package/src/hooks/useUpdateLayoutEffect.ts +0 -21
  321. package/src/index.ts +0 -29
  322. package/src/linkParser.tsx +0 -255
  323. package/src/logging.ts +0 -8
  324. package/src/styles.ts +0 -25
  325. package/src/types.ts +0 -25
  326. package/src/utils.ts +0 -134
@@ -1,156 +0,0 @@
1
- import React, { RefObject } from 'react'
2
- import {
3
- TextInput,
4
- StyleProp,
5
- TextStyle,
6
- ViewStyle,
7
- } from 'react-native'
8
- import {
9
- ActionSheetOptions,
10
- } from '@expo/react-native-action-sheet'
11
- import { KeyboardProvider, KeyboardAvoidingViewProps } from 'react-native-keyboard-controller'
12
-
13
- import { ActionsProps } from '../Actions'
14
- import { AvatarProps } from '../Avatar'
15
- import { BubbleProps } from '../Bubble'
16
- import { ComposerProps } from '../Composer'
17
- import { InputToolbarProps } from '../InputToolbar'
18
- import { MessageImageProps } from '../MessageImage'
19
- import { AnimatedList, MessagesContainerProps } from '../MessagesContainer'
20
- import { MessageTextProps } from '../MessageText'
21
- import {
22
- IMessage,
23
- LeftRightStyle,
24
- MessageAudioProps,
25
- MessageVideoProps,
26
- User,
27
- } from '../Models'
28
- import { QuickRepliesProps } from '../QuickReplies'
29
- import { ReplyProps } from '../Reply'
30
- import { SendProps } from '../Send'
31
- import { SystemMessageProps } from '../SystemMessage'
32
- import { TimeProps } from '../Time'
33
-
34
- export interface GiftedChatProps<TMessage extends IMessage> extends Partial<Omit<MessagesContainerProps<TMessage>, 'messageReplyContainerStyle'>> {
35
- /* Messages container ref */
36
- messagesContainerRef?: RefObject<AnimatedList<TMessage>>
37
- /* text input ref */
38
- textInputRef?: RefObject<TextInput>
39
- /* Controls whether or not to show user.name property in the message bubble */
40
- isUsernameVisible?: boolean
41
- /* Messages container style */
42
- messagesContainerStyle?: StyleProp<ViewStyle>
43
- /* Input text; default is undefined, but if specified, it will override GiftedChat's internal state */
44
- text?: string
45
- initialText?: string
46
- /* User sending the messages: { _id, name, avatar } */
47
- user?: User
48
- /* Locale to localize the dates */
49
- locale?: string
50
- /* Force color scheme (light/dark); default is undefined (uses system color scheme) */
51
- colorScheme?: 'light' | 'dark'
52
- /* Format to use for rendering times; default is 'LT' */
53
- timeFormat?: string
54
- /* Format to use for rendering dates; default is 'll' */
55
- dateFormat?: string
56
- /* Format to use for rendering relative times; Today - for now. See more: https://day.js.org/docs/en/plugin/calendar */
57
- dateFormatCalendar?: object
58
- /* Whether to render an avatar for the current user; default is false, only show avatars for other users */
59
- isUserAvatarVisible?: boolean
60
- /* When false, avatars will only be displayed when a consecutive message is from the same user on the same day; default is false */
61
- isAvatarVisibleForEveryMessage?: boolean
62
- /* Render the message avatar at the top of consecutive messages, rather than the bottom; default is false */
63
- isAvatarOnTop?: boolean
64
- /* Extra props to be passed to the <Image> component created by the default renderMessageImage */
65
- imageProps?: MessageImageProps<TMessage>
66
- /* Minimum height of the input toolbar; default is 44 */
67
- minInputToolbarHeight?: number
68
- /* Extra props to be passed to the <TextInput>. See https://reactnative.dev/docs/textinput */
69
- textInputProps?: Partial<React.ComponentProps<typeof TextInput>>
70
- /* Force send button */
71
- isSendButtonAlwaysVisible?: boolean
72
- /* Image style */
73
- imageStyle?: StyleProp<ViewStyle>
74
- /* composer min Height */
75
- minComposerHeight?: number
76
- /* composer min Height */
77
- maxComposerHeight?: number
78
- actions?: Array<{ title: string, action: () => void }>
79
- actionSheetOptionTintColor?: string
80
- quickReplyStyle?: StyleProp<ViewStyle>
81
- quickReplyTextStyle?: StyleProp<TextStyle>
82
- quickReplyContainerStyle?: StyleProp<ViewStyle>
83
- /* optional prop used to place customView below text, image and video views; default is false */
84
- isCustomViewBottom?: boolean
85
- timeTextStyle?: LeftRightStyle<TextStyle>
86
- /* Custom action sheet */
87
- actionSheet?: () => {
88
- showActionSheetWithOptions: (
89
- options: ActionSheetOptions,
90
- callback: (buttonIndex: number) => void | Promise<void>
91
- ) => void
92
- }
93
- /* Callback when a message avatar is tapped */
94
- onPressAvatar?: (user: User) => void
95
- /* Callback when a message avatar is tapped */
96
- onLongPressAvatar?: (user: User) => void
97
- /* Generate an id for new messages. Defaults to a simple random string generator */
98
- messageIdGenerator?: (message?: TMessage) => string
99
- /* Callback when sending a message */
100
- onSend?: (messages: TMessage[]) => void
101
- /* Render a loading view when initializing */
102
- renderLoading?: () => React.ReactNode
103
- /* Custom message avatar; set to null to not render any avatar for the message */
104
- renderAvatar?: null | ((props: AvatarProps<TMessage>) => React.ReactNode)
105
- /* Custom message bubble */
106
- renderBubble?: (props: BubbleProps<TMessage>) => React.ReactNode
107
- /* Custom system message */
108
- renderSystemMessage?: (props: SystemMessageProps<TMessage>) => React.ReactNode
109
- /* Callback when a message bubble is pressed; default is to do nothing */
110
- onPressMessage?: (context: unknown, message: TMessage) => void
111
- /* Callback when a message bubble is long-pressed; default is to show an ActionSheet with "Copy Text" (see example using showActionSheetWithOptions()) */
112
- onLongPressMessage?: (context: unknown, message: TMessage) => void
113
- /* Custom Username container */
114
- renderUsername?: (user: User) => React.ReactNode
115
- /* Reverses display order of messages; default is true */
116
- /* Custom message text */
117
- renderMessageText?: (messageText: MessageTextProps<TMessage>) => React.ReactNode
118
- /* Custom message image */
119
- renderMessageImage?: (props: MessageImageProps<TMessage>) => React.ReactNode
120
- /* Custom message video */
121
- renderMessageVideo?: (props: MessageVideoProps<TMessage>) => React.ReactNode
122
- /* Custom message audio */
123
- renderMessageAudio?: (props: MessageAudioProps<TMessage>) => React.ReactNode
124
- /* Custom view inside the bubble */
125
- renderCustomView?: (props: BubbleProps<TMessage>) => React.ReactNode
126
- /* Custom time inside a message */
127
- renderTime?: (props: TimeProps<TMessage>) => React.ReactNode
128
- /* Custom component to render below the MessagesContainer */
129
- renderChatFooter?: () => React.ReactNode
130
- /* Custom message composer container. Can be a component, element, render function, or null */
131
- renderInputToolbar?: React.ComponentType<InputToolbarProps<TMessage>> | React.ReactElement | ((props: InputToolbarProps<TMessage>) => React.ReactNode) | null
132
- /* Custom text input message composer */
133
- renderComposer?: (props: ComposerProps) => React.ReactNode
134
- /* Custom action button on the left of the message composer */
135
- renderActions?: (props: ActionsProps) => React.ReactNode
136
- /* Custom send button; you can pass children to the original Send component quite easily, for example to use a custom icon (example) */
137
- renderSend?: (props: SendProps<TMessage>) => React.ReactNode
138
- /* Custom second line of actions below the message composer */
139
- renderAccessory?: (props: InputToolbarProps<TMessage>) => React.ReactNode
140
- /* Callback when the Action button is pressed (if set, the default actionSheet will not be used) */
141
- onPressActionButton?: () => void
142
- /* Extra props to be passed to the MessageText component */
143
- messageTextProps?: Partial<MessageTextProps<TMessage>>
144
- renderQuickReplies?: (
145
- quickReplies: QuickRepliesProps<TMessage>
146
- ) => React.ReactNode
147
- renderQuickReplySend?: () => React.ReactNode
148
- keyboardProviderProps?: React.ComponentProps<typeof KeyboardProvider>
149
- /** Props for KeyboardAvoidingView. Use `keyboardVerticalOffset` to account for headers or iOS predictive text bar (~44pt). */
150
- keyboardAvoidingViewProps?: KeyboardAvoidingViewProps
151
- /** Enable animated day label that appears on scroll; default is true */
152
- isDayAnimationEnabled?: boolean
153
-
154
- /** Reply functionality configuration */
155
- reply?: ReplyProps<TMessage>
156
- }
@@ -1,25 +0,0 @@
1
- import { createContext, useContext } from 'react'
2
- import {
3
- ActionSheetOptions,
4
- } from '@expo/react-native-action-sheet'
5
-
6
- export interface IGiftedChatContext {
7
- actionSheet(): {
8
- showActionSheetWithOptions: (
9
- options: ActionSheetOptions,
10
- callback: (buttonIndex?: number) => void | Promise<void>
11
- ) => void
12
- }
13
- getLocale(): string
14
- getColorScheme(): 'light' | 'dark' | null | undefined
15
- }
16
-
17
- export const GiftedChatContext = createContext<IGiftedChatContext>({
18
- getLocale: () => 'en',
19
- actionSheet: () => ({
20
- showActionSheetWithOptions: () => {},
21
- }),
22
- getColorScheme: () => undefined,
23
- })
24
-
25
- export const useChatContext = () => useContext(GiftedChatContext)
@@ -1,177 +0,0 @@
1
- import React, { useCallback, useMemo } from 'react'
2
- import { StyleSheet, View, StyleProp, ViewStyle, TextStyle } from 'react-native'
3
-
4
- import { Actions, ActionsProps } from './Actions'
5
- import { Color } from './Color'
6
- import { ReplyPreview, ReplyPreviewProps } from './components/ReplyPreview'
7
- import { Composer, ComposerProps } from './Composer'
8
- import { useColorScheme } from './hooks/useColorScheme'
9
- import { IMessage, ReplyMessage } from './Models'
10
- import { Send, SendProps } from './Send'
11
- import { renderComponentOrElement } from './utils'
12
-
13
- export type { ReplyPreviewProps } from './components/ReplyPreview'
14
-
15
- export interface InputToolbarProps<TMessage extends IMessage> {
16
- actions?: Array<{ title: string, action: () => void }>
17
- actionSheetOptionTintColor?: string
18
- containerStyle?: StyleProp<ViewStyle>
19
- primaryStyle?: StyleProp<ViewStyle>
20
- renderAccessory?: (props: InputToolbarProps<TMessage>) => React.ReactNode
21
- renderActions?: (props: ActionsProps) => React.ReactNode
22
- renderSend?: (props: SendProps<TMessage>) => React.ReactNode
23
- renderComposer?: (props: ComposerProps) => React.ReactNode
24
- onPressActionButton?: () => void
25
- icon?: () => React.ReactNode
26
- wrapperStyle?: StyleProp<ViewStyle>
27
- /** Reply message to show in preview */
28
- replyMessage?: ReplyMessage | null
29
- /** Callback to clear reply */
30
- onClearReply?: () => void
31
- /** Custom render for reply preview */
32
- renderReplyPreview?: (props: ReplyPreviewProps) => React.ReactNode
33
- /** Style for reply preview container */
34
- replyPreviewContainerStyle?: StyleProp<ViewStyle>
35
- /** Style for reply preview text */
36
- replyPreviewTextStyle?: StyleProp<TextStyle>
37
- }
38
-
39
- export function InputToolbar<TMessage extends IMessage = IMessage> (
40
- props: InputToolbarProps<TMessage>
41
- ) {
42
- const {
43
- renderActions,
44
- onPressActionButton,
45
- renderComposer,
46
- renderSend,
47
- renderAccessory,
48
- actions,
49
- actionSheetOptionTintColor,
50
- icon,
51
- wrapperStyle,
52
- containerStyle,
53
- replyMessage,
54
- onClearReply,
55
- renderReplyPreview: renderReplyPreviewProp,
56
- replyPreviewContainerStyle,
57
- replyPreviewTextStyle,
58
- } = props
59
-
60
- const colorScheme = useColorScheme()
61
-
62
- const containerStyles = useMemo(() => [
63
- styles.container,
64
- colorScheme === 'dark' && styles.container_dark,
65
- containerStyle,
66
- ], [colorScheme, containerStyle])
67
-
68
- const primaryStyles = useMemo(() => [
69
- styles.primary,
70
- props.primaryStyle,
71
- ], [props.primaryStyle])
72
-
73
- const actionsFragment = useMemo(() => {
74
- const actionsProps = {
75
- onPressActionButton,
76
- actions,
77
- actionSheetOptionTintColor,
78
- icon,
79
- wrapperStyle,
80
- containerStyle,
81
- }
82
-
83
- if (renderActions)
84
- return renderComponentOrElement(renderActions, actionsProps)
85
-
86
- if (onPressActionButton)
87
- return <Actions {...actionsProps} />
88
-
89
- return null
90
- }, [
91
- renderActions,
92
- onPressActionButton,
93
- actions,
94
- actionSheetOptionTintColor,
95
- icon,
96
- wrapperStyle,
97
- containerStyle,
98
- ])
99
-
100
- const composerFragment = useMemo(() => {
101
- const composerProps = props as ComposerProps
102
-
103
- if (renderComposer)
104
- return renderComponentOrElement(renderComposer, composerProps)
105
-
106
- return <Composer {...composerProps} />
107
- }, [renderComposer, props])
108
-
109
- const sendFragment = useMemo(() => {
110
- if (renderSend)
111
- return renderComponentOrElement(renderSend, props)
112
-
113
- return <Send {...props} />
114
- }, [renderSend, props])
115
-
116
- const accessoryFragment = useMemo(() => {
117
- if (!renderAccessory)
118
- return null
119
-
120
- return renderComponentOrElement(renderAccessory, props)
121
- }, [renderAccessory, props])
122
-
123
- const handleClearReply = useCallback(() => {
124
- onClearReply?.()
125
- }, [onClearReply])
126
-
127
- const replyPreviewFragment = useMemo(() => {
128
- if (!replyMessage)
129
- return null
130
-
131
- const replyPreviewProps: ReplyPreviewProps = {
132
- replyMessage,
133
- onClearReply: handleClearReply,
134
- containerStyle: replyPreviewContainerStyle,
135
- textStyle: replyPreviewTextStyle,
136
- }
137
-
138
- if (renderReplyPreviewProp)
139
- return renderComponentOrElement(renderReplyPreviewProp, replyPreviewProps)
140
-
141
- return <ReplyPreview {...replyPreviewProps} />
142
- }, [
143
- replyMessage,
144
- handleClearReply,
145
- renderReplyPreviewProp,
146
- replyPreviewContainerStyle,
147
- replyPreviewTextStyle,
148
- ])
149
-
150
- return (
151
- <View style={containerStyles}>
152
- {replyPreviewFragment}
153
- <View style={primaryStyles}>
154
- {actionsFragment}
155
- {composerFragment}
156
- {sendFragment}
157
- </View>
158
- {accessoryFragment}
159
- </View>
160
- )
161
- }
162
-
163
- const styles = StyleSheet.create({
164
- container: {
165
- borderTopWidth: StyleSheet.hairlineWidth,
166
- borderTopColor: Color.defaultColor,
167
- backgroundColor: Color.white,
168
- },
169
- container_dark: {
170
- backgroundColor: '#1a1a1a',
171
- borderTopColor: '#444',
172
- },
173
- primary: {
174
- flexDirection: 'row',
175
- alignItems: 'flex-end',
176
- },
177
- })
@@ -1,94 +0,0 @@
1
- import React from 'react'
2
- import {
3
- ActivityIndicator,
4
- StyleSheet,
5
- View,
6
- StyleProp,
7
- ViewStyle,
8
- TextStyle,
9
- } from 'react-native'
10
- import { Text } from 'react-native-gesture-handler'
11
- import { Color } from './Color'
12
- import { TouchableOpacity } from './components/TouchableOpacity'
13
- import stylesCommon from './styles'
14
-
15
- export interface LoadEarlierMessagesProps {
16
- isAvailable: boolean
17
- isLoading: boolean
18
- onPress: () => void
19
- isInfiniteScrollEnabled?: boolean
20
- label?: string
21
- containerStyle?: StyleProp<ViewStyle>
22
- wrapperStyle?: StyleProp<ViewStyle>
23
- textStyle?: StyleProp<TextStyle>
24
- activityIndicatorStyle?: StyleProp<ViewStyle>
25
- activityIndicatorColor?: string
26
- activityIndicatorSize?: number | 'small' | 'large'
27
- }
28
-
29
- export const LoadEarlierMessages: React.FC<LoadEarlierMessagesProps> = ({
30
- isLoading = false,
31
- onPress,
32
- label = 'Load earlier messages',
33
- containerStyle,
34
- wrapperStyle,
35
- textStyle,
36
- activityIndicatorColor = 'white',
37
- activityIndicatorSize = 'small',
38
- activityIndicatorStyle,
39
- }) => {
40
- return (
41
- <TouchableOpacity
42
- style={[styles.container, containerStyle]}
43
- onPress={onPress}
44
- enabled={!isLoading}
45
- accessibilityRole='button'
46
- >
47
- <View style={[stylesCommon.centerItems, styles.wrapper, wrapperStyle]}>
48
- {
49
- isLoading
50
- ? (
51
- <ActivityIndicator
52
- color={activityIndicatorColor}
53
- size={activityIndicatorSize}
54
- style={[styles.activityIndicator, activityIndicatorStyle]}
55
- />
56
- )
57
- : (
58
- <View style={styles.textContainer}>
59
- <Text style={[styles.text, textStyle]}>
60
- {label}
61
- </Text>
62
- </View>
63
- )
64
- }
65
- </View>
66
- </TouchableOpacity>
67
- )
68
- }
69
-
70
- const styles = StyleSheet.create({
71
- container: {
72
- alignItems: 'center',
73
- marginVertical: 10,
74
- },
75
- wrapper: {
76
- backgroundColor: Color.defaultColor,
77
- borderRadius: 15,
78
- paddingHorizontal: 10,
79
- paddingVertical: 5,
80
- },
81
- textContainer: {
82
- paddingTop: 3,
83
- paddingBottom: 4,
84
- },
85
- text: {
86
- backgroundColor: Color.backgroundTransparent,
87
- color: Color.white,
88
- fontSize: 12,
89
- lineHeight: 13,
90
- },
91
- activityIndicator: {
92
- paddingHorizontal: 20,
93
- },
94
- })