react-native-gifted-chat 2.6.4 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -16
- package/lib/Actions.d.ts +0 -11
- package/lib/Actions.js +2 -14
- package/lib/Actions.js.map +1 -1
- package/lib/Avatar.d.ts +1 -23
- package/lib/Avatar.js +32 -40
- package/lib/Avatar.js.map +1 -1
- package/lib/Bubble/index.d.ts +30 -0
- package/lib/{Bubble.js → Bubble/index.js} +31 -181
- package/lib/Bubble/index.js.map +1 -0
- package/lib/Bubble/styles.d.ts +69 -0
- package/lib/Bubble/styles.js +72 -0
- package/lib/Bubble/styles.js.map +1 -0
- package/lib/Bubble/types.d.ts +47 -0
- package/lib/Bubble/types.js +2 -0
- package/lib/Bubble/types.js.map +1 -0
- package/lib/Composer.d.ts +0 -17
- package/lib/Composer.js +3 -18
- package/lib/Composer.js.map +1 -1
- package/lib/Constant.d.ts +1 -1
- package/lib/Constant.js +1 -1
- package/lib/Constant.js.map +1 -1
- package/lib/Day/index.d.ts +4 -0
- package/lib/Day/index.js +39 -0
- package/lib/Day/index.js.map +1 -0
- package/lib/Day/styles.d.ts +20 -0
- package/lib/Day/styles.js +22 -0
- package/lib/Day/styles.js.map +1 -0
- package/lib/Day/types.d.ts +9 -0
- package/lib/Day/types.js +2 -0
- package/lib/Day/types.js.map +1 -0
- package/lib/GiftedAvatar.d.ts +1 -11
- package/lib/GiftedAvatar.js +26 -33
- package/lib/GiftedAvatar.js.map +1 -1
- package/lib/GiftedChat/index.d.ts +26 -0
- package/lib/{GiftedChat.js → GiftedChat/index.js} +58 -59
- package/lib/GiftedChat/index.js.map +1 -0
- package/lib/GiftedChat/styles.d.ts +6 -0
- package/lib/GiftedChat/styles.js +7 -0
- package/lib/GiftedChat/styles.js.map +1 -0
- package/lib/{GiftedChat.d.ts → GiftedChat/types.d.ts} +29 -37
- package/lib/GiftedChat/types.js +2 -0
- package/lib/GiftedChat/types.js.map +1 -0
- package/lib/InputToolbar.d.ts +1 -14
- package/lib/InputToolbar.js +0 -12
- package/lib/InputToolbar.js.map +1 -1
- package/lib/LoadEarlier.d.ts +0 -14
- package/lib/LoadEarlier.js +2 -16
- package/lib/LoadEarlier.js.map +1 -1
- package/lib/Message/index.d.ts +6 -0
- package/lib/Message/index.js +85 -0
- package/lib/Message/index.js.map +1 -0
- package/lib/Message/styles.d.ts +21 -0
- package/lib/Message/styles.js +22 -0
- package/lib/Message/styles.js.map +1 -0
- package/lib/Message/types.d.ts +22 -0
- package/lib/Message/types.js +2 -0
- package/lib/Message/types.js.map +1 -0
- package/lib/MessageAudio.js +1 -2
- package/lib/MessageAudio.js.map +1 -1
- package/lib/MessageContainer/components/DayAnimated/index.d.ts +5 -0
- package/lib/MessageContainer/components/DayAnimated/index.js +85 -0
- package/lib/MessageContainer/components/DayAnimated/index.js.map +1 -0
- package/lib/MessageContainer/components/DayAnimated/styles.d.ts +11 -0
- package/lib/MessageContainer/components/DayAnimated/styles.js +12 -0
- package/lib/MessageContainer/components/DayAnimated/styles.js.map +1 -0
- package/lib/MessageContainer/components/DayAnimated/types.d.ts +17 -0
- package/lib/MessageContainer/components/DayAnimated/types.js +2 -0
- package/lib/MessageContainer/components/DayAnimated/types.js.map +1 -0
- package/lib/MessageContainer/components/Item/index.d.ts +22 -0
- package/lib/MessageContainer/components/Item/index.js +69 -0
- package/lib/MessageContainer/components/Item/index.js.map +1 -0
- package/lib/MessageContainer/components/Item/types.d.ts +18 -0
- package/lib/MessageContainer/components/Item/types.js +2 -0
- package/lib/MessageContainer/components/Item/types.js.map +1 -0
- package/lib/MessageContainer/index.d.ts +6 -0
- package/lib/MessageContainer/index.js +175 -0
- package/lib/MessageContainer/index.js.map +1 -0
- package/lib/MessageContainer/styles.d.ts +34 -0
- package/lib/MessageContainer/styles.js +31 -0
- package/lib/MessageContainer/styles.js.map +1 -0
- package/lib/MessageContainer/types.d.ts +54 -0
- package/lib/MessageContainer/types.js +2 -0
- package/lib/MessageContainer/types.js.map +1 -0
- package/lib/MessageImage.d.ts +1 -12
- package/lib/MessageImage.js +2 -12
- package/lib/MessageImage.js.map +1 -1
- package/lib/MessageText.d.ts +1 -24
- package/lib/MessageText.js +0 -22
- package/lib/MessageText.js.map +1 -1
- package/lib/MessageVideo.js +1 -2
- package/lib/MessageVideo.js.map +1 -1
- package/lib/QuickReplies.d.ts +1 -12
- package/lib/QuickReplies.js +10 -20
- package/lib/QuickReplies.js.map +1 -1
- package/lib/Send.d.ts +2 -16
- package/lib/Send.js +0 -13
- package/lib/Send.js.map +1 -1
- package/lib/SystemMessage.d.ts +1 -10
- package/lib/SystemMessage.js +2 -12
- package/lib/SystemMessage.js.map +1 -1
- package/lib/Time.d.ts +1 -17
- package/lib/Time.js +0 -15
- package/lib/Time.js.map +1 -1
- package/lib/TypingIndicator/index.d.ts +5 -0
- package/lib/{TypingIndicator.js → TypingIndicator/index.js} +9 -30
- package/lib/TypingIndicator/index.js.map +1 -0
- package/lib/TypingIndicator/styles.d.ts +20 -0
- package/lib/TypingIndicator/styles.js +22 -0
- package/lib/TypingIndicator/styles.js.map +1 -0
- package/lib/TypingIndicator/types.d.ts +3 -0
- package/lib/TypingIndicator/types.js +2 -0
- package/lib/TypingIndicator/types.js.map +1 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/styles.d.ts +10 -0
- package/lib/styles.js +11 -0
- package/lib/styles.js.map +1 -0
- package/lib/{Models.d.ts → types.d.ts} +1 -1
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts +1 -3
- package/lib/utils.js +0 -7
- package/lib/utils.js.map +1 -1
- package/package.json +30 -34
- package/src/Actions.tsx +3 -15
- package/src/Avatar.tsx +43 -52
- package/src/{Bubble.tsx → Bubble/index.tsx} +53 -270
- package/src/Bubble/styles.ts +73 -0
- package/src/Bubble/types.ts +90 -0
- package/src/Composer.tsx +3 -19
- package/src/Constant.ts +1 -1
- package/src/Day/index.tsx +63 -0
- package/src/Day/styles.ts +22 -0
- package/src/Day/types.ts +14 -0
- package/src/GiftedAvatar.tsx +31 -38
- package/src/GiftedChat/index.tsx +503 -0
- package/src/GiftedChat/styles.ts +7 -0
- package/src/GiftedChat/types.ts +206 -0
- package/src/InputToolbar.tsx +1 -14
- package/src/LoadEarlier.tsx +2 -17
- package/src/Message/index.tsx +135 -0
- package/src/Message/styles.ts +22 -0
- package/src/Message/types.ts +26 -0
- package/src/MessageAudio.tsx +1 -4
- package/src/MessageContainer/components/DayAnimated/index.tsx +143 -0
- package/src/MessageContainer/components/DayAnimated/styles.ts +12 -0
- package/src/MessageContainer/components/DayAnimated/types.ts +12 -0
- package/src/MessageContainer/components/Item/index.tsx +136 -0
- package/src/MessageContainer/components/Item/types.ts +13 -0
- package/src/MessageContainer/index.tsx +316 -0
- package/src/MessageContainer/styles.ts +31 -0
- package/src/MessageContainer/types.ts +60 -0
- package/src/MessageImage.tsx +3 -14
- package/src/MessageText.tsx +2 -25
- package/src/MessageVideo.tsx +1 -4
- package/src/QuickReplies.tsx +14 -25
- package/src/Send.tsx +1 -15
- package/src/SystemMessage.tsx +3 -14
- package/src/Time.tsx +1 -17
- package/src/{TypingIndicator.tsx → TypingIndicator/index.tsx} +12 -35
- package/src/TypingIndicator/styles.ts +22 -0
- package/src/TypingIndicator/types.ts +3 -0
- package/src/__tests__/Bubble.test.tsx +7 -4
- package/src/__tests__/GiftedAvatar.test.tsx +6 -2
- package/src/__tests__/GiftedChat.test.tsx +20 -14
- package/src/__tests__/Message.test.tsx +4 -1
- package/src/__tests__/__snapshots__/Actions.test.tsx.snap +6 -2
- package/src/__tests__/__snapshots__/Bubble.test.tsx.snap +3 -1
- package/src/__tests__/__snapshots__/Composer.test.tsx.snap +2 -0
- package/src/__tests__/__snapshots__/Constant.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/Day.test.tsx.snap +1 -33
- package/src/__tests__/__snapshots__/GiftedAvatar.test.tsx.snap +4 -2
- package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +22 -9
- package/src/__tests__/__snapshots__/InputToolbar.test.tsx.snap +2 -0
- package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +3 -1
- package/src/__tests__/__snapshots__/Message.test.tsx.snap +21 -100
- package/src/__tests__/__snapshots__/MessageContainer.test.tsx.snap +282 -82
- package/src/__tests__/__snapshots__/MessageImage.test.tsx.snap +8 -4
- package/src/__tests__/__snapshots__/SystemMessage.test.tsx.snap +5 -1
- package/src/__tests__/data.ts +1 -1
- package/src/index.ts +0 -2
- package/src/styles.ts +11 -0
- package/src/{Models.ts → types.ts} +1 -1
- package/src/utils.ts +1 -9
- package/example_bare/vendor/bundle/ruby/2.7.0/gems/ffi-1.17.0/ext/ffi_c/libffi/.ci/compile +0 -351
- package/example_bare/vendor/bundle/ruby/2.7.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.bhaible/Makefile +0 -28
- package/lib/Actions.js.flow +0 -21
- package/lib/Avatar.js.flow +0 -27
- package/lib/Bubble.d.ts +0 -148
- package/lib/Bubble.js.flow +0 -69
- package/lib/Bubble.js.map +0 -1
- package/lib/Composer.js.flow +0 -24
- package/lib/Day.d.ts +0 -15
- package/lib/Day.js +0 -36
- package/lib/Day.js.flow +0 -23
- package/lib/Day.js.map +0 -1
- package/lib/GiftedAvatar.js.flow +0 -17
- package/lib/GiftedChat.js.flow +0 -163
- package/lib/GiftedChat.js.map +0 -1
- package/lib/InputToolbar.js.flow +0 -31
- package/lib/LoadEarlier.js.flow +0 -20
- package/lib/Message.d.ts +0 -67
- package/lib/Message.js +0 -157
- package/lib/Message.js.flow +0 -32
- package/lib/Message.js.map +0 -1
- package/lib/MessageAudio.js.flow +0 -15
- package/lib/MessageContainer.d.ts +0 -103
- package/lib/MessageContainer.js +0 -224
- package/lib/MessageContainer.js.flow +0 -39
- package/lib/MessageContainer.js.map +0 -1
- package/lib/MessageImage.js.flow +0 -20
- package/lib/MessageText.js.flow +0 -23
- package/lib/MessageVideo.js.flow +0 -16
- package/lib/Models.js +0 -2
- package/lib/Models.js.map +0 -1
- package/lib/QuickReplies.js.flow +0 -25
- package/lib/Send.js.flow +0 -19
- package/lib/SystemMessage.js.flow +0 -18
- package/lib/Time.js.flow +0 -19
- package/lib/TypingIndicator.d.ts +0 -6
- package/lib/TypingIndicator.js.map +0 -1
- package/lib/index.js.flow +0 -2
- package/lib/types.js.flow +0 -43
- package/lib/utils.js.flow +0 -16
- package/src/Day.tsx +0 -71
- package/src/GiftedChat.tsx +0 -678
- package/src/Message.tsx +0 -229
- package/src/MessageContainer.tsx +0 -359
package/src/QuickReplies.tsx
CHANGED
|
@@ -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 './
|
|
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 './
|
|
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
|
-
}
|
package/src/SystemMessage.tsx
CHANGED
|
@@ -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 './
|
|
13
|
-
import
|
|
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 './
|
|
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 {
|
|
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
|
-
|
|
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
|
+
})
|
|
@@ -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
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
|
|
8
|
+
let tree
|
|
9
9
|
|
|
10
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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
|
]
|
|
@@ -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
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[
|
|
4
|
+
<KeyboardProvider>
|
|
5
|
+
<View
|
|
6
|
+
style={
|
|
8
7
|
{
|
|
9
8
|
"flex": 1,
|
|
10
|
-
}
|
|
11
|
-
|
|
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
|
`;
|
|
@@ -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
|
},
|