react-native-gifted-chat 2.6.5 → 2.7.1

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 (228) hide show
  1. package/README.md +8 -17
  2. package/lib/Actions.d.ts +0 -11
  3. package/lib/Actions.js +2 -14
  4. package/lib/Actions.js.map +1 -1
  5. package/lib/Avatar.d.ts +1 -23
  6. package/lib/Avatar.js +32 -40
  7. package/lib/Avatar.js.map +1 -1
  8. package/lib/Bubble/index.d.ts +30 -0
  9. package/lib/{Bubble.js → Bubble/index.js} +31 -181
  10. package/lib/Bubble/index.js.map +1 -0
  11. package/lib/Bubble/styles.d.ts +69 -0
  12. package/lib/Bubble/styles.js +72 -0
  13. package/lib/Bubble/styles.js.map +1 -0
  14. package/lib/Bubble/types.d.ts +47 -0
  15. package/lib/Bubble/types.js +2 -0
  16. package/lib/Bubble/types.js.map +1 -0
  17. package/lib/Composer.d.ts +0 -17
  18. package/lib/Composer.js +3 -18
  19. package/lib/Composer.js.map +1 -1
  20. package/lib/Constant.d.ts +1 -1
  21. package/lib/Constant.js +1 -1
  22. package/lib/Constant.js.map +1 -1
  23. package/lib/Day/index.d.ts +4 -0
  24. package/lib/Day/index.js +39 -0
  25. package/lib/Day/index.js.map +1 -0
  26. package/lib/Day/styles.d.ts +20 -0
  27. package/lib/Day/styles.js +22 -0
  28. package/lib/Day/styles.js.map +1 -0
  29. package/lib/Day/types.d.ts +9 -0
  30. package/lib/Day/types.js +2 -0
  31. package/lib/Day/types.js.map +1 -0
  32. package/lib/GiftedAvatar.d.ts +1 -11
  33. package/lib/GiftedAvatar.js +26 -33
  34. package/lib/GiftedAvatar.js.map +1 -1
  35. package/lib/GiftedChat/index.d.ts +26 -0
  36. package/lib/{GiftedChat.js → GiftedChat/index.js} +46 -52
  37. package/lib/GiftedChat/index.js.map +1 -0
  38. package/lib/GiftedChat/styles.d.ts +6 -0
  39. package/lib/GiftedChat/styles.js +7 -0
  40. package/lib/GiftedChat/styles.js.map +1 -0
  41. package/lib/{GiftedChat.d.ts → GiftedChat/types.d.ts} +28 -38
  42. package/lib/GiftedChat/types.js +2 -0
  43. package/lib/GiftedChat/types.js.map +1 -0
  44. package/lib/InputToolbar.d.ts +1 -14
  45. package/lib/InputToolbar.js +0 -12
  46. package/lib/InputToolbar.js.map +1 -1
  47. package/lib/LoadEarlier.d.ts +0 -14
  48. package/lib/LoadEarlier.js +2 -16
  49. package/lib/LoadEarlier.js.map +1 -1
  50. package/lib/Message/index.d.ts +6 -0
  51. package/lib/Message/index.js +85 -0
  52. package/lib/Message/index.js.map +1 -0
  53. package/lib/Message/styles.d.ts +21 -0
  54. package/lib/Message/styles.js +22 -0
  55. package/lib/Message/styles.js.map +1 -0
  56. package/lib/Message/types.d.ts +22 -0
  57. package/lib/Message/types.js +2 -0
  58. package/lib/Message/types.js.map +1 -0
  59. package/lib/MessageAudio.js +1 -2
  60. package/lib/MessageAudio.js.map +1 -1
  61. package/lib/MessageContainer/components/DayAnimated/index.d.ts +5 -0
  62. package/lib/MessageContainer/components/DayAnimated/index.js +85 -0
  63. package/lib/MessageContainer/components/DayAnimated/index.js.map +1 -0
  64. package/lib/MessageContainer/components/DayAnimated/styles.d.ts +11 -0
  65. package/lib/MessageContainer/components/DayAnimated/styles.js +12 -0
  66. package/lib/MessageContainer/components/DayAnimated/styles.js.map +1 -0
  67. package/lib/MessageContainer/components/DayAnimated/types.d.ts +17 -0
  68. package/lib/MessageContainer/components/DayAnimated/types.js +2 -0
  69. package/lib/MessageContainer/components/DayAnimated/types.js.map +1 -0
  70. package/lib/MessageContainer/components/Item/index.d.ts +22 -0
  71. package/lib/MessageContainer/components/Item/index.js +69 -0
  72. package/lib/MessageContainer/components/Item/index.js.map +1 -0
  73. package/lib/MessageContainer/components/Item/types.d.ts +18 -0
  74. package/lib/MessageContainer/components/Item/types.js +2 -0
  75. package/lib/MessageContainer/components/Item/types.js.map +1 -0
  76. package/lib/MessageContainer/index.d.ts +6 -0
  77. package/lib/MessageContainer/index.js +200 -0
  78. package/lib/MessageContainer/index.js.map +1 -0
  79. package/lib/MessageContainer/styles.d.ts +34 -0
  80. package/lib/MessageContainer/styles.js +31 -0
  81. package/lib/MessageContainer/styles.js.map +1 -0
  82. package/lib/MessageContainer/types.d.ts +54 -0
  83. package/lib/MessageContainer/types.js +2 -0
  84. package/lib/MessageContainer/types.js.map +1 -0
  85. package/lib/MessageImage.d.ts +1 -12
  86. package/lib/MessageImage.js +2 -12
  87. package/lib/MessageImage.js.map +1 -1
  88. package/lib/MessageText.d.ts +1 -24
  89. package/lib/MessageText.js +0 -22
  90. package/lib/MessageText.js.map +1 -1
  91. package/lib/MessageVideo.js +1 -2
  92. package/lib/MessageVideo.js.map +1 -1
  93. package/lib/QuickReplies.d.ts +1 -12
  94. package/lib/QuickReplies.js +10 -20
  95. package/lib/QuickReplies.js.map +1 -1
  96. package/lib/Send.d.ts +2 -16
  97. package/lib/Send.js +0 -13
  98. package/lib/Send.js.map +1 -1
  99. package/lib/SystemMessage.d.ts +1 -10
  100. package/lib/SystemMessage.js +2 -12
  101. package/lib/SystemMessage.js.map +1 -1
  102. package/lib/Time.d.ts +1 -17
  103. package/lib/Time.js +0 -15
  104. package/lib/Time.js.map +1 -1
  105. package/lib/TypingIndicator/index.d.ts +5 -0
  106. package/lib/{TypingIndicator.js → TypingIndicator/index.js} +9 -30
  107. package/lib/TypingIndicator/index.js.map +1 -0
  108. package/lib/TypingIndicator/styles.d.ts +20 -0
  109. package/lib/TypingIndicator/styles.js +22 -0
  110. package/lib/TypingIndicator/styles.js.map +1 -0
  111. package/lib/TypingIndicator/types.d.ts +3 -0
  112. package/lib/TypingIndicator/types.js +2 -0
  113. package/lib/TypingIndicator/types.js.map +1 -0
  114. package/lib/index.d.ts +0 -1
  115. package/lib/index.js +0 -1
  116. package/lib/index.js.map +1 -1
  117. package/lib/styles.d.ts +10 -0
  118. package/lib/styles.js +11 -0
  119. package/lib/styles.js.map +1 -0
  120. package/lib/{Models.d.ts → types.d.ts} +1 -1
  121. package/lib/types.js +2 -0
  122. package/lib/types.js.map +1 -0
  123. package/lib/utils.d.ts +1 -3
  124. package/lib/utils.js +0 -7
  125. package/lib/utils.js.map +1 -1
  126. package/package.json +21 -29
  127. package/src/Actions.tsx +3 -15
  128. package/src/Avatar.tsx +43 -52
  129. package/src/{Bubble.tsx → Bubble/index.tsx} +52 -269
  130. package/src/Bubble/styles.ts +73 -0
  131. package/src/Bubble/types.ts +90 -0
  132. package/src/Composer.tsx +3 -19
  133. package/src/Constant.ts +1 -1
  134. package/src/Day/index.tsx +63 -0
  135. package/src/Day/styles.ts +22 -0
  136. package/src/Day/types.ts +14 -0
  137. package/src/GiftedAvatar.tsx +31 -38
  138. package/src/GiftedChat/index.tsx +501 -0
  139. package/src/GiftedChat/styles.ts +7 -0
  140. package/src/GiftedChat/types.ts +206 -0
  141. package/src/InputToolbar.tsx +1 -14
  142. package/src/LoadEarlier.tsx +2 -17
  143. package/src/Message/index.tsx +135 -0
  144. package/src/Message/styles.ts +22 -0
  145. package/src/Message/types.ts +26 -0
  146. package/src/MessageAudio.tsx +1 -4
  147. package/src/MessageContainer/components/DayAnimated/index.tsx +143 -0
  148. package/src/MessageContainer/components/DayAnimated/styles.ts +12 -0
  149. package/src/MessageContainer/components/DayAnimated/types.ts +12 -0
  150. package/src/MessageContainer/components/Item/index.tsx +136 -0
  151. package/src/MessageContainer/components/Item/types.ts +13 -0
  152. package/src/MessageContainer/index.tsx +343 -0
  153. package/src/MessageContainer/styles.ts +31 -0
  154. package/src/MessageContainer/types.ts +60 -0
  155. package/src/MessageImage.tsx +3 -14
  156. package/src/MessageText.tsx +1 -24
  157. package/src/MessageVideo.tsx +1 -4
  158. package/src/QuickReplies.tsx +14 -25
  159. package/src/Send.tsx +1 -15
  160. package/src/SystemMessage.tsx +3 -14
  161. package/src/Time.tsx +1 -17
  162. package/src/{TypingIndicator.tsx → TypingIndicator/index.tsx} +12 -35
  163. package/src/TypingIndicator/styles.ts +22 -0
  164. package/src/TypingIndicator/types.ts +3 -0
  165. package/src/__tests__/Bubble.test.tsx +7 -4
  166. package/src/__tests__/GiftedAvatar.test.tsx +6 -2
  167. package/src/__tests__/GiftedChat.test.tsx +20 -14
  168. package/src/__tests__/Message.test.tsx +4 -1
  169. package/src/__tests__/__snapshots__/Actions.test.tsx.snap +6 -2
  170. package/src/__tests__/__snapshots__/Bubble.test.tsx.snap +3 -1
  171. package/src/__tests__/__snapshots__/Composer.test.tsx.snap +2 -0
  172. package/src/__tests__/__snapshots__/Constant.test.tsx.snap +1 -1
  173. package/src/__tests__/__snapshots__/Day.test.tsx.snap +1 -33
  174. package/src/__tests__/__snapshots__/GiftedAvatar.test.tsx.snap +4 -2
  175. package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +22 -9
  176. package/src/__tests__/__snapshots__/InputToolbar.test.tsx.snap +2 -0
  177. package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +3 -1
  178. package/src/__tests__/__snapshots__/Message.test.tsx.snap +21 -100
  179. package/src/__tests__/__snapshots__/MessageContainer.test.tsx.snap +282 -82
  180. package/src/__tests__/__snapshots__/MessageImage.test.tsx.snap +8 -4
  181. package/src/__tests__/__snapshots__/SystemMessage.test.tsx.snap +5 -1
  182. package/src/__tests__/data.ts +1 -1
  183. package/src/index.ts +0 -2
  184. package/src/styles.ts +11 -0
  185. package/src/{Models.ts → types.ts} +1 -1
  186. package/src/utils.ts +1 -9
  187. package/lib/Actions.js.flow +0 -21
  188. package/lib/Avatar.js.flow +0 -27
  189. package/lib/Bubble.d.ts +0 -148
  190. package/lib/Bubble.js.flow +0 -69
  191. package/lib/Bubble.js.map +0 -1
  192. package/lib/Composer.js.flow +0 -24
  193. package/lib/Day.d.ts +0 -15
  194. package/lib/Day.js +0 -36
  195. package/lib/Day.js.flow +0 -23
  196. package/lib/Day.js.map +0 -1
  197. package/lib/GiftedAvatar.js.flow +0 -17
  198. package/lib/GiftedChat.js.flow +0 -163
  199. package/lib/GiftedChat.js.map +0 -1
  200. package/lib/InputToolbar.js.flow +0 -31
  201. package/lib/LoadEarlier.js.flow +0 -20
  202. package/lib/Message.d.ts +0 -67
  203. package/lib/Message.js +0 -157
  204. package/lib/Message.js.flow +0 -32
  205. package/lib/Message.js.map +0 -1
  206. package/lib/MessageAudio.js.flow +0 -15
  207. package/lib/MessageContainer.d.ts +0 -105
  208. package/lib/MessageContainer.js +0 -224
  209. package/lib/MessageContainer.js.flow +0 -39
  210. package/lib/MessageContainer.js.map +0 -1
  211. package/lib/MessageImage.js.flow +0 -20
  212. package/lib/MessageText.js.flow +0 -23
  213. package/lib/MessageVideo.js.flow +0 -16
  214. package/lib/Models.js +0 -2
  215. package/lib/Models.js.map +0 -1
  216. package/lib/QuickReplies.js.flow +0 -25
  217. package/lib/Send.js.flow +0 -19
  218. package/lib/SystemMessage.js.flow +0 -18
  219. package/lib/Time.js.flow +0 -19
  220. package/lib/TypingIndicator.d.ts +0 -6
  221. package/lib/TypingIndicator.js.map +0 -1
  222. package/lib/index.js.flow +0 -2
  223. package/lib/types.js.flow +0 -43
  224. package/lib/utils.js.flow +0 -16
  225. package/src/Day.tsx +0 -71
  226. package/src/GiftedChat.tsx +0 -689
  227. package/src/Message.tsx +0 -229
  228. package/src/MessageContainer.tsx +0 -361
@@ -1,5 +1,4 @@
1
1
  import React, { useState, useMemo, useCallback } from 'react'
2
- import PropTypes from 'prop-types'
3
2
  import {
4
3
  Text,
5
4
  StyleSheet,
@@ -9,10 +8,10 @@ import {
9
8
  ViewStyle,
10
9
  TextStyle,
11
10
  } from 'react-native'
12
- import { IMessage, Reply } from './Models'
11
+ import { IMessage, Reply } from './types'
13
12
  import Color from './Color'
14
- import { StylePropType } from './utils'
15
13
  import { warning } from './logging'
14
+ import stylesCommon from './styles'
16
15
 
17
16
  const styles = StyleSheet.create({
18
17
  container: {
@@ -21,8 +20,6 @@ const styles = StyleSheet.create({
21
20
  maxWidth: 300,
22
21
  },
23
22
  quickReply: {
24
- justifyContent: 'center',
25
- alignItems: 'center',
26
23
  borderWidth: 1,
27
24
  maxWidth: 200,
28
25
  paddingVertical: 7,
@@ -90,6 +87,15 @@ export function QuickReplies ({
90
87
  return false
91
88
  }, [currentMessage, nextMessage])
92
89
 
90
+ const handleSend = useCallback((repliesData: Reply[]) => () => {
91
+ onQuickReply?.(
92
+ repliesData.map((reply: Reply) => ({
93
+ ...reply,
94
+ messageId: currentMessage!._id,
95
+ }))
96
+ )
97
+ }, [onQuickReply, currentMessage])
98
+
93
99
  const handlePress = useCallback(
94
100
  (reply: Reply) => () => {
95
101
  if (currentMessage) {
@@ -113,18 +119,9 @@ export function QuickReplies ({
113
119
  }
114
120
  }
115
121
  },
116
- [replies, currentMessage]
122
+ [replies, currentMessage, handleSend]
117
123
  )
118
124
 
119
- const handleSend = (repliesData: Reply[]) => () => {
120
- onQuickReply?.(
121
- repliesData.map((reply: Reply) => ({
122
- ...reply,
123
- messageId: currentMessage!._id,
124
- }))
125
- )
126
- }
127
-
128
125
  if (!shouldComponentDisplay)
129
126
  return null
130
127
 
@@ -139,6 +136,7 @@ export function QuickReplies ({
139
136
  <TouchableOpacity
140
137
  onPress={handlePress(reply)}
141
138
  style={[
139
+ stylesCommon.centerItems,
142
140
  styles.quickReply,
143
141
  quickReplyStyle,
144
142
  { borderColor: color },
@@ -163,7 +161,7 @@ export function QuickReplies ({
163
161
  )}
164
162
  {replies.length > 0 && (
165
163
  <TouchableOpacity
166
- style={[styles.quickReply, styles.sendLink]}
164
+ style={[stylesCommon.centerItems, styles.quickReply, styles.sendLink]}
167
165
  onPress={handleSend(replies)}
168
166
  >
169
167
  {renderQuickReplySend?.() || (
@@ -174,12 +172,3 @@ export function QuickReplies ({
174
172
  </View>
175
173
  )
176
174
  }
177
-
178
- QuickReplies.propTypes = {
179
- currentMessage: PropTypes.object.isRequired,
180
- onQuickReply: PropTypes.func,
181
- color: PropTypes.string,
182
- sendText: PropTypes.string,
183
- renderQuickReplySend: PropTypes.func,
184
- quickReplyStyle: StylePropType,
185
- }
package/src/Send.tsx CHANGED
@@ -1,5 +1,4 @@
1
1
  import React, { useMemo, useCallback } from 'react'
2
- import PropTypes from 'prop-types'
3
2
  import {
4
3
  StyleSheet,
5
4
  Text,
@@ -12,8 +11,7 @@ import {
12
11
  } from 'react-native'
13
12
 
14
13
  import Color from './Color'
15
- import { IMessage } from './Models'
16
- import { StylePropType } from './utils'
14
+ import { IMessage } from './types'
17
15
  import { TEST_ID } from './Constant'
18
16
 
19
17
  const styles = StyleSheet.create({
@@ -88,15 +86,3 @@ export const Send = <TMessage extends IMessage = IMessage>({
88
86
  </TouchableOpacity>
89
87
  )
90
88
  }
91
-
92
- Send.propTypes = {
93
- text: PropTypes.string,
94
- onSend: PropTypes.func,
95
- label: PropTypes.string,
96
- containerStyle: StylePropType,
97
- textStyle: StylePropType,
98
- children: PropTypes.element,
99
- alwaysShowSend: PropTypes.bool,
100
- disabled: PropTypes.bool,
101
- sendButtonProps: PropTypes.object,
102
- }
@@ -7,16 +7,12 @@ import {
7
7
  StyleProp,
8
8
  TextStyle,
9
9
  } from 'react-native'
10
- import PropTypes from 'prop-types'
11
10
  import Color from './Color'
12
- import { IMessage } from './Models'
13
- import { StylePropType } from './utils'
11
+ import { IMessage } from './types'
12
+ import stylesCommon from './styles'
14
13
 
15
14
  const styles = StyleSheet.create({
16
15
  container: {
17
- alignItems: 'center',
18
- justifyContent: 'center',
19
- flex: 1,
20
16
  marginTop: 5,
21
17
  marginBottom: 10,
22
18
  },
@@ -45,17 +41,10 @@ export function SystemMessage<TMessage extends IMessage = IMessage> ({
45
41
  return null
46
42
 
47
43
  return (
48
- <View style={[styles.container, containerStyle]}>
44
+ <View style={[stylesCommon.fill, stylesCommon.centerItems, styles.container, containerStyle]}>
49
45
  <View style={wrapperStyle}>
50
46
  <Text style={[styles.text, textStyle]}>{currentMessage.text}</Text>
51
47
  </View>
52
48
  </View>
53
49
  )
54
50
  }
55
-
56
- SystemMessage.propTypes = {
57
- currentMessage: PropTypes.object,
58
- containerStyle: StylePropType,
59
- wrapperStyle: StylePropType,
60
- textStyle: StylePropType,
61
- }
package/src/Time.tsx CHANGED
@@ -1,12 +1,10 @@
1
1
  import * as React from 'react'
2
- import PropTypes from 'prop-types'
3
2
  import { StyleSheet, Text, View, ViewStyle, TextStyle } from 'react-native'
4
3
  import dayjs from 'dayjs'
5
4
 
6
5
  import Color from './Color'
7
6
  import { TIME_FORMAT } from './Constant'
8
- import { LeftRightStyle, IMessage } from './Models'
9
- import { StylePropType } from './utils'
7
+ import { LeftRightStyle, IMessage } from './types'
10
8
  import { useChatContext } from './GiftedChatContext'
11
9
 
12
10
  const { containerStyle } = StyleSheet.create({
@@ -81,17 +79,3 @@ export function Time<TMessage extends IMessage = IMessage> ({
81
79
  </View>
82
80
  )
83
81
  }
84
-
85
- Time.propTypes = {
86
- position: PropTypes.oneOf(['left', 'right']),
87
- currentMessage: PropTypes.object,
88
- containerStyle: PropTypes.shape({
89
- left: StylePropType,
90
- right: StylePropType,
91
- }),
92
- timeFormat: PropTypes.string,
93
- timeTextStyle: PropTypes.shape({
94
- left: StylePropType,
95
- right: StylePropType,
96
- }),
97
- }
@@ -1,6 +1,5 @@
1
1
  import React, { useCallback, useEffect, useState, useMemo } from 'react'
2
- import { StyleSheet, View } from 'react-native'
3
- import Color from './Color'
2
+ import { View } from 'react-native'
4
3
  import Animated, {
5
4
  runOnJS,
6
5
  useAnimatedStyle,
@@ -10,6 +9,12 @@ import Animated, {
10
9
  withSequence,
11
10
  withTiming,
12
11
  } from 'react-native-reanimated'
12
+ import { TypingIndicatorProps } from './types'
13
+
14
+ import stylesCommon from '../styles'
15
+ import styles from './styles'
16
+
17
+ export * from './types'
13
18
 
14
19
  const DotsAnimation = () => {
15
20
  const dot1 = useSharedValue(0)
@@ -76,7 +81,7 @@ const DotsAnimation = () => {
76
81
  }, [dot3, topY, bottomY, duration])
77
82
 
78
83
  return (
79
- <View style={styles.dots}>
84
+ <View style={[stylesCommon.fill, stylesCommon.centerItems, styles.dots]}>
80
85
  <Animated.View style={[styles.dot, dot1Style]} />
81
86
  <Animated.View style={[styles.dot, dot2Style]} />
82
87
  <Animated.View style={[styles.dot, dot3Style]} />
@@ -84,11 +89,7 @@ const DotsAnimation = () => {
84
89
  )
85
90
  }
86
91
 
87
- interface Props {
88
- isTyping?: boolean
89
- }
90
-
91
- const TypingIndicator = ({ isTyping }: Props) => {
92
+ const TypingIndicator = ({ isTyping }: TypingIndicatorProps) => {
92
93
  const yCoords = useSharedValue(200)
93
94
  const heightScale = useSharedValue(0)
94
95
  const marginScale = useSharedValue(0)
@@ -113,16 +114,15 @@ const TypingIndicator = ({ isTyping }: Props) => {
113
114
  marginScale.value = withTiming(8, { duration })
114
115
  }, [yCoords, heightScale, marginScale])
115
116
 
116
- // side effect
117
117
  const slideOut = useCallback(() => {
118
118
  const duration = 250
119
119
 
120
- yCoords.value = withTiming(200, { duration })
121
- heightScale.value = withTiming(0, { duration })
122
- marginScale.value = withTiming(0, { duration }, isFinished => {
120
+ yCoords.value = withTiming(200, { duration }, isFinished => {
123
121
  if (isFinished)
124
122
  runOnJS(setIsVisible)(false)
125
123
  })
124
+ heightScale.value = withTiming(0, { duration })
125
+ marginScale.value = withTiming(0, { duration })
126
126
  }, [yCoords, heightScale, marginScale])
127
127
 
128
128
  useEffect(() => {
@@ -153,27 +153,4 @@ const TypingIndicator = ({ isTyping }: Props) => {
153
153
  )
154
154
  }
155
155
 
156
- const styles = StyleSheet.create({
157
- container: {
158
- marginLeft: 8,
159
- width: 45,
160
- borderRadius: 15,
161
- backgroundColor: Color.leftBubbleBackground,
162
- },
163
- dots: {
164
- flexDirection: 'row',
165
- alignItems: 'center',
166
- justifyContent: 'center',
167
- flex: 1,
168
- },
169
- dot: {
170
- marginLeft: 2,
171
- marginRight: 2,
172
- borderRadius: 4,
173
- width: 8,
174
- height: 8,
175
- backgroundColor: 'rgba(0, 0, 0, 0.38)',
176
- },
177
- })
178
-
179
156
  export default TypingIndicator
@@ -0,0 +1,22 @@
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
+ })
@@ -0,0 +1,3 @@
1
+ export interface TypingIndicatorProps {
2
+ isTyping?: boolean
3
+ }
@@ -5,8 +5,10 @@ import renderer from 'react-test-renderer'
5
5
  import { Bubble } from '../GiftedChat'
6
6
 
7
7
  it('should render <Bubble /> and compare with snapshot', () => {
8
- const tree = renderer
9
- .create(
8
+ let tree
9
+
10
+ renderer.act(() => {
11
+ tree = renderer.create(
10
12
  <Bubble
11
13
  user={{ _id: 1 }}
12
14
  currentMessage={{
@@ -15,9 +17,10 @@ it('should render <Bubble /> and compare with snapshot', () => {
15
17
  createdAt: 1554744013721,
16
18
  user: { _id: 1 },
17
19
  }}
20
+ position='left'
18
21
  />
19
22
  )
20
- .toJSON()
23
+ })
21
24
 
22
- expect(tree).toMatchSnapshot()
25
+ expect(tree.toJSON()).toMatchSnapshot()
23
26
  })
@@ -5,7 +5,11 @@ import renderer from 'react-test-renderer'
5
5
  import { GiftedAvatar } from '../GiftedChat'
6
6
 
7
7
  it('should render <GiftedAvatar /> and compare with snapshot', () => {
8
- const tree = renderer.create(<GiftedAvatar />).toJSON()
8
+ let tree
9
9
 
10
- expect(tree).toMatchSnapshot()
10
+ renderer.act(() => {
11
+ tree = renderer.create(<GiftedAvatar />)
12
+ })
13
+
14
+ expect(tree.toJSON()).toMatchSnapshot()
11
15
  })
@@ -1,9 +1,9 @@
1
1
  import 'react-native'
2
2
  import React from 'react'
3
3
  import renderer from 'react-test-renderer'
4
- import { SafeAreaProvider } from 'react-native-safe-area-context'
5
4
 
6
5
  import { GiftedChat } from '../GiftedChat'
6
+ import { useReanimatedKeyboardAnimation } from 'react-native-keyboard-controller'
7
7
 
8
8
  const messages = [
9
9
  {
@@ -18,19 +18,25 @@ const messages = [
18
18
  ]
19
19
 
20
20
  it('should render <GiftedChat/> and compare with snapshot', () => {
21
- const tree = renderer
22
- .create(
23
- <SafeAreaProvider>
24
- <GiftedChat
25
- messages={messages}
26
- onSend={() => { }}
27
- user={{
28
- _id: 1,
29
- }}
30
- />
31
- </SafeAreaProvider>
21
+ let tree
22
+
23
+ renderer.act(() => {
24
+ (useReanimatedKeyboardAnimation as jest.Mock).mockReturnValue({
25
+ height: {
26
+ value: 0,
27
+ },
28
+ })
29
+
30
+ tree = renderer.create(
31
+ <GiftedChat
32
+ messages={messages}
33
+ onSend={() => {}}
34
+ user={{
35
+ _id: 1,
36
+ }}
37
+ />
32
38
  )
33
- .toJSON()
39
+ })
34
40
 
35
- expect(tree).toMatchSnapshot()
41
+ expect(tree.toJSON()).toMatchSnapshot()
36
42
  })
@@ -17,6 +17,7 @@ describe('Message component', () => {
17
17
  createdAt: 1554744013721,
18
18
  user: { _id: 1 },
19
19
  }}
20
+ position='left'
20
21
  />
21
22
  )
22
23
  .toJSON()
@@ -26,7 +27,7 @@ describe('Message component', () => {
26
27
 
27
28
  it('should NOT render <Message />', () => {
28
29
  const tree = renderer
29
- .create(<Message key='123' user={{ _id: 1 }} currentMessage={null} />)
30
+ .create(<Message key='123' user={{ _id: 1 }} currentMessage={null} position='left' />)
30
31
  .toJSON()
31
32
 
32
33
  expect(tree).toMatchSnapshot()
@@ -44,6 +45,7 @@ describe('Message component', () => {
44
45
  createdAt: 1554744013721,
45
46
  user: { _id: 1 },
46
47
  }}
48
+ position='left'
47
49
  showUserAvatar
48
50
  />
49
51
  )
@@ -67,6 +69,7 @@ describe('Message component', () => {
67
69
  avatar: null,
68
70
  },
69
71
  }}
72
+ position='left'
70
73
  showUserAvatar
71
74
  />
72
75
  )
@@ -42,13 +42,17 @@ exports[`should render <Actions /> and compare with snapshot 1`] = `
42
42
  <View
43
43
  style={
44
44
  [
45
+ {
46
+ "flex": 1,
47
+ },
45
48
  {
46
49
  "alignItems": "center",
50
+ "justifyContent": "center",
51
+ },
52
+ {
47
53
  "borderColor": "#b2b2b2",
48
54
  "borderRadius": 13,
49
55
  "borderWidth": 2,
50
- "flex": 1,
51
- "justifyContent": "center",
52
56
  },
53
57
  undefined,
54
58
  ]
@@ -5,9 +5,11 @@ exports[`should render <Bubble /> and compare with snapshot 1`] = `
5
5
  style={
6
6
  [
7
7
  {
8
- "alignItems": "flex-start",
9
8
  "flex": 1,
10
9
  },
10
+ {
11
+ "alignItems": "flex-start",
12
+ },
11
13
  undefined,
12
14
  ]
13
15
  }
@@ -16,6 +16,8 @@ exports[`should render <Composer /> and compare with snapshot 1`] = `
16
16
  [
17
17
  {
18
18
  "flex": 1,
19
+ },
20
+ {
19
21
  "fontSize": 16,
20
22
  "lineHeight": 22,
21
23
  "marginBottom": 5,
@@ -2,7 +2,7 @@
2
2
 
3
3
  exports[`should compare Constant with snapshot 1`] = `
4
4
  {
5
- "DATE_FORMAT": "ll",
5
+ "DATE_FORMAT": "D MMMM",
6
6
  "DEFAULT_PLACEHOLDER": "Type a message...",
7
7
  "MAX_COMPOSER_HEIGHT": 200,
8
8
  "MIN_COMPOSER_HEIGHT": 33,
@@ -2,36 +2,4 @@
2
2
 
3
3
  exports[`Day should not render <Day /> and compare with snapshot 1`] = `null`;
4
4
 
5
- exports[`Day should render <Day /> and compare with snapshot 1`] = `
6
- <View
7
- style={
8
- [
9
- {
10
- "alignItems": "center",
11
- "justifyContent": "center",
12
- "marginBottom": 10,
13
- "marginTop": 5,
14
- },
15
- undefined,
16
- ]
17
- }
18
- >
19
- <View>
20
- <Text
21
- style={
22
- [
23
- {
24
- "backgroundColor": "transparent",
25
- "color": "#b2b2b2",
26
- "fontSize": 12,
27
- "fontWeight": "600",
28
- },
29
- undefined,
30
- ]
31
- }
32
- >
33
- Apr 17, 2022
34
- </Text>
35
- </View>
36
- </View>
37
- `;
5
+ exports[`Day should render <Day /> and compare with snapshot 1`] = `null`;
@@ -7,15 +7,17 @@ exports[`should render <GiftedAvatar /> and compare with snapshot 1`] = `
7
7
  [
8
8
  {
9
9
  "alignItems": "center",
10
+ "justifyContent": "center",
11
+ },
12
+ {
10
13
  "borderRadius": 20,
11
14
  "height": 40,
12
- "justifyContent": "center",
13
15
  "width": 40,
14
16
  },
15
17
  {
16
18
  "backgroundColor": "transparent",
17
19
  },
18
- {},
20
+ undefined,
19
21
  ]
20
22
  }
21
23
  />
@@ -1,15 +1,28 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`should render <GiftedChat/> and compare with snapshot 1`] = `
4
- <RNCSafeAreaProvider
5
- onInsetsChange={[Function]}
6
- style={
7
- [
4
+ <KeyboardProvider>
5
+ <View
6
+ style={
8
7
  {
9
8
  "flex": 1,
10
- },
11
- undefined,
12
- ]
13
- }
14
- />
9
+ }
10
+ }
11
+ >
12
+ <View
13
+ onLayout={[Function]}
14
+ style={
15
+ [
16
+ {
17
+ "flex": 1,
18
+ },
19
+ {
20
+ "overflow": "hidden",
21
+ },
22
+ ]
23
+ }
24
+ testID="GC_WRAPPER"
25
+ />
26
+ </View>
27
+ </KeyboardProvider>
15
28
  `;
@@ -39,6 +39,8 @@ exports[`should render <InputToolbar /> and compare with snapshot 1`] = `
39
39
  [
40
40
  {
41
41
  "flex": 1,
42
+ },
43
+ {
42
44
  "fontSize": 16,
43
45
  "lineHeight": 22,
44
46
  "marginBottom": 5,
@@ -44,10 +44,12 @@ exports[`should render <LoadEarlier /> and compare with snapshot 1`] = `
44
44
  [
45
45
  {
46
46
  "alignItems": "center",
47
+ "justifyContent": "center",
48
+ },
49
+ {
47
50
  "backgroundColor": "#b2b2b2",
48
51
  "borderRadius": 15,
49
52
  "height": 30,
50
- "justifyContent": "center",
51
53
  "paddingLeft": 10,
52
54
  "paddingRight": 10,
53
55
  },