react-native-gifted-chat 2.8.2-alpha.4 → 2.8.2-alpha.6
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/CHANGELOG_2.8.1_to_2.8.2-alpha.5.md +374 -0
- package/package.json +1 -1
- package/src/GiftedChat/index.tsx +6 -11
- package/src/LoadEarlierMessages.tsx +47 -50
- package/src/MessageContainer/components/DayAnimated/index.tsx +1 -0
- package/src/MessageContainer/index.tsx +5 -5
- package/src/MessageText.tsx +2 -1
- package/src/SystemMessage.tsx +29 -23
- package/src/__tests__/__snapshots__/Actions.test.tsx.snap +61 -57
- package/src/__tests__/__snapshots__/Bubble.test.tsx.snap +0 -1
- package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +56 -36
- package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +64 -52
- package/src/__tests__/__snapshots__/Message.test.tsx.snap +0 -3
- package/src/__tests__/__snapshots__/MessageText.test.tsx.snap +0 -1
- package/src/__tests__/__snapshots__/Send.test.tsx.snap +120 -108
- package/src/__tests__/__snapshots__/SystemMessage.test.tsx.snap +38 -8
- package/src/components/TouchableOpacity.tsx +26 -15
- package/src/LoadEarlier.tsx +0 -95
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Send should always render <Send /> and compare with snapshot 1`] = `
|
|
4
4
|
<View
|
|
5
|
-
accessibilityLabel="send"
|
|
6
|
-
accessibilityRole="button"
|
|
7
5
|
accessibilityState={
|
|
8
6
|
{
|
|
9
7
|
"busy": undefined,
|
|
10
8
|
"checked": undefined,
|
|
11
|
-
"disabled":
|
|
9
|
+
"disabled": undefined,
|
|
12
10
|
"expanded": undefined,
|
|
13
11
|
"selected": undefined,
|
|
14
12
|
}
|
|
@@ -24,29 +22,6 @@ exports[`Send should always render <Send /> and compare with snapshot 1`] = `
|
|
|
24
22
|
accessible={true}
|
|
25
23
|
collapsable={false}
|
|
26
24
|
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
25
|
onBlur={[Function]}
|
|
51
26
|
onClick={[Function]}
|
|
52
27
|
onFocus={[Function]}
|
|
@@ -56,40 +31,71 @@ exports[`Send should always render <Send /> and compare with snapshot 1`] = `
|
|
|
56
31
|
onResponderTerminate={[Function]}
|
|
57
32
|
onResponderTerminationRequest={[Function]}
|
|
58
33
|
onStartShouldSetResponder={[Function]}
|
|
59
|
-
|
|
60
|
-
|
|
34
|
+
>
|
|
35
|
+
<View
|
|
36
|
+
accessibilityLabel="send"
|
|
37
|
+
accessibilityRole="button"
|
|
38
|
+
accessible={true}
|
|
39
|
+
collapsable={false}
|
|
40
|
+
disabled={false}
|
|
41
|
+
jestAnimatedProps={
|
|
61
42
|
{
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
43
|
+
"value": {},
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
jestAnimatedStyle={
|
|
66
47
|
{
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
<Text
|
|
75
|
-
style={
|
|
48
|
+
"value": {
|
|
49
|
+
"opacity": 1,
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
jestInlineStyle={
|
|
54
|
+
[
|
|
76
55
|
[
|
|
77
56
|
{
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"fontSize": 17,
|
|
81
|
-
"fontWeight": "600",
|
|
82
|
-
"marginBottom": 12,
|
|
83
|
-
"marginLeft": 10,
|
|
84
|
-
"marginRight": 10,
|
|
57
|
+
"height": 44,
|
|
58
|
+
"justifyContent": "flex-end",
|
|
85
59
|
},
|
|
86
60
|
undefined,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
61
|
+
],
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
style={
|
|
65
|
+
[
|
|
66
|
+
{
|
|
67
|
+
"height": 44,
|
|
68
|
+
"justifyContent": "flex-end",
|
|
69
|
+
},
|
|
70
|
+
undefined,
|
|
71
|
+
{
|
|
72
|
+
"opacity": 1,
|
|
73
|
+
},
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
testID="GC_SEND_TOUCHABLE"
|
|
77
|
+
>
|
|
78
|
+
<View>
|
|
79
|
+
<Text
|
|
80
|
+
style={
|
|
81
|
+
[
|
|
82
|
+
{
|
|
83
|
+
"backgroundColor": "transparent",
|
|
84
|
+
"color": "#0084ff",
|
|
85
|
+
"fontSize": 17,
|
|
86
|
+
"fontWeight": "600",
|
|
87
|
+
"marginBottom": 12,
|
|
88
|
+
"marginLeft": 10,
|
|
89
|
+
"marginRight": 10,
|
|
90
|
+
},
|
|
91
|
+
undefined,
|
|
92
|
+
undefined,
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
>
|
|
96
|
+
Send
|
|
97
|
+
</Text>
|
|
98
|
+
</View>
|
|
93
99
|
</View>
|
|
94
100
|
</View>
|
|
95
101
|
`;
|
|
@@ -98,13 +104,11 @@ exports[`Send should not render <Send /> and compare with snapshot 1`] = `null`;
|
|
|
98
104
|
|
|
99
105
|
exports[`Send should render <Send /> where there is input and compare with snapshot 1`] = `
|
|
100
106
|
<View
|
|
101
|
-
accessibilityLabel="send"
|
|
102
|
-
accessibilityRole="button"
|
|
103
107
|
accessibilityState={
|
|
104
108
|
{
|
|
105
109
|
"busy": undefined,
|
|
106
110
|
"checked": undefined,
|
|
107
|
-
"disabled":
|
|
111
|
+
"disabled": undefined,
|
|
108
112
|
"expanded": undefined,
|
|
109
113
|
"selected": undefined,
|
|
110
114
|
}
|
|
@@ -120,29 +124,6 @@ exports[`Send should render <Send /> where there is input and compare with snaps
|
|
|
120
124
|
accessible={true}
|
|
121
125
|
collapsable={false}
|
|
122
126
|
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
127
|
onBlur={[Function]}
|
|
147
128
|
onClick={[Function]}
|
|
148
129
|
onFocus={[Function]}
|
|
@@ -152,40 +133,71 @@ exports[`Send should render <Send /> where there is input and compare with snaps
|
|
|
152
133
|
onResponderTerminate={[Function]}
|
|
153
134
|
onResponderTerminationRequest={[Function]}
|
|
154
135
|
onStartShouldSetResponder={[Function]}
|
|
155
|
-
|
|
156
|
-
|
|
136
|
+
>
|
|
137
|
+
<View
|
|
138
|
+
accessibilityLabel="send"
|
|
139
|
+
accessibilityRole="button"
|
|
140
|
+
accessible={true}
|
|
141
|
+
collapsable={false}
|
|
142
|
+
disabled={false}
|
|
143
|
+
jestAnimatedProps={
|
|
157
144
|
{
|
|
158
|
-
"
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
145
|
+
"value": {},
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
jestAnimatedStyle={
|
|
162
149
|
{
|
|
163
|
-
"
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
<Text
|
|
171
|
-
style={
|
|
150
|
+
"value": {
|
|
151
|
+
"opacity": 1,
|
|
152
|
+
},
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
jestInlineStyle={
|
|
156
|
+
[
|
|
172
157
|
[
|
|
173
158
|
{
|
|
174
|
-
"
|
|
175
|
-
"
|
|
176
|
-
"fontSize": 17,
|
|
177
|
-
"fontWeight": "600",
|
|
178
|
-
"marginBottom": 12,
|
|
179
|
-
"marginLeft": 10,
|
|
180
|
-
"marginRight": 10,
|
|
159
|
+
"height": 44,
|
|
160
|
+
"justifyContent": "flex-end",
|
|
181
161
|
},
|
|
182
162
|
undefined,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
163
|
+
],
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
style={
|
|
167
|
+
[
|
|
168
|
+
{
|
|
169
|
+
"height": 44,
|
|
170
|
+
"justifyContent": "flex-end",
|
|
171
|
+
},
|
|
172
|
+
undefined,
|
|
173
|
+
{
|
|
174
|
+
"opacity": 1,
|
|
175
|
+
},
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
testID="GC_SEND_TOUCHABLE"
|
|
179
|
+
>
|
|
180
|
+
<View>
|
|
181
|
+
<Text
|
|
182
|
+
style={
|
|
183
|
+
[
|
|
184
|
+
{
|
|
185
|
+
"backgroundColor": "transparent",
|
|
186
|
+
"color": "#0084ff",
|
|
187
|
+
"fontSize": 17,
|
|
188
|
+
"fontWeight": "600",
|
|
189
|
+
"marginBottom": 12,
|
|
190
|
+
"marginLeft": 10,
|
|
191
|
+
"marginRight": 10,
|
|
192
|
+
},
|
|
193
|
+
undefined,
|
|
194
|
+
undefined,
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
>
|
|
198
|
+
Send
|
|
199
|
+
</Text>
|
|
200
|
+
</View>
|
|
189
201
|
</View>
|
|
190
202
|
</View>
|
|
191
203
|
`;
|
|
@@ -15,6 +15,7 @@ exports[`SystemMessage should render <SystemMessage /> and compare with snapshot
|
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
"marginBottom": 10,
|
|
18
|
+
"marginHorizontal": 20,
|
|
18
19
|
"marginTop": 5,
|
|
19
20
|
},
|
|
20
21
|
undefined,
|
|
@@ -22,21 +23,50 @@ exports[`SystemMessage should render <SystemMessage /> and compare with snapshot
|
|
|
22
23
|
}
|
|
23
24
|
>
|
|
24
25
|
<View>
|
|
25
|
-
<
|
|
26
|
+
<View
|
|
26
27
|
style={
|
|
27
28
|
[
|
|
28
29
|
{
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
30
|
+
"marginBottom": 5,
|
|
31
|
+
"marginLeft": 10,
|
|
32
|
+
"marginRight": 10,
|
|
33
|
+
"marginTop": 5,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"backgroundColor": "rgba(0,0,0,0.05)",
|
|
37
|
+
"borderColor": "rgba(0,0,0,0.1)",
|
|
38
|
+
"borderRadius": 20,
|
|
39
|
+
"borderWidth": 1,
|
|
40
|
+
"paddingHorizontal": 10,
|
|
41
|
+
"paddingVertical": 10,
|
|
33
42
|
},
|
|
34
|
-
undefined,
|
|
35
43
|
]
|
|
36
44
|
}
|
|
37
45
|
>
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
<Text
|
|
47
|
+
style={
|
|
48
|
+
[
|
|
49
|
+
{
|
|
50
|
+
"color": "black",
|
|
51
|
+
},
|
|
52
|
+
undefined,
|
|
53
|
+
[
|
|
54
|
+
{
|
|
55
|
+
"backgroundColor": "transparent",
|
|
56
|
+
"fontSize": 12,
|
|
57
|
+
"fontStyle": "italic",
|
|
58
|
+
"fontWeight": "300",
|
|
59
|
+
},
|
|
60
|
+
undefined,
|
|
61
|
+
],
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
>
|
|
65
|
+
<Text>
|
|
66
|
+
test
|
|
67
|
+
</Text>
|
|
68
|
+
</Text>
|
|
69
|
+
</View>
|
|
40
70
|
</View>
|
|
41
71
|
</View>
|
|
42
72
|
`;
|
|
@@ -6,40 +6,51 @@ import Animated, {
|
|
|
6
6
|
withTiming,
|
|
7
7
|
} from 'react-native-reanimated'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export interface TouchableOpacityProps extends React.ComponentProps<typeof AnimatedPressable> {
|
|
9
|
+
export type TouchableOpacityProps = React.ComponentProps<typeof Pressable> & {
|
|
12
10
|
activeOpacity?: number
|
|
13
|
-
}
|
|
11
|
+
} & React.ComponentProps<typeof Animated.View>
|
|
14
12
|
|
|
15
|
-
export
|
|
13
|
+
export const TouchableOpacity: React.FC<TouchableOpacityProps> = ({
|
|
16
14
|
children,
|
|
17
15
|
style,
|
|
18
16
|
activeOpacity = 0.2,
|
|
17
|
+
onPress,
|
|
19
18
|
...rest
|
|
20
|
-
}
|
|
19
|
+
}) => {
|
|
21
20
|
const opacity = useSharedValue(1)
|
|
21
|
+
const isAnimationInFinished = useSharedValue(false)
|
|
22
22
|
|
|
23
23
|
const handlePressIn = useCallback(() => {
|
|
24
|
-
opacity.value = withTiming(activeOpacity, { duration: 150 })
|
|
25
|
-
|
|
24
|
+
opacity.value = withTiming(activeOpacity, { duration: 150 }, () => {
|
|
25
|
+
isAnimationInFinished.value = true
|
|
26
|
+
})
|
|
27
|
+
}, [activeOpacity, opacity, isAnimationInFinished])
|
|
26
28
|
|
|
27
29
|
const handlePressOut = useCallback(() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
'worklet'
|
|
32
|
+
|
|
33
|
+
opacity.value = withTiming(1, { duration: 150 })
|
|
34
|
+
isAnimationInFinished.value = false
|
|
35
|
+
}, isAnimationInFinished.value ? 0 : 150)
|
|
36
|
+
}, [opacity, isAnimationInFinished])
|
|
30
37
|
|
|
31
38
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
32
39
|
opacity: opacity.value,
|
|
33
40
|
}))
|
|
34
41
|
|
|
35
42
|
return (
|
|
36
|
-
<
|
|
37
|
-
{...rest}
|
|
43
|
+
<Pressable
|
|
38
44
|
onPressIn={handlePressIn}
|
|
39
45
|
onPressOut={handlePressOut}
|
|
40
|
-
|
|
46
|
+
onPress={onPress}
|
|
41
47
|
>
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
<Animated.View
|
|
49
|
+
{...rest}
|
|
50
|
+
style={[style, animatedStyle]}
|
|
51
|
+
>
|
|
52
|
+
{children}
|
|
53
|
+
</Animated.View>
|
|
54
|
+
</Pressable>
|
|
44
55
|
)
|
|
45
56
|
}
|
package/src/LoadEarlier.tsx
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
ActivityIndicator,
|
|
4
|
-
Platform,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
Text,
|
|
7
|
-
View,
|
|
8
|
-
StyleProp,
|
|
9
|
-
ViewStyle,
|
|
10
|
-
TextStyle,
|
|
11
|
-
} from 'react-native'
|
|
12
|
-
import Color from './Color'
|
|
13
|
-
import { TouchableOpacity } from './components/TouchableOpacity'
|
|
14
|
-
import stylesCommon from './styles'
|
|
15
|
-
|
|
16
|
-
const styles = StyleSheet.create({
|
|
17
|
-
container: {
|
|
18
|
-
alignItems: 'center',
|
|
19
|
-
marginTop: 5,
|
|
20
|
-
marginBottom: 10,
|
|
21
|
-
},
|
|
22
|
-
wrapper: {
|
|
23
|
-
backgroundColor: Color.defaultColor,
|
|
24
|
-
borderRadius: 15,
|
|
25
|
-
height: 30,
|
|
26
|
-
paddingLeft: 10,
|
|
27
|
-
paddingRight: 10,
|
|
28
|
-
},
|
|
29
|
-
text: {
|
|
30
|
-
backgroundColor: Color.backgroundTransparent,
|
|
31
|
-
color: Color.white,
|
|
32
|
-
fontSize: 12,
|
|
33
|
-
},
|
|
34
|
-
activityIndicator: {
|
|
35
|
-
marginTop: Platform.select({
|
|
36
|
-
ios: -14,
|
|
37
|
-
android: -16,
|
|
38
|
-
default: -15,
|
|
39
|
-
}),
|
|
40
|
-
},
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
export interface LoadEarlierMessagesProps {
|
|
44
|
-
isLoadingEarlier?: boolean
|
|
45
|
-
label?: string
|
|
46
|
-
containerStyle?: StyleProp<ViewStyle>
|
|
47
|
-
wrapperStyle?: StyleProp<ViewStyle>
|
|
48
|
-
textStyle?: StyleProp<TextStyle>
|
|
49
|
-
activityIndicatorStyle?: StyleProp<ViewStyle>
|
|
50
|
-
activityIndicatorColor?: string
|
|
51
|
-
activityIndicatorSize?: number | 'small' | 'large'
|
|
52
|
-
onPress: () => void
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const LoadEarlierMessages: React.FC<LoadEarlierMessagesProps> = ({
|
|
56
|
-
isLoadingEarlier = false,
|
|
57
|
-
onPress,
|
|
58
|
-
label = 'Load earlier messages',
|
|
59
|
-
containerStyle,
|
|
60
|
-
wrapperStyle,
|
|
61
|
-
textStyle,
|
|
62
|
-
activityIndicatorColor = 'white',
|
|
63
|
-
activityIndicatorSize = 'small',
|
|
64
|
-
activityIndicatorStyle,
|
|
65
|
-
}) => {
|
|
66
|
-
const loadingContent = useMemo(() => (
|
|
67
|
-
<View>
|
|
68
|
-
<Text style={[styles.text, textStyle, { opacity: 0 }]}>
|
|
69
|
-
{label}
|
|
70
|
-
</Text>
|
|
71
|
-
<ActivityIndicator
|
|
72
|
-
color={activityIndicatorColor!}
|
|
73
|
-
size={activityIndicatorSize!}
|
|
74
|
-
style={[styles.activityIndicator, activityIndicatorStyle]}
|
|
75
|
-
/>
|
|
76
|
-
</View>
|
|
77
|
-
), [label, textStyle, activityIndicatorColor, activityIndicatorSize, activityIndicatorStyle])
|
|
78
|
-
|
|
79
|
-
const labelContent = useMemo(() => (
|
|
80
|
-
<Text style={[styles.text, textStyle]}>{label}</Text>
|
|
81
|
-
), [label, textStyle])
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<TouchableOpacity
|
|
85
|
-
style={[styles.container, containerStyle]}
|
|
86
|
-
onPress={onPress}
|
|
87
|
-
disabled={isLoadingEarlier}
|
|
88
|
-
accessibilityRole='button'
|
|
89
|
-
>
|
|
90
|
-
<View style={[stylesCommon.centerItems, styles.wrapper, wrapperStyle]}>
|
|
91
|
-
{isLoadingEarlier ? loadingContent : labelContent}
|
|
92
|
-
</View>
|
|
93
|
-
</TouchableOpacity>
|
|
94
|
-
)
|
|
95
|
-
}
|