react-native-gifted-chat 2.8.2-alpha.1 → 2.8.2-alpha.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.
- package/README.md +68 -27
- package/package.json +10 -11
- package/src/Actions.tsx +14 -16
- package/src/Avatar.tsx +1 -1
- package/src/Bubble/index.tsx +13 -10
- package/src/Bubble/types.ts +5 -4
- package/src/Composer.tsx +1 -1
- package/src/Day/index.tsx +3 -3
- package/src/GiftedAvatar.tsx +2 -2
- package/src/GiftedChat/index.tsx +53 -46
- package/src/GiftedChat/styles.ts +3 -0
- package/src/GiftedChat/types.ts +15 -18
- package/src/InputToolbar.tsx +10 -10
- package/src/LoadEarlier.tsx +7 -7
- package/src/LoadEarlierMessages.tsx +97 -0
- package/src/Message/index.tsx +4 -18
- package/src/Message/types.ts +2 -2
- package/src/MessageAudio.tsx +1 -1
- package/src/MessageContainer/components/DayAnimated/index.tsx +9 -9
- package/src/MessageContainer/components/DayAnimated/types.ts +1 -1
- package/src/MessageContainer/components/Item/index.tsx +3 -3
- package/src/MessageContainer/components/Item/types.ts +1 -1
- package/src/MessageContainer/index.tsx +22 -27
- package/src/MessageContainer/types.ts +6 -12
- package/src/MessageImage.tsx +119 -17
- package/src/MessageText.tsx +10 -45
- package/src/MessageVideo.tsx +1 -1
- package/src/QuickReplies.tsx +2 -2
- package/src/Send.tsx +3 -4
- package/src/SystemMessage.tsx +1 -1
- package/src/Time.tsx +1 -1
- package/src/TypingIndicator/index.tsx +2 -2
- package/src/__tests__/DayAnimated.test.tsx +4 -4
- package/src/__tests__/GiftedChat.test.tsx +3 -3
- package/src/__tests__/LoadEarlier.test.tsx +3 -3
- package/src/__tests__/__snapshots__/Actions.test.tsx.snap +39 -7
- package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +20 -22
- package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +38 -7
- package/src/__tests__/__snapshots__/MessageImage.test.tsx.snap +34 -15
- package/src/__tests__/__snapshots__/Send.test.tsx.snap +70 -10
- package/src/components/TouchableOpacity.tsx +45 -0
- package/src/types.ts +1 -3
- package/src/utils.ts +2 -2
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`should render <GiftedChat/> and compare with snapshot 1`] = `
|
|
4
|
-
<
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
{
|
|
7
|
+
"flex": 1,
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
>
|
|
5
11
|
<View
|
|
12
|
+
onLayout={[Function]}
|
|
6
13
|
style={
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
[
|
|
15
|
+
{
|
|
16
|
+
"flex": 1,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"overflow": "hidden",
|
|
20
|
+
},
|
|
21
|
+
]
|
|
10
22
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
style={
|
|
15
|
-
[
|
|
16
|
-
{
|
|
17
|
-
"flex": 1,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"overflow": "hidden",
|
|
21
|
-
},
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
testID="GC_WRAPPER"
|
|
25
|
-
/>
|
|
26
|
-
</View>
|
|
27
|
-
</KeyboardProvider>
|
|
23
|
+
testID="GC_WRAPPER"
|
|
24
|
+
/>
|
|
25
|
+
</View>
|
|
28
26
|
`;
|
|
29
27
|
|
|
30
|
-
exports[`should render <GiftedChat/> with
|
|
28
|
+
exports[`should render <GiftedChat/> with isKeyboardInternallyHandled=false 1`] = `
|
|
31
29
|
<View
|
|
32
30
|
style={
|
|
33
31
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`should render <
|
|
3
|
+
exports[`should render <LoadEarlierMessages /> and compare with snapshot 1`] = `
|
|
4
4
|
<View
|
|
5
5
|
accessibilityRole="button"
|
|
6
6
|
accessibilityState={
|
|
@@ -23,7 +23,33 @@ exports[`should render <LoadEarlier /> and compare with snapshot 1`] = `
|
|
|
23
23
|
accessible={true}
|
|
24
24
|
collapsable={false}
|
|
25
25
|
focusable={true}
|
|
26
|
+
jestAnimatedProps={
|
|
27
|
+
{
|
|
28
|
+
"value": {},
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
jestAnimatedStyle={
|
|
32
|
+
{
|
|
33
|
+
"value": {
|
|
34
|
+
"opacity": 1,
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
jestInlineStyle={
|
|
39
|
+
[
|
|
40
|
+
[
|
|
41
|
+
{
|
|
42
|
+
"alignItems": "center",
|
|
43
|
+
"marginBottom": 10,
|
|
44
|
+
"marginTop": 5,
|
|
45
|
+
},
|
|
46
|
+
undefined,
|
|
47
|
+
],
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
onBlur={[Function]}
|
|
26
51
|
onClick={[Function]}
|
|
52
|
+
onFocus={[Function]}
|
|
27
53
|
onResponderGrant={[Function]}
|
|
28
54
|
onResponderMove={[Function]}
|
|
29
55
|
onResponderRelease={[Function]}
|
|
@@ -31,12 +57,17 @@ exports[`should render <LoadEarlier /> and compare with snapshot 1`] = `
|
|
|
31
57
|
onResponderTerminationRequest={[Function]}
|
|
32
58
|
onStartShouldSetResponder={[Function]}
|
|
33
59
|
style={
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
60
|
+
[
|
|
61
|
+
{
|
|
62
|
+
"alignItems": "center",
|
|
63
|
+
"marginBottom": 10,
|
|
64
|
+
"marginTop": 5,
|
|
65
|
+
},
|
|
66
|
+
undefined,
|
|
67
|
+
{
|
|
68
|
+
"opacity": 1,
|
|
69
|
+
},
|
|
70
|
+
]
|
|
40
71
|
}
|
|
41
72
|
>
|
|
42
73
|
<View
|
|
@@ -2,23 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`MessageImage should render <MessageImage /> and compare with snapshot 1`] = `
|
|
4
4
|
<View>
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
<View
|
|
6
|
+
accessibilityState={
|
|
7
|
+
{
|
|
8
|
+
"busy": undefined,
|
|
9
|
+
"checked": undefined,
|
|
10
|
+
"disabled": undefined,
|
|
11
|
+
"expanded": undefined,
|
|
12
|
+
"selected": undefined,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
accessibilityValue={
|
|
16
|
+
{
|
|
17
|
+
"max": undefined,
|
|
18
|
+
"min": undefined,
|
|
19
|
+
"now": undefined,
|
|
20
|
+
"text": undefined,
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
accessible={true}
|
|
24
|
+
collapsable={false}
|
|
25
|
+
focusable={true}
|
|
26
|
+
onClick={[Function]}
|
|
27
|
+
onResponderGrant={[Function]}
|
|
28
|
+
onResponderMove={[Function]}
|
|
29
|
+
onResponderRelease={[Function]}
|
|
30
|
+
onResponderTerminate={[Function]}
|
|
31
|
+
onResponderTerminationRequest={[Function]}
|
|
32
|
+
onStartShouldSetResponder={[Function]}
|
|
33
|
+
style={
|
|
34
|
+
{
|
|
35
|
+
"opacity": 1,
|
|
36
|
+
}
|
|
19
37
|
}
|
|
20
38
|
>
|
|
21
39
|
<Image
|
|
40
|
+
onLayout={[Function]}
|
|
22
41
|
source={
|
|
23
42
|
{
|
|
24
43
|
"uri": "url://to/image.png",
|
|
@@ -37,7 +56,7 @@ exports[`MessageImage should render <MessageImage /> and compare with snapshot
|
|
|
37
56
|
]
|
|
38
57
|
}
|
|
39
58
|
/>
|
|
40
|
-
</
|
|
59
|
+
</View>
|
|
41
60
|
</View>
|
|
42
61
|
`;
|
|
43
62
|
|
|
@@ -24,7 +24,32 @@ exports[`Send should always render <Send /> and compare with snapshot 1`] = `
|
|
|
24
24
|
accessible={true}
|
|
25
25
|
collapsable={false}
|
|
26
26
|
focusable={true}
|
|
27
|
+
jestAnimatedProps={
|
|
28
|
+
{
|
|
29
|
+
"value": {},
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
jestAnimatedStyle={
|
|
33
|
+
{
|
|
34
|
+
"value": {
|
|
35
|
+
"opacity": 1,
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
jestInlineStyle={
|
|
40
|
+
[
|
|
41
|
+
[
|
|
42
|
+
{
|
|
43
|
+
"height": 44,
|
|
44
|
+
"justifyContent": "flex-end",
|
|
45
|
+
},
|
|
46
|
+
undefined,
|
|
47
|
+
],
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
onBlur={[Function]}
|
|
27
51
|
onClick={[Function]}
|
|
52
|
+
onFocus={[Function]}
|
|
28
53
|
onResponderGrant={[Function]}
|
|
29
54
|
onResponderMove={[Function]}
|
|
30
55
|
onResponderRelease={[Function]}
|
|
@@ -32,11 +57,16 @@ exports[`Send should always render <Send /> and compare with snapshot 1`] = `
|
|
|
32
57
|
onResponderTerminationRequest={[Function]}
|
|
33
58
|
onStartShouldSetResponder={[Function]}
|
|
34
59
|
style={
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
60
|
+
[
|
|
61
|
+
{
|
|
62
|
+
"height": 44,
|
|
63
|
+
"justifyContent": "flex-end",
|
|
64
|
+
},
|
|
65
|
+
undefined,
|
|
66
|
+
{
|
|
67
|
+
"opacity": 1,
|
|
68
|
+
},
|
|
69
|
+
]
|
|
40
70
|
}
|
|
41
71
|
testID="GC_SEND_TOUCHABLE"
|
|
42
72
|
>
|
|
@@ -90,7 +120,32 @@ exports[`Send should render <Send /> where there is input and compare with snaps
|
|
|
90
120
|
accessible={true}
|
|
91
121
|
collapsable={false}
|
|
92
122
|
focusable={true}
|
|
123
|
+
jestAnimatedProps={
|
|
124
|
+
{
|
|
125
|
+
"value": {},
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
jestAnimatedStyle={
|
|
129
|
+
{
|
|
130
|
+
"value": {
|
|
131
|
+
"opacity": 1,
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
jestInlineStyle={
|
|
136
|
+
[
|
|
137
|
+
[
|
|
138
|
+
{
|
|
139
|
+
"height": 44,
|
|
140
|
+
"justifyContent": "flex-end",
|
|
141
|
+
},
|
|
142
|
+
undefined,
|
|
143
|
+
],
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
onBlur={[Function]}
|
|
93
147
|
onClick={[Function]}
|
|
148
|
+
onFocus={[Function]}
|
|
94
149
|
onResponderGrant={[Function]}
|
|
95
150
|
onResponderMove={[Function]}
|
|
96
151
|
onResponderRelease={[Function]}
|
|
@@ -98,11 +153,16 @@ exports[`Send should render <Send /> where there is input and compare with snaps
|
|
|
98
153
|
onResponderTerminationRequest={[Function]}
|
|
99
154
|
onStartShouldSetResponder={[Function]}
|
|
100
155
|
style={
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
156
|
+
[
|
|
157
|
+
{
|
|
158
|
+
"height": 44,
|
|
159
|
+
"justifyContent": "flex-end",
|
|
160
|
+
},
|
|
161
|
+
undefined,
|
|
162
|
+
{
|
|
163
|
+
"opacity": 1,
|
|
164
|
+
},
|
|
165
|
+
]
|
|
106
166
|
}
|
|
107
167
|
testID="GC_SEND_TOUCHABLE"
|
|
108
168
|
>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { useCallback } from 'react'
|
|
2
|
+
import { Pressable } from 'react-native-gesture-handler'
|
|
3
|
+
import Animated, {
|
|
4
|
+
useAnimatedStyle,
|
|
5
|
+
useSharedValue,
|
|
6
|
+
withTiming,
|
|
7
|
+
} from 'react-native-reanimated'
|
|
8
|
+
|
|
9
|
+
const AnimatedPressable = Animated.createAnimatedComponent(Pressable)
|
|
10
|
+
|
|
11
|
+
export interface TouchableOpacityProps extends React.ComponentProps<typeof AnimatedPressable> {
|
|
12
|
+
activeOpacity?: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function TouchableOpacity({
|
|
16
|
+
children,
|
|
17
|
+
style,
|
|
18
|
+
activeOpacity = 0.2,
|
|
19
|
+
...rest
|
|
20
|
+
}: TouchableOpacityProps) {
|
|
21
|
+
const opacity = useSharedValue(1)
|
|
22
|
+
|
|
23
|
+
const handlePressIn = useCallback(() => {
|
|
24
|
+
opacity.value = withTiming(activeOpacity, { duration: 150 })
|
|
25
|
+
}, [activeOpacity, opacity])
|
|
26
|
+
|
|
27
|
+
const handlePressOut = useCallback(() => {
|
|
28
|
+
opacity.value = withTiming(1, { duration: 150 })
|
|
29
|
+
}, [opacity])
|
|
30
|
+
|
|
31
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
32
|
+
opacity: opacity.value,
|
|
33
|
+
}))
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<AnimatedPressable
|
|
37
|
+
{...rest}
|
|
38
|
+
onPressIn={handlePressIn}
|
|
39
|
+
onPressOut={handlePressOut}
|
|
40
|
+
style={[style, animatedStyle]}
|
|
41
|
+
>
|
|
42
|
+
{children}
|
|
43
|
+
</AnimatedPressable>
|
|
44
|
+
)
|
|
45
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { StyleProp, ViewStyle } from 'react-native'
|
|
2
|
-
import { LightboxProps } from 'react-native-lightbox-v2'
|
|
3
2
|
|
|
4
3
|
export { ActionsProps } from './Actions'
|
|
5
4
|
export { AvatarProps } from './Avatar'
|
|
@@ -14,7 +13,7 @@ export { ComposerProps } from './Composer'
|
|
|
14
13
|
export { DayProps } from './Day'
|
|
15
14
|
export { GiftedAvatarProps } from './GiftedAvatar'
|
|
16
15
|
export { InputToolbarProps } from './InputToolbar'
|
|
17
|
-
export {
|
|
16
|
+
export { LoadEarlierMessagesProps } from './LoadEarlierMessages'
|
|
18
17
|
export { MessageProps } from './Message'
|
|
19
18
|
export { MessageContainerProps } from './MessageContainer'
|
|
20
19
|
export { MessageImageProps } from './MessageImage'
|
|
@@ -77,7 +76,6 @@ export interface MessageVideoProps<TMessage extends IMessage> {
|
|
|
77
76
|
containerStyle?: StyleProp<ViewStyle>
|
|
78
77
|
videoStyle?: StyleProp<ViewStyle>
|
|
79
78
|
videoProps?: object
|
|
80
|
-
lightboxProps?: LightboxProps
|
|
81
79
|
}
|
|
82
80
|
|
|
83
81
|
export interface MessageAudioProps<TMessage extends IMessage> {
|
package/src/utils.ts
CHANGED
|
@@ -46,7 +46,7 @@ function processCallbackArguments (args: unknown[]): unknown[] {
|
|
|
46
46
|
return params
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
export function useCallbackDebounced<T extends (...args: any[]) => any>(callbackFunc: T, deps: React.DependencyList = [], time: number): (...args: Parameters<T>) => void {
|
|
51
51
|
const timeoutId = useRef<ReturnType<typeof setTimeout>>(undefined)
|
|
52
52
|
|
|
@@ -70,7 +70,7 @@ export function useCallbackDebounced<T extends (...args: any[]) => any>(callback
|
|
|
70
70
|
return savedFunc
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
export function useCallbackThrottled<T extends (...args: any[]) => any>(callbackFunc: T, deps: React.DependencyList = [], time: number): (...args: Parameters<T>) => void {
|
|
75
75
|
const lastExecution = useRef<number>(0)
|
|
76
76
|
const timeoutId = useRef<ReturnType<typeof setTimeout>>(undefined)
|