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,155 +0,0 @@
1
- import React, { useCallback, useEffect, useState, useMemo } from 'react'
2
- import { View } from 'react-native'
3
- import Animated, {
4
- runOnJS,
5
- useAnimatedStyle,
6
- useSharedValue,
7
- withDelay,
8
- withRepeat,
9
- withSequence,
10
- withTiming,
11
- } from 'react-native-reanimated'
12
- import stylesCommon from '../styles'
13
-
14
- import styles from './styles'
15
- import { TypingIndicatorProps } from './types'
16
-
17
- export * from './types'
18
-
19
- const DotsAnimation = () => {
20
- const dot1 = useSharedValue(0)
21
- const dot2 = useSharedValue(0)
22
- const dot3 = useSharedValue(0)
23
-
24
- const topY = useMemo(() => -5, [])
25
- const bottomY = useMemo(() => 5, [])
26
- const duration = useMemo(() => 500, [])
27
-
28
- const dot1Style = useAnimatedStyle(() => ({
29
- transform: [{
30
- translateY: dot1.value,
31
- }],
32
- }), [dot1])
33
-
34
- const dot2Style = useAnimatedStyle(() => ({
35
- transform: [{
36
- translateY: dot2.value,
37
- }],
38
- }), [dot2])
39
-
40
- const dot3Style = useAnimatedStyle(() => ({
41
- transform: [{
42
- translateY: dot3.value,
43
- }],
44
- }), [dot3])
45
-
46
- useEffect(() => {
47
- dot1.value = withRepeat(
48
- withSequence(
49
- withTiming(topY, { duration }),
50
- withTiming(bottomY, { duration })
51
- ),
52
- 0,
53
- true
54
- )
55
- }, [dot1, topY, bottomY, duration])
56
-
57
- useEffect(() => {
58
- dot2.value = withDelay(100,
59
- withRepeat(
60
- withSequence(
61
- withTiming(topY, { duration }),
62
- withTiming(bottomY, { duration })
63
- ),
64
- 0,
65
- true
66
- )
67
- )
68
- }, [dot2, topY, bottomY, duration])
69
-
70
- useEffect(() => {
71
- dot3.value = withDelay(200,
72
- withRepeat(
73
- withSequence(
74
- withTiming(topY, { duration }),
75
- withTiming(bottomY, { duration })
76
- ),
77
- 0,
78
- true
79
- )
80
- )
81
- }, [dot3, topY, bottomY, duration])
82
-
83
- return (
84
- <View style={[stylesCommon.fill, stylesCommon.centerItems, styles.dots]}>
85
- <Animated.View style={[styles.dot, dot1Style]} />
86
- <Animated.View style={[styles.dot, dot2Style]} />
87
- <Animated.View style={[styles.dot, dot3Style]} />
88
- </View>
89
- )
90
- }
91
-
92
- export const TypingIndicator = ({ isTyping, style }: TypingIndicatorProps) => {
93
- const yCoords = useSharedValue(200)
94
- const heightScale = useSharedValue(0)
95
- const marginScale = useSharedValue(0)
96
-
97
- const [isVisible, setIsVisible] = useState(isTyping)
98
-
99
- const containerStyle = useAnimatedStyle(() => ({
100
- transform: [
101
- {
102
- translateY: yCoords.value,
103
- },
104
- ],
105
- height: heightScale.value,
106
- marginBottom: marginScale.value,
107
- }), [yCoords, heightScale, marginScale])
108
-
109
- const slideIn = useCallback(() => {
110
- const duration = 250
111
-
112
- yCoords.value = withTiming(0, { duration })
113
- heightScale.value = withTiming(35, { duration })
114
- marginScale.value = withTiming(8, { duration })
115
- }, [yCoords, heightScale, marginScale])
116
-
117
- const slideOut = useCallback(() => {
118
- const duration = 250
119
-
120
- yCoords.value = withTiming(200, { duration }, isFinished => {
121
- if (isFinished)
122
- runOnJS(setIsVisible)(false)
123
- })
124
- heightScale.value = withTiming(0, { duration })
125
- marginScale.value = withTiming(0, { duration })
126
- }, [yCoords, heightScale, marginScale])
127
-
128
- useEffect(() => {
129
- if (isVisible)
130
- if (isTyping)
131
- slideIn()
132
- else
133
- slideOut()
134
- }, [isVisible, isTyping, slideIn, slideOut])
135
-
136
- useEffect(() => {
137
- if (isTyping)
138
- setIsVisible(true)
139
- }, [isTyping])
140
-
141
- if (!isVisible)
142
- return null
143
-
144
- return (
145
- <Animated.View
146
- style={[
147
- styles.container,
148
- containerStyle,
149
- style,
150
- ]}
151
- >
152
- <DotsAnimation />
153
- </Animated.View>
154
- )
155
- }
@@ -1,22 +0,0 @@
1
- import { StyleSheet } from 'react-native'
2
- import { Color } from '../Color'
3
-
4
- export default StyleSheet.create({
5
- container: {
6
- marginLeft: 8,
7
- width: 45,
8
- borderRadius: 15,
9
- backgroundColor: Color.leftBubbleBackground,
10
- },
11
- dots: {
12
- flexDirection: 'row',
13
- },
14
- dot: {
15
- marginLeft: 2,
16
- marginRight: 2,
17
- borderRadius: 4,
18
- width: 8,
19
- height: 8,
20
- backgroundColor: 'rgba(0, 0, 0, 0.38)',
21
- },
22
- })
@@ -1,6 +0,0 @@
1
- import { StyleProp, ViewStyle } from 'react-native'
2
-
3
- export interface TypingIndicatorProps {
4
- isTyping?: boolean
5
- style?: StyleProp<ViewStyle>
6
- }
@@ -1,9 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { Actions } from '..'
5
-
6
- it('should render <Actions /> and compare with snapshot', () => {
7
- const { toJSON } = render(<Actions />)
8
- expect(toJSON()).toMatchSnapshot()
9
- })
@@ -1,17 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { Avatar } from '..'
5
- import { DEFAULT_TEST_MESSAGE } from './data'
6
-
7
- it('should render <Avatar /> and compare with snapshot', () => {
8
- const { toJSON } = render(
9
- <Avatar
10
- renderAvatar={() => 'renderAvatar'}
11
- position='left'
12
- currentMessage={DEFAULT_TEST_MESSAGE}
13
- />
14
- )
15
-
16
- expect(toJSON()).toMatchSnapshot()
17
- })
@@ -1,17 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { Bubble } from '..'
5
- import { DEFAULT_TEST_MESSAGE } from './data'
6
-
7
- it('should render <Bubble /> and compare with snapshot', () => {
8
- const { toJSON } = render(
9
- <Bubble
10
- user={{ _id: 1 }}
11
- currentMessage={DEFAULT_TEST_MESSAGE}
12
- position='left'
13
- />
14
- )
15
-
16
- expect(toJSON()).toMatchSnapshot()
17
- })
@@ -1,5 +0,0 @@
1
- import { Color } from '../Color'
2
-
3
- it('should compare Color with snapshot', () => {
4
- expect(Color).toMatchSnapshot()
5
- })
@@ -1,10 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { Composer } from '..'
5
-
6
- it('should render <Composer /> and compare with snapshot', () => {
7
- const { toJSON } = render(<Composer />)
8
-
9
- expect(toJSON()).toMatchSnapshot()
10
- })
@@ -1,5 +0,0 @@
1
- import * as Constant from '../Constant'
2
-
3
- it('should compare Constant with snapshot', () => {
4
- expect(Constant).toMatchSnapshot()
5
- })
@@ -1,20 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { Day } from '..'
5
- import { DEFAULT_TEST_MESSAGE } from './data'
6
-
7
- describe('Day', () => {
8
- it('should not render <Day /> and compare with snapshot', () => {
9
- const { toJSON } = render(<Day createdAt={DEFAULT_TEST_MESSAGE.createdAt} />)
10
-
11
- expect(toJSON()).toMatchSnapshot()
12
- })
13
-
14
- it('should render <Day /> and compare with snapshot', () => {
15
- const { toJSON } = render(
16
- <Day createdAt={DEFAULT_TEST_MESSAGE.createdAt} />
17
- )
18
- expect(toJSON()).toMatchSnapshot()
19
- })
20
- })
@@ -1,46 +0,0 @@
1
- import React from 'react'
2
- import { View, Text } from 'react-native'
3
- import { render } from '@testing-library/react-native'
4
- import { DayProps } from '../Day'
5
- import { DayAnimated } from '../MessagesContainer/components/DayAnimated'
6
- import { DEFAULT_TEST_MESSAGE } from './data'
7
-
8
- const mockDaysPositions = { value: {} }
9
- const mockScrolledY = { value: 0 }
10
- const mockListHeight = { value: 800 }
11
-
12
- describe('DayAnimated', () => {
13
- it('should render DayAnimated with default Day component', () => {
14
- const { toJSON } = render(
15
- <DayAnimated
16
- scrolledY={mockScrolledY}
17
- daysPositions={mockDaysPositions}
18
- listHeight={mockListHeight}
19
- messages={[DEFAULT_TEST_MESSAGE]}
20
- isLoading={false}
21
- />
22
- )
23
- expect(toJSON()).toMatchSnapshot()
24
- })
25
-
26
- it('should use custom renderDay when provided', () => {
27
- const customRenderDay = jest.fn((props: DayProps) => (
28
- <View testID='custom-day'>
29
- <Text>Custom Day: {props.createdAt.toLocaleString()}</Text>
30
- </View>
31
- ))
32
-
33
- const { toJSON } = render(
34
- <DayAnimated
35
- scrolledY={mockScrolledY}
36
- daysPositions={mockDaysPositions}
37
- listHeight={mockListHeight}
38
- messages={[DEFAULT_TEST_MESSAGE]}
39
- isLoading={false}
40
- renderDay={customRenderDay}
41
- />
42
- )
43
-
44
- expect(toJSON()).toMatchSnapshot()
45
- })
46
- })
@@ -1,10 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { GiftedAvatar } from '..'
5
-
6
- it('should render <GiftedAvatar /> and compare with snapshot', () => {
7
- const { toJSON } = render(<GiftedAvatar />)
8
-
9
- expect(toJSON()).toMatchSnapshot()
10
- })
@@ -1,60 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { GiftedChat } from '..'
5
-
6
- const messages = [
7
- {
8
- _id: 1,
9
- text: 'Hello developer',
10
- createdAt: new Date(),
11
- user: {
12
- _id: 2,
13
- name: 'John Doe',
14
- },
15
- },
16
- ]
17
-
18
- it('should render <GiftedChat/> and compare with snapshot', () => {
19
- const { toJSON } = render(
20
- <GiftedChat
21
- messages={messages}
22
- onSend={() => {}}
23
- user={{
24
- _id: 1,
25
- }}
26
- />
27
- )
28
-
29
- expect(toJSON()).toMatchSnapshot()
30
- })
31
-
32
- it('should render <GiftedChat/> with light colorScheme and compare with snapshot', () => {
33
- const { toJSON } = render(
34
- <GiftedChat
35
- messages={messages}
36
- onSend={() => {}}
37
- user={{
38
- _id: 1,
39
- }}
40
- colorScheme='light'
41
- />
42
- )
43
-
44
- expect(toJSON()).toMatchSnapshot()
45
- })
46
-
47
- it('should render <GiftedChat/> with dark colorScheme and compare with snapshot', () => {
48
- const { toJSON } = render(
49
- <GiftedChat
50
- messages={messages}
51
- onSend={() => {}}
52
- user={{
53
- _id: 1,
54
- }}
55
- colorScheme='dark'
56
- />
57
- )
58
-
59
- expect(toJSON()).toMatchSnapshot()
60
- })
@@ -1,10 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { InputToolbar } from '..'
5
-
6
- it('should render <InputToolbar /> and compare with snapshot', () => {
7
- const { toJSON } = render(<InputToolbar />)
8
-
9
- expect(toJSON()).toMatchSnapshot()
10
- })
@@ -1,10 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { LoadEarlierMessages } from '..'
5
-
6
- it('should render <LoadEarlierMessages /> and compare with snapshot', () => {
7
- const { toJSON } = render(<LoadEarlierMessages isAvailable isLoading={false} onPress={() => {}} />)
8
-
9
- expect(toJSON()).toMatchSnapshot()
10
- })
@@ -1,67 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { Message } from '..'
5
- import { DEFAULT_TEST_MESSAGE } from './data'
6
-
7
- describe('Message component', () => {
8
- it('should render <Message /> and compare with snapshot', () => {
9
- const { toJSON } = render(
10
- <Message
11
- key='123'
12
- user={{ _id: 1 }}
13
- currentMessage={{
14
- _id: 1,
15
- text: 'test',
16
- createdAt: 1554744013721,
17
- user: { _id: 1 },
18
- }}
19
- position='left'
20
- />
21
- )
22
-
23
- expect(toJSON()).toMatchSnapshot()
24
- })
25
-
26
- it('should NOT render <Message />', () => {
27
- const { toJSON } = render(
28
- <Message key='123' user={{ _id: 1 }} currentMessage={null} position='left' />
29
- )
30
-
31
- expect(toJSON()).toMatchSnapshot()
32
- })
33
-
34
- it('should render <Message /> with Avatar', () => {
35
- const { toJSON } = render(
36
- <Message
37
- key='123'
38
- user={{ _id: 1 }}
39
- currentMessage={DEFAULT_TEST_MESSAGE}
40
- position='left'
41
- isUserAvatarVisible
42
- />
43
- )
44
-
45
- expect(toJSON()).toMatchSnapshot()
46
- })
47
-
48
- it('should render null if user has no Avatar', () => {
49
- const { toJSON } = render(
50
- <Message
51
- key='123'
52
- user={{ _id: 1 }}
53
- currentMessage={{
54
- ...DEFAULT_TEST_MESSAGE,
55
- user: {
56
- _id: 1,
57
- avatar: undefined,
58
- },
59
- }}
60
- position='left'
61
- isUserAvatarVisible
62
- />
63
- )
64
-
65
- expect(toJSON()).toMatchSnapshot()
66
- })
67
- })
@@ -1,24 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { MessageImage } from '..'
5
- import { DEFAULT_TEST_MESSAGE } from './data'
6
-
7
- describe('MessageImage', () => {
8
- it('should not render <MessageImage /> and compare with snapshot', () => {
9
- const { toJSON } = render(<MessageImage currentMessage={null} />)
10
- expect(toJSON()).toMatchSnapshot()
11
- })
12
-
13
- it('should render <MessageImage /> and compare with snapshot', () => {
14
- const { toJSON } = render(
15
- <MessageImage
16
- currentMessage={{
17
- ...DEFAULT_TEST_MESSAGE,
18
- image: 'url://to/image.png',
19
- }}
20
- />
21
- )
22
- expect(toJSON()).toMatchSnapshot()
23
- })
24
- })
@@ -1,54 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { MessageReply } from '../components/MessageReply'
5
- import { IMessage, ReplyMessage } from '../Models'
6
-
7
- const replyMessage: ReplyMessage = {
8
- _id: 'reply-1',
9
- text: 'Original message text',
10
- user: {
11
- _id: 2,
12
- name: 'John Doe',
13
- },
14
- }
15
-
16
- const currentMessage: IMessage = {
17
- _id: 'msg-1',
18
- text: 'Reply text',
19
- createdAt: new Date(),
20
- user: {
21
- _id: 1,
22
- name: 'Jane Doe',
23
- },
24
- replyMessage,
25
- }
26
-
27
- it('should render <MessageReply /> and compare with snapshot', () => {
28
- const { toJSON } = render(
29
- <MessageReply
30
- replyMessage={replyMessage}
31
- currentMessage={currentMessage}
32
- position='left'
33
- />
34
- )
35
-
36
- expect(toJSON()).toMatchSnapshot()
37
- })
38
-
39
- it('should render <MessageReply /> on right position and compare with snapshot', () => {
40
- const currentMessageFromCurrentUser: IMessage = {
41
- ...currentMessage,
42
- user: replyMessage.user,
43
- }
44
-
45
- const { toJSON } = render(
46
- <MessageReply
47
- replyMessage={replyMessage}
48
- currentMessage={currentMessageFromCurrentUser}
49
- position='right'
50
- />
51
- )
52
-
53
- expect(toJSON()).toMatchSnapshot()
54
- })
@@ -1,15 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { MessageText } from '..'
5
- import { DEFAULT_TEST_MESSAGE } from './data'
6
-
7
- it('should render <MessageText /> and compare with snapshot', () => {
8
- const { toJSON } = render(
9
- <MessageText
10
- currentMessage={DEFAULT_TEST_MESSAGE}
11
- />
12
- )
13
-
14
- expect(toJSON()).toMatchSnapshot()
15
- })
@@ -1,38 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { MessagesContainer } from '..'
5
- import { DEFAULT_TEST_MESSAGE } from './data'
6
-
7
- it('should render <MessagesContainer /> without crashing', () => {
8
- // Just verify it renders without throwing
9
- expect(() => render(
10
- <MessagesContainer
11
- messages={[DEFAULT_TEST_MESSAGE]}
12
- user={{ _id: 1 }}
13
- />
14
- )).not.toThrow()
15
- })
16
-
17
- it('should render <MessagesContainer /> with multiple messages', () => {
18
- const messages = [
19
- { ...DEFAULT_TEST_MESSAGE, _id: 'test1' },
20
- { ...DEFAULT_TEST_MESSAGE, _id: 'test2' },
21
- ]
22
-
23
- expect(() => render(
24
- <MessagesContainer
25
- messages={messages}
26
- user={{ _id: 1 }}
27
- />
28
- )).not.toThrow()
29
- })
30
-
31
- it('should render <MessagesContainer /> with empty messages', () => {
32
- expect(() => render(
33
- <MessagesContainer
34
- messages={[]}
35
- user={{ _id: 1 }}
36
- />
37
- )).not.toThrow()
38
- })
@@ -1,41 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { ReplyPreview } from '../components/ReplyPreview'
5
- import { ReplyMessage } from '../Models'
6
-
7
- const replyMessage: ReplyMessage = {
8
- _id: 'reply-1',
9
- text: 'Original message to reply to',
10
- user: {
11
- _id: 2,
12
- name: 'John Doe',
13
- },
14
- }
15
-
16
- it('should render <ReplyPreview /> and compare with snapshot', () => {
17
- const { toJSON } = render(
18
- <ReplyPreview
19
- replyMessage={replyMessage}
20
- onClearReply={() => {}}
21
- />
22
- )
23
-
24
- expect(toJSON()).toMatchSnapshot()
25
- })
26
-
27
- it('should render <ReplyPreview /> with image and compare with snapshot', () => {
28
- const replyWithImage: ReplyMessage = {
29
- ...replyMessage,
30
- image: 'https://example.com/image.jpg',
31
- }
32
-
33
- const { toJSON } = render(
34
- <ReplyPreview
35
- replyMessage={replyWithImage}
36
- onClearReply={() => {}}
37
- />
38
- )
39
-
40
- expect(toJSON()).toMatchSnapshot()
41
- })
@@ -1,21 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react-native'
3
-
4
- import { Send } from '..'
5
-
6
- describe('Send', () => {
7
- it('should not render <Send /> and compare with snapshot', () => {
8
- const { toJSON } = render(<Send />)
9
- expect(toJSON()).toMatchSnapshot()
10
- })
11
-
12
- it('should always render <Send /> and compare with snapshot', () => {
13
- const { toJSON } = render(<Send isSendButtonAlwaysVisible />)
14
- expect(toJSON()).toMatchSnapshot()
15
- })
16
-
17
- it('should render <Send /> where there is input and compare with snapshot', () => {
18
- const { toJSON } = render(<Send text='test input' />)
19
- expect(toJSON()).toMatchSnapshot()
20
- })
21
- })