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.
- package/CHANGELOG.md +435 -0
- package/README.md +68 -12
- package/lib/Actions.d.ts +16 -0
- package/lib/Actions.d.ts.map +1 -0
- package/lib/Actions.js +65 -0
- package/lib/Actions.js.map +1 -0
- package/lib/Avatar.d.ts +19 -0
- package/lib/Avatar.d.ts.map +1 -0
- package/lib/Avatar.js +93 -0
- package/lib/Avatar.js.map +1 -0
- package/lib/Bubble/index.d.ts +6 -0
- package/lib/Bubble/index.d.ts.map +1 -0
- package/lib/Bubble/index.js +269 -0
- package/lib/Bubble/index.js.map +1 -0
- package/lib/Bubble/styles.d.ts +57 -0
- package/lib/Bubble/styles.d.ts.map +1 -0
- package/lib/Bubble/styles.js +59 -0
- package/lib/Bubble/styles.js.map +1 -0
- package/lib/Bubble/types.d.ts +59 -0
- package/lib/Bubble/types.d.ts.map +1 -0
- package/lib/Bubble/types.js +2 -0
- package/lib/Bubble/types.js.map +1 -0
- package/lib/Color.d.ts +18 -0
- package/lib/Color.d.ts.map +1 -0
- package/lib/Color.js +18 -0
- package/lib/Color.js.map +1 -0
- package/lib/Composer.d.ts +9 -0
- package/lib/Composer.d.ts.map +1 -0
- package/lib/Composer.js +56 -0
- package/lib/Composer.js.map +1 -0
- package/lib/Constant.d.ts +8 -0
- package/lib/Constant.d.ts.map +1 -0
- package/lib/Constant.js +8 -0
- package/lib/Constant.js.map +1 -0
- package/lib/Day/index.d.ts +5 -0
- package/lib/Day/index.d.ts.map +1 -0
- package/lib/Day/index.js +40 -0
- package/lib/Day/index.js.map +1 -0
- package/lib/Day/styles.d.ts +21 -0
- package/lib/Day/styles.d.ts.map +1 -0
- package/lib/Day/styles.js +22 -0
- package/lib/Day/styles.js.map +1 -0
- package/lib/Day/types.d.ts +11 -0
- package/lib/Day/types.d.ts.map +1 -0
- package/lib/Day/types.js +2 -0
- package/lib/Day/types.js.map +1 -0
- package/lib/GiftedAvatar.d.ts +12 -0
- package/lib/GiftedAvatar.d.ts.map +1 -0
- package/lib/GiftedAvatar.js +101 -0
- package/lib/GiftedAvatar.js.map +1 -0
- package/lib/GiftedChat/index.d.ts +10 -0
- package/lib/GiftedChat/index.d.ts.map +1 -0
- package/lib/GiftedChat/index.js +241 -0
- package/lib/GiftedChat/index.js.map +1 -0
- package/lib/GiftedChat/styles.d.ts +13 -0
- package/lib/GiftedChat/styles.d.ts.map +1 -0
- package/lib/GiftedChat/styles.js +13 -0
- package/lib/GiftedChat/styles.js.map +1 -0
- package/lib/GiftedChat/types.d.ts +90 -0
- package/lib/GiftedChat/types.d.ts.map +1 -0
- package/lib/GiftedChat/types.js +2 -0
- package/lib/GiftedChat/types.js.map +1 -0
- package/lib/GiftedChatContext.d.ts +11 -0
- package/lib/GiftedChatContext.d.ts.map +1 -0
- package/lib/GiftedChatContext.js +10 -0
- package/lib/GiftedChatContext.js.map +1 -0
- package/lib/InputToolbar.d.ts +36 -0
- package/lib/InputToolbar.d.ts.map +1 -0
- package/lib/InputToolbar.js +108 -0
- package/lib/InputToolbar.js.map +1 -0
- package/lib/LoadEarlierMessages.d.ts +17 -0
- package/lib/LoadEarlierMessages.d.ts.map +1 -0
- package/lib/LoadEarlierMessages.js +45 -0
- package/lib/LoadEarlierMessages.js.map +1 -0
- package/lib/Message/index.d.ts +6 -0
- package/lib/Message/index.d.ts.map +1 -0
- package/lib/Message/index.js +180 -0
- package/lib/Message/index.js.map +1 -0
- package/lib/Message/styles.d.ts +18 -0
- package/lib/Message/styles.d.ts.map +1 -0
- package/lib/Message/styles.js +18 -0
- package/lib/Message/styles.js.map +1 -0
- package/lib/Message/types.d.ts +25 -0
- package/lib/Message/types.d.ts.map +1 -0
- package/lib/Message/types.js +2 -0
- package/lib/Message/types.js.map +1 -0
- package/lib/MessageAudio.d.ts +3 -0
- package/lib/MessageAudio.d.ts.map +1 -0
- package/lib/MessageAudio.js +25 -0
- package/lib/MessageAudio.js.map +1 -0
- package/lib/MessageImage.d.ts +12 -0
- package/lib/MessageImage.d.ts.map +1 -0
- package/lib/MessageImage.js +164 -0
- package/lib/MessageImage.js.map +1 -0
- package/lib/MessageReply.d.ts +15 -0
- package/lib/MessageReply.d.ts.map +1 -0
- package/lib/MessageReply.js +103 -0
- package/lib/MessageReply.js.map +1 -0
- package/lib/MessageText.d.ts +24 -0
- package/lib/MessageText.d.ts.map +1 -0
- package/lib/MessageText.js +41 -0
- package/lib/MessageText.js.map +1 -0
- package/lib/MessageVideo.d.ts +3 -0
- package/lib/MessageVideo.d.ts.map +1 -0
- package/lib/MessageVideo.js +25 -0
- package/lib/MessageVideo.js.map +1 -0
- package/lib/MessagesContainer/components/DayAnimated/index.d.ts +5 -0
- package/lib/MessagesContainer/components/DayAnimated/index.d.ts.map +1 -0
- package/lib/MessagesContainer/components/DayAnimated/index.js +92 -0
- package/lib/MessagesContainer/components/DayAnimated/index.js.map +1 -0
- package/lib/MessagesContainer/components/DayAnimated/styles.d.ts +12 -0
- package/lib/MessagesContainer/components/DayAnimated/styles.d.ts.map +1 -0
- package/lib/MessagesContainer/components/DayAnimated/styles.js +12 -0
- package/lib/MessagesContainer/components/DayAnimated/styles.js.map +1 -0
- package/lib/MessagesContainer/components/DayAnimated/types.d.ts +18 -0
- package/lib/MessagesContainer/components/DayAnimated/types.d.ts.map +1 -0
- package/lib/MessagesContainer/components/DayAnimated/types.js +2 -0
- package/lib/MessagesContainer/components/DayAnimated/types.js.map +1 -0
- package/lib/MessagesContainer/components/Item/index.d.ts +23 -0
- package/lib/MessagesContainer/components/Item/index.d.ts.map +1 -0
- package/lib/MessagesContainer/components/Item/index.js +120 -0
- package/lib/MessagesContainer/components/Item/index.js.map +1 -0
- package/lib/MessagesContainer/components/Item/types.d.ts +19 -0
- package/lib/MessagesContainer/components/Item/types.d.ts.map +1 -0
- package/lib/MessagesContainer/components/Item/types.js +2 -0
- package/lib/MessagesContainer/components/Item/types.js.map +1 -0
- package/lib/MessagesContainer/index.d.ts +6 -0
- package/lib/MessagesContainer/index.d.ts.map +1 -0
- package/lib/MessagesContainer/index.js +258 -0
- package/lib/MessagesContainer/index.js.map +1 -0
- package/lib/MessagesContainer/styles.d.ts +55 -0
- package/lib/MessagesContainer/styles.d.ts.map +1 -0
- package/lib/MessagesContainer/styles.js +42 -0
- package/lib/MessagesContainer/styles.js.map +1 -0
- package/lib/MessagesContainer/types.d.ts +88 -0
- package/lib/MessagesContainer/types.d.ts.map +1 -0
- package/lib/MessagesContainer/types.js +10 -0
- package/lib/MessagesContainer/types.js.map +1 -0
- package/lib/Models.d.ts +58 -0
- package/lib/Models.d.ts.map +1 -0
- package/lib/Models.js +2 -0
- package/lib/Models.js.map +1 -0
- package/lib/QuickReplies.d.ts +16 -0
- package/lib/QuickReplies.d.ts.map +1 -0
- package/lib/QuickReplies.js +108 -0
- package/lib/QuickReplies.js.map +1 -0
- package/lib/Reply/index.d.ts +2 -0
- package/lib/Reply/index.d.ts.map +1 -0
- package/lib/Reply/index.js +2 -0
- package/lib/Reply/index.js.map +1 -0
- package/lib/Reply/types.d.ts +72 -0
- package/lib/Reply/types.d.ts.map +1 -0
- package/lib/Reply/types.js +2 -0
- package/lib/Reply/types.js.map +1 -0
- package/lib/ReplyPreview.d.ts +14 -0
- package/lib/ReplyPreview.d.ts.map +1 -0
- package/lib/ReplyPreview.js +95 -0
- package/lib/ReplyPreview.js.map +1 -0
- package/lib/Send.d.ts +19 -0
- package/lib/Send.d.ts.map +1 -0
- package/lib/Send.js +57 -0
- package/lib/Send.js.map +1 -0
- package/lib/SystemMessage.d.ts +14 -0
- package/lib/SystemMessage.d.ts.map +1 -0
- package/lib/SystemMessage.js +42 -0
- package/lib/SystemMessage.js.map +1 -0
- package/lib/Time.d.ts +12 -0
- package/lib/Time.d.ts.map +1 -0
- package/lib/Time.js +39 -0
- package/lib/Time.js.map +1 -0
- package/lib/TypingIndicator/index.d.ts +5 -0
- package/lib/TypingIndicator/index.d.ts.map +1 -0
- package/lib/TypingIndicator/index.js +94 -0
- package/lib/TypingIndicator/index.js.map +1 -0
- package/lib/TypingIndicator/styles.d.ts +21 -0
- package/lib/TypingIndicator/styles.d.ts.map +1 -0
- package/lib/TypingIndicator/styles.js +22 -0
- package/lib/TypingIndicator/styles.js.map +1 -0
- package/lib/TypingIndicator/types.d.ts +6 -0
- package/lib/TypingIndicator/types.d.ts.map +1 -0
- package/lib/TypingIndicator/types.js +2 -0
- package/lib/TypingIndicator/types.js.map +1 -0
- package/lib/components/MessageReply.d.ts +29 -0
- package/lib/components/MessageReply.d.ts.map +1 -0
- package/lib/components/MessageReply.js +87 -0
- package/lib/components/MessageReply.js.map +1 -0
- package/lib/components/ReplyPreview.d.ts +17 -0
- package/lib/components/ReplyPreview.d.ts.map +1 -0
- package/lib/components/ReplyPreview.js +148 -0
- package/lib/components/ReplyPreview.js.map +1 -0
- package/lib/components/TouchableOpacity.d.ts +9 -0
- package/lib/components/TouchableOpacity.d.ts.map +1 -0
- package/lib/components/TouchableOpacity.js +37 -0
- package/lib/components/TouchableOpacity.js.map +1 -0
- package/lib/hooks/useColorScheme.d.ts +8 -0
- package/lib/hooks/useColorScheme.d.ts.map +1 -0
- package/lib/hooks/useColorScheme.js +17 -0
- package/lib/hooks/useColorScheme.js.map +1 -0
- package/lib/hooks/useUpdateLayoutEffect.d.ts +9 -0
- package/lib/hooks/useUpdateLayoutEffect.d.ts.map +1 -0
- package/lib/hooks/useUpdateLayoutEffect.js +17 -0
- package/lib/hooks/useUpdateLayoutEffect.js.map +1 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +31 -0
- package/lib/index.js.map +1 -0
- package/lib/linkParser.d.ts +39 -0
- package/lib/linkParser.d.ts.map +1 -0
- package/lib/linkParser.js +154 -0
- package/lib/linkParser.js.map +1 -0
- package/lib/logging.d.ts +3 -0
- package/lib/logging.d.ts.map +1 -0
- package/lib/logging.js +5 -0
- package/lib/logging.js.map +1 -0
- package/lib/styles.d.ts +14 -0
- package/lib/styles.d.ts.map +1 -0
- package/lib/styles.js +23 -0
- package/lib/styles.js.map +1 -0
- package/lib/types.d.ts +19 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts +8 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +105 -0
- package/lib/utils.js.map +1 -0
- package/package.json +12 -11
- package/src/Actions.tsx +0 -110
- package/src/Avatar.tsx +0 -169
- package/src/Bubble/index.tsx +0 -407
- package/src/Bubble/styles.ts +0 -66
- package/src/Bubble/types.ts +0 -104
- package/src/Color.ts +0 -17
- package/src/Composer.tsx +0 -100
- package/src/Constant.ts +0 -8
- package/src/Day/index.tsx +0 -63
- package/src/Day/styles.ts +0 -22
- package/src/Day/types.ts +0 -15
- package/src/GiftedAvatar.tsx +0 -187
- package/src/GiftedChat/index.tsx +0 -420
- package/src/GiftedChat/styles.ts +0 -10
- package/src/GiftedChat/types.ts +0 -156
- package/src/GiftedChatContext.ts +0 -25
- package/src/InputToolbar.tsx +0 -177
- package/src/LoadEarlierMessages.tsx +0 -94
- package/src/Message/index.tsx +0 -273
- package/src/Message/styles.ts +0 -18
- package/src/Message/types.ts +0 -26
- package/src/MessageAudio.tsx +0 -29
- package/src/MessageImage.tsx +0 -251
- package/src/MessageReply.tsx +0 -160
- package/src/MessageText.tsx +0 -111
- package/src/MessageVideo.tsx +0 -29
- package/src/MessagesContainer/components/DayAnimated/index.tsx +0 -151
- package/src/MessagesContainer/components/DayAnimated/styles.ts +0 -12
- package/src/MessagesContainer/components/DayAnimated/types.ts +0 -12
- package/src/MessagesContainer/components/Item/index.tsx +0 -197
- package/src/MessagesContainer/components/Item/types.ts +0 -13
- package/src/MessagesContainer/index.tsx +0 -434
- package/src/MessagesContainer/styles.ts +0 -42
- package/src/MessagesContainer/types.ts +0 -102
- package/src/Models.ts +0 -66
- package/src/QuickReplies.tsx +0 -181
- package/src/Reply/index.ts +0 -1
- package/src/Reply/types.ts +0 -80
- package/src/ReplyPreview.tsx +0 -132
- package/src/Send.tsx +0 -115
- package/src/SystemMessage.tsx +0 -79
- package/src/Time.tsx +0 -64
- package/src/TypingIndicator/index.tsx +0 -155
- package/src/TypingIndicator/styles.ts +0 -22
- package/src/TypingIndicator/types.ts +0 -6
- package/src/__tests__/Actions.test.tsx +0 -9
- package/src/__tests__/Avatar.test.tsx +0 -17
- package/src/__tests__/Bubble.test.tsx +0 -17
- package/src/__tests__/Color.test.tsx +0 -5
- package/src/__tests__/Composer.test.tsx +0 -10
- package/src/__tests__/Constant.test.tsx +0 -5
- package/src/__tests__/Day.test.tsx +0 -20
- package/src/__tests__/DayAnimated.test.tsx +0 -46
- package/src/__tests__/GiftedAvatar.test.tsx +0 -10
- package/src/__tests__/GiftedChat.test.tsx +0 -60
- package/src/__tests__/InputToolbar.test.tsx +0 -10
- package/src/__tests__/LoadEarlier.test.tsx +0 -10
- package/src/__tests__/Message.test.tsx +0 -67
- package/src/__tests__/MessageImage.test.tsx +0 -24
- package/src/__tests__/MessageReply.test.tsx +0 -54
- package/src/__tests__/MessageText.test.tsx +0 -15
- package/src/__tests__/MessagesContainer.test.tsx +0 -38
- package/src/__tests__/ReplyPreview.test.tsx +0 -41
- package/src/__tests__/Send.test.tsx +0 -21
- package/src/__tests__/SystemMessage.test.tsx +0 -24
- package/src/__tests__/Time.test.tsx +0 -26
- package/src/__tests__/__snapshots__/Actions.test.tsx.snap +0 -40
- package/src/__tests__/__snapshots__/Avatar.test.tsx.snap +0 -17
- package/src/__tests__/__snapshots__/Bubble.test.tsx.snap +0 -121
- package/src/__tests__/__snapshots__/Color.test.tsx.snap +0 -21
- package/src/__tests__/__snapshots__/Composer.test.tsx.snap +0 -51
- package/src/__tests__/__snapshots__/Constant.test.tsx.snap +0 -13
- package/src/__tests__/__snapshots__/Day.test.tsx.snap +0 -99
- package/src/__tests__/__snapshots__/DayAnimated.test.tsx.snap +0 -5
- package/src/__tests__/__snapshots__/GiftedAvatar.test.tsx.snap +0 -24
- package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +0 -169
- package/src/__tests__/__snapshots__/InputToolbar.test.tsx.snap +0 -145
- package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +0 -33
- package/src/__tests__/__snapshots__/Message.test.tsx.snap +0 -510
- package/src/__tests__/__snapshots__/MessageImage.test.tsx.snap +0 -293
- package/src/__tests__/__snapshots__/MessageReply.test.tsx.snap +0 -181
- package/src/__tests__/__snapshots__/MessageText.test.tsx.snap +0 -29
- package/src/__tests__/__snapshots__/ReplyPreview.test.tsx.snap +0 -403
- package/src/__tests__/__snapshots__/Send.test.tsx.snap +0 -214
- package/src/__tests__/__snapshots__/SystemMessage.test.tsx.snap +0 -77
- package/src/__tests__/__snapshots__/Time.test.tsx.snap +0 -22
- package/src/__tests__/data.ts +0 -8
- package/src/__tests__/utils.test.ts +0 -31
- package/src/components/MessageReply.tsx +0 -156
- package/src/components/ReplyPreview.tsx +0 -230
- package/src/components/TouchableOpacity.tsx +0 -67
- package/src/hooks/useColorScheme.ts +0 -18
- package/src/hooks/useUpdateLayoutEffect.ts +0 -21
- package/src/index.ts +0 -29
- package/src/linkParser.tsx +0 -255
- package/src/logging.ts +0 -8
- package/src/styles.ts +0 -25
- package/src/types.ts +0 -25
- package/src/utils.ts +0 -134
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { isSameDay, isSameUser } from '../utils'
|
|
2
|
-
|
|
3
|
-
it('should test if same day', () => {
|
|
4
|
-
const now = new Date()
|
|
5
|
-
expect(
|
|
6
|
-
isSameDay(
|
|
7
|
-
{
|
|
8
|
-
_id: 1,
|
|
9
|
-
text: 'test',
|
|
10
|
-
createdAt: now,
|
|
11
|
-
user: { _id: 1 },
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
_id: 2,
|
|
15
|
-
text: 'test2',
|
|
16
|
-
createdAt: now,
|
|
17
|
-
user: { _id: 2 },
|
|
18
|
-
}
|
|
19
|
-
)
|
|
20
|
-
).toBe(true)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('should test if same user', () => {
|
|
24
|
-
const message = {
|
|
25
|
-
_id: 1,
|
|
26
|
-
text: 'test',
|
|
27
|
-
createdAt: new Date(),
|
|
28
|
-
user: { _id: 1 },
|
|
29
|
-
}
|
|
30
|
-
expect(isSameUser(message, message)).toBe(true)
|
|
31
|
-
})
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
Image,
|
|
4
|
-
ImageStyle,
|
|
5
|
-
Pressable,
|
|
6
|
-
StyleProp,
|
|
7
|
-
StyleSheet,
|
|
8
|
-
Text,
|
|
9
|
-
TextStyle,
|
|
10
|
-
View,
|
|
11
|
-
ViewStyle,
|
|
12
|
-
} from 'react-native'
|
|
13
|
-
|
|
14
|
-
import { IMessage, ReplyMessage } from '../Models'
|
|
15
|
-
import { isSameUser } from '../utils'
|
|
16
|
-
|
|
17
|
-
export interface MessageReplyProps<TMessage extends IMessage = IMessage> {
|
|
18
|
-
/** The reply message to display */
|
|
19
|
-
replyMessage: ReplyMessage
|
|
20
|
-
/** The current message containing the reply */
|
|
21
|
-
currentMessage: TMessage
|
|
22
|
-
/** Position of the bubble (left or right) */
|
|
23
|
-
position: 'left' | 'right'
|
|
24
|
-
/** Container style for the reply */
|
|
25
|
-
containerStyle?: StyleProp<ViewStyle>
|
|
26
|
-
/** Container style for left position */
|
|
27
|
-
containerStyleLeft?: StyleProp<ViewStyle>
|
|
28
|
-
/** Container style for right position */
|
|
29
|
-
containerStyleRight?: StyleProp<ViewStyle>
|
|
30
|
-
/** Text style for the reply */
|
|
31
|
-
textStyle?: StyleProp<TextStyle>
|
|
32
|
-
/** Text style for left position */
|
|
33
|
-
textStyleLeft?: StyleProp<TextStyle>
|
|
34
|
-
/** Text style for right position */
|
|
35
|
-
textStyleRight?: StyleProp<TextStyle>
|
|
36
|
-
/** Image style for the reply */
|
|
37
|
-
imageStyle?: StyleProp<ImageStyle>
|
|
38
|
-
/** Callback when reply is pressed */
|
|
39
|
-
onPress?: (replyMessage: ReplyMessage) => void
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const styles = StyleSheet.create({
|
|
43
|
-
container: {
|
|
44
|
-
borderRadius: 8,
|
|
45
|
-
marginBottom: 4,
|
|
46
|
-
paddingHorizontal: 10,
|
|
47
|
-
paddingVertical: 6,
|
|
48
|
-
},
|
|
49
|
-
containerLeft: {
|
|
50
|
-
backgroundColor: 'rgba(0, 0, 0, 0.06)',
|
|
51
|
-
borderLeftColor: '#0084ff',
|
|
52
|
-
borderLeftWidth: 3,
|
|
53
|
-
},
|
|
54
|
-
containerRight: {
|
|
55
|
-
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
|
56
|
-
borderLeftColor: 'rgba(255, 255, 255, 0.6)',
|
|
57
|
-
borderLeftWidth: 3,
|
|
58
|
-
},
|
|
59
|
-
image: {
|
|
60
|
-
borderRadius: 4,
|
|
61
|
-
height: 40,
|
|
62
|
-
marginTop: 4,
|
|
63
|
-
width: 40,
|
|
64
|
-
},
|
|
65
|
-
text: {
|
|
66
|
-
fontSize: 13,
|
|
67
|
-
},
|
|
68
|
-
textLeft: {
|
|
69
|
-
color: '#333',
|
|
70
|
-
},
|
|
71
|
-
textRight: {
|
|
72
|
-
color: 'rgba(255, 255, 255, 0.9)',
|
|
73
|
-
},
|
|
74
|
-
username: {
|
|
75
|
-
fontWeight: '600',
|
|
76
|
-
marginBottom: 2,
|
|
77
|
-
},
|
|
78
|
-
usernameLeft: {
|
|
79
|
-
color: '#0084ff',
|
|
80
|
-
},
|
|
81
|
-
usernameRight: {
|
|
82
|
-
color: 'rgba(255, 255, 255, 0.9)',
|
|
83
|
-
},
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
export function MessageReply<TMessage extends IMessage = IMessage> ({
|
|
87
|
-
replyMessage,
|
|
88
|
-
currentMessage,
|
|
89
|
-
position,
|
|
90
|
-
containerStyle,
|
|
91
|
-
containerStyleLeft,
|
|
92
|
-
containerStyleRight,
|
|
93
|
-
textStyle,
|
|
94
|
-
textStyleLeft,
|
|
95
|
-
textStyleRight,
|
|
96
|
-
imageStyle,
|
|
97
|
-
onPress,
|
|
98
|
-
}: MessageReplyProps<TMessage>) {
|
|
99
|
-
const isCurrentUser = useMemo(
|
|
100
|
-
() => isSameUser(currentMessage, { user: replyMessage.user } as TMessage),
|
|
101
|
-
[currentMessage, replyMessage.user]
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
const displayName = useMemo(() => {
|
|
105
|
-
if (isCurrentUser)
|
|
106
|
-
return 'You'
|
|
107
|
-
|
|
108
|
-
return replyMessage.user?.name || 'Unknown'
|
|
109
|
-
}, [isCurrentUser, replyMessage.user?.name])
|
|
110
|
-
|
|
111
|
-
const handlePress = () => {
|
|
112
|
-
onPress?.(replyMessage)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const containerStyles = [
|
|
116
|
-
styles.container,
|
|
117
|
-
position === 'left' ? styles.containerLeft : styles.containerRight,
|
|
118
|
-
containerStyle,
|
|
119
|
-
position === 'left' ? containerStyleLeft : containerStyleRight,
|
|
120
|
-
]
|
|
121
|
-
|
|
122
|
-
const usernameStyles = [
|
|
123
|
-
styles.username,
|
|
124
|
-
position === 'left' ? styles.usernameLeft : styles.usernameRight,
|
|
125
|
-
textStyle,
|
|
126
|
-
position === 'left' ? textStyleLeft : textStyleRight,
|
|
127
|
-
]
|
|
128
|
-
|
|
129
|
-
const textStyles = [
|
|
130
|
-
styles.text,
|
|
131
|
-
position === 'left' ? styles.textLeft : styles.textRight,
|
|
132
|
-
textStyle,
|
|
133
|
-
position === 'left' ? textStyleLeft : textStyleRight,
|
|
134
|
-
]
|
|
135
|
-
|
|
136
|
-
return (
|
|
137
|
-
<Pressable onPress={handlePress}>
|
|
138
|
-
<View style={containerStyles}>
|
|
139
|
-
<Text style={usernameStyles} numberOfLines={1}>
|
|
140
|
-
{displayName}
|
|
141
|
-
</Text>
|
|
142
|
-
{replyMessage.text && (
|
|
143
|
-
<Text style={textStyles} numberOfLines={2}>
|
|
144
|
-
{replyMessage.text}
|
|
145
|
-
</Text>
|
|
146
|
-
)}
|
|
147
|
-
{replyMessage.image && (
|
|
148
|
-
<Image
|
|
149
|
-
source={{ uri: replyMessage.image }}
|
|
150
|
-
style={[styles.image, imageStyle]}
|
|
151
|
-
/>
|
|
152
|
-
)}
|
|
153
|
-
</View>
|
|
154
|
-
</Pressable>
|
|
155
|
-
)
|
|
156
|
-
}
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
Image,
|
|
4
|
-
ImageStyle,
|
|
5
|
-
Pressable,
|
|
6
|
-
StyleProp,
|
|
7
|
-
StyleSheet,
|
|
8
|
-
Text,
|
|
9
|
-
TextStyle,
|
|
10
|
-
View,
|
|
11
|
-
ViewStyle,
|
|
12
|
-
} from 'react-native'
|
|
13
|
-
import Animated, {
|
|
14
|
-
useAnimatedStyle,
|
|
15
|
-
useSharedValue,
|
|
16
|
-
withTiming,
|
|
17
|
-
Easing,
|
|
18
|
-
interpolate,
|
|
19
|
-
runOnJS,
|
|
20
|
-
} from 'react-native-reanimated'
|
|
21
|
-
|
|
22
|
-
import { useColorScheme } from '../hooks/useColorScheme'
|
|
23
|
-
import { ReplyMessage } from '../Models'
|
|
24
|
-
|
|
25
|
-
const ANIMATION_DURATION = 200
|
|
26
|
-
const ANIMATION_EASING = Easing.bezier(0.25, 0.1, 0.25, 1)
|
|
27
|
-
const DEFAULT_HEIGHT = 68
|
|
28
|
-
|
|
29
|
-
export interface ReplyPreviewProps {
|
|
30
|
-
/** The reply message to preview */
|
|
31
|
-
replyMessage: ReplyMessage
|
|
32
|
-
/** Callback to clear the reply */
|
|
33
|
-
onClearReply?: () => void
|
|
34
|
-
/** Container style */
|
|
35
|
-
containerStyle?: StyleProp<ViewStyle>
|
|
36
|
-
/** Text style */
|
|
37
|
-
textStyle?: StyleProp<TextStyle>
|
|
38
|
-
/** Image style */
|
|
39
|
-
imageStyle?: StyleProp<ImageStyle>
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const styles = StyleSheet.create({
|
|
43
|
-
borderIndicator: {
|
|
44
|
-
backgroundColor: '#0084ff',
|
|
45
|
-
borderTopLeftRadius: 4,
|
|
46
|
-
height: '100%',
|
|
47
|
-
width: 4,
|
|
48
|
-
},
|
|
49
|
-
clearButton: {
|
|
50
|
-
alignItems: 'center',
|
|
51
|
-
borderRadius: 12,
|
|
52
|
-
height: 24,
|
|
53
|
-
justifyContent: 'center',
|
|
54
|
-
width: 24,
|
|
55
|
-
},
|
|
56
|
-
clearButtonText: {
|
|
57
|
-
fontSize: 18,
|
|
58
|
-
fontWeight: '600',
|
|
59
|
-
},
|
|
60
|
-
container: {
|
|
61
|
-
borderRadius: 8,
|
|
62
|
-
flexDirection: 'row',
|
|
63
|
-
marginBottom: 8,
|
|
64
|
-
marginHorizontal: 10,
|
|
65
|
-
overflow: 'hidden',
|
|
66
|
-
},
|
|
67
|
-
containerDark: {
|
|
68
|
-
backgroundColor: '#2c2c2e',
|
|
69
|
-
},
|
|
70
|
-
containerLight: {
|
|
71
|
-
backgroundColor: '#e9e9eb',
|
|
72
|
-
},
|
|
73
|
-
content: {
|
|
74
|
-
flex: 1,
|
|
75
|
-
paddingHorizontal: 10,
|
|
76
|
-
paddingVertical: 8,
|
|
77
|
-
},
|
|
78
|
-
image: {
|
|
79
|
-
borderRadius: 4,
|
|
80
|
-
height: 40,
|
|
81
|
-
marginRight: 8,
|
|
82
|
-
width: 40,
|
|
83
|
-
},
|
|
84
|
-
row: {
|
|
85
|
-
alignItems: 'center',
|
|
86
|
-
flexDirection: 'row',
|
|
87
|
-
},
|
|
88
|
-
text: {
|
|
89
|
-
fontSize: 14,
|
|
90
|
-
},
|
|
91
|
-
textDark: {
|
|
92
|
-
color: '#fff',
|
|
93
|
-
},
|
|
94
|
-
textLight: {
|
|
95
|
-
color: '#333',
|
|
96
|
-
},
|
|
97
|
-
username: {
|
|
98
|
-
color: '#0084ff',
|
|
99
|
-
fontSize: 13,
|
|
100
|
-
fontWeight: '600',
|
|
101
|
-
marginBottom: 2,
|
|
102
|
-
},
|
|
103
|
-
wrapper: {
|
|
104
|
-
overflow: 'hidden',
|
|
105
|
-
},
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
export function ReplyPreview ({
|
|
109
|
-
replyMessage,
|
|
110
|
-
onClearReply,
|
|
111
|
-
containerStyle,
|
|
112
|
-
textStyle,
|
|
113
|
-
imageStyle,
|
|
114
|
-
}: ReplyPreviewProps) {
|
|
115
|
-
const colorScheme = useColorScheme()
|
|
116
|
-
const isDark = colorScheme === 'dark'
|
|
117
|
-
|
|
118
|
-
const animationProgress = useSharedValue(0)
|
|
119
|
-
const contentHeight = useSharedValue(DEFAULT_HEIGHT)
|
|
120
|
-
|
|
121
|
-
// Animate in on mount
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
animationProgress.value = withTiming(1, {
|
|
124
|
-
duration: ANIMATION_DURATION,
|
|
125
|
-
easing: ANIMATION_EASING,
|
|
126
|
-
})
|
|
127
|
-
}, [animationProgress])
|
|
128
|
-
|
|
129
|
-
const handleClear = () => {
|
|
130
|
-
'worklet'
|
|
131
|
-
animationProgress.value = withTiming(0, {
|
|
132
|
-
duration: ANIMATION_DURATION,
|
|
133
|
-
easing: ANIMATION_EASING,
|
|
134
|
-
}, finished => {
|
|
135
|
-
if (finished && onClearReply)
|
|
136
|
-
runOnJS(onClearReply)()
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const wrapperAnimatedStyle = useAnimatedStyle(() => {
|
|
141
|
-
const height = interpolate(
|
|
142
|
-
animationProgress.value,
|
|
143
|
-
[0, 1],
|
|
144
|
-
[0, contentHeight.value]
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
const opacity = interpolate(
|
|
148
|
-
animationProgress.value,
|
|
149
|
-
[0, 0.5, 1],
|
|
150
|
-
[0, 0.5, 1]
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
const translateY = interpolate(
|
|
154
|
-
animationProgress.value,
|
|
155
|
-
[0, 1],
|
|
156
|
-
[10, 0]
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
return {
|
|
160
|
-
height,
|
|
161
|
-
opacity,
|
|
162
|
-
transform: [{ translateY }],
|
|
163
|
-
}
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
const displayName = replyMessage.user?.name || 'Unknown'
|
|
167
|
-
|
|
168
|
-
return (
|
|
169
|
-
<Animated.View style={[styles.wrapper, wrapperAnimatedStyle]}>
|
|
170
|
-
<View
|
|
171
|
-
style={[
|
|
172
|
-
styles.container,
|
|
173
|
-
isDark ? styles.containerDark : styles.containerLight,
|
|
174
|
-
containerStyle,
|
|
175
|
-
]}
|
|
176
|
-
onLayout={e => {
|
|
177
|
-
const newHeight = e.nativeEvent.layout.height + 8
|
|
178
|
-
// Animate height change smoothly when content changes
|
|
179
|
-
contentHeight.value = withTiming(newHeight, {
|
|
180
|
-
duration: ANIMATION_DURATION,
|
|
181
|
-
easing: ANIMATION_EASING,
|
|
182
|
-
})
|
|
183
|
-
}}
|
|
184
|
-
>
|
|
185
|
-
<View style={styles.borderIndicator} />
|
|
186
|
-
<View style={styles.content}>
|
|
187
|
-
<View style={styles.row}>
|
|
188
|
-
{replyMessage.image && (
|
|
189
|
-
<Image
|
|
190
|
-
source={{ uri: replyMessage.image }}
|
|
191
|
-
style={[styles.image, imageStyle]}
|
|
192
|
-
/>
|
|
193
|
-
)}
|
|
194
|
-
<View style={{ flex: 1 }}>
|
|
195
|
-
<Text style={styles.username} numberOfLines={1}>
|
|
196
|
-
Replying to {displayName}
|
|
197
|
-
</Text>
|
|
198
|
-
{replyMessage.text && (
|
|
199
|
-
<Text
|
|
200
|
-
style={[
|
|
201
|
-
styles.text,
|
|
202
|
-
isDark ? styles.textDark : styles.textLight,
|
|
203
|
-
textStyle,
|
|
204
|
-
]}
|
|
205
|
-
numberOfLines={2}
|
|
206
|
-
>
|
|
207
|
-
{replyMessage.text}
|
|
208
|
-
</Text>
|
|
209
|
-
)}
|
|
210
|
-
</View>
|
|
211
|
-
</View>
|
|
212
|
-
</View>
|
|
213
|
-
<Pressable
|
|
214
|
-
style={styles.clearButton}
|
|
215
|
-
onPress={handleClear}
|
|
216
|
-
hitSlop={8}
|
|
217
|
-
>
|
|
218
|
-
<Text
|
|
219
|
-
style={[
|
|
220
|
-
styles.clearButtonText,
|
|
221
|
-
isDark ? styles.textDark : styles.textLight,
|
|
222
|
-
]}
|
|
223
|
-
>
|
|
224
|
-
×
|
|
225
|
-
</Text>
|
|
226
|
-
</Pressable>
|
|
227
|
-
</View>
|
|
228
|
-
</Animated.View>
|
|
229
|
-
)
|
|
230
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react'
|
|
2
|
-
import { BaseButton } from 'react-native-gesture-handler'
|
|
3
|
-
import Animated, {
|
|
4
|
-
useAnimatedStyle,
|
|
5
|
-
useSharedValue,
|
|
6
|
-
withTiming,
|
|
7
|
-
} from 'react-native-reanimated'
|
|
8
|
-
|
|
9
|
-
export type TouchableOpacityProps = Omit<React.ComponentProps<typeof BaseButton>, 'onPress'> & {
|
|
10
|
-
activeOpacity?: number
|
|
11
|
-
onPress?: () => void
|
|
12
|
-
} & React.ComponentProps<typeof Animated.View>
|
|
13
|
-
|
|
14
|
-
export const TouchableOpacity: React.FC<TouchableOpacityProps> = ({
|
|
15
|
-
children,
|
|
16
|
-
style,
|
|
17
|
-
activeOpacity = 0.2,
|
|
18
|
-
onPress,
|
|
19
|
-
...rest
|
|
20
|
-
}) => {
|
|
21
|
-
const opacity = useSharedValue(1)
|
|
22
|
-
const isAnimationInFinished = useSharedValue(false)
|
|
23
|
-
|
|
24
|
-
const handlePressIn = useCallback(() => {
|
|
25
|
-
opacity.value = withTiming(activeOpacity, { duration: 150 }, () => {
|
|
26
|
-
isAnimationInFinished.value = true
|
|
27
|
-
})
|
|
28
|
-
}, [activeOpacity, opacity, isAnimationInFinished])
|
|
29
|
-
|
|
30
|
-
const handlePressOut = useCallback(() => {
|
|
31
|
-
setTimeout(() => {
|
|
32
|
-
'worklet'
|
|
33
|
-
|
|
34
|
-
opacity.value = withTiming(1, { duration: 150 })
|
|
35
|
-
isAnimationInFinished.value = false
|
|
36
|
-
}, isAnimationInFinished.value ? 0 : 150)
|
|
37
|
-
}, [opacity, isAnimationInFinished])
|
|
38
|
-
|
|
39
|
-
const handleActiveStateChange = useCallback((isActive: boolean) => {
|
|
40
|
-
if (isActive)
|
|
41
|
-
handlePressIn()
|
|
42
|
-
else
|
|
43
|
-
handlePressOut()
|
|
44
|
-
}, [handlePressIn, handlePressOut])
|
|
45
|
-
|
|
46
|
-
const animatedStyle = useAnimatedStyle(() => ({
|
|
47
|
-
opacity: opacity.value,
|
|
48
|
-
}))
|
|
49
|
-
|
|
50
|
-
const handlePress = useCallback(() => {
|
|
51
|
-
onPress?.()
|
|
52
|
-
}, [onPress])
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<BaseButton
|
|
56
|
-
{...rest}
|
|
57
|
-
onPress={handlePress}
|
|
58
|
-
onActiveStateChange={handleActiveStateChange}
|
|
59
|
-
>
|
|
60
|
-
<Animated.View
|
|
61
|
-
style={[style, animatedStyle]}
|
|
62
|
-
>
|
|
63
|
-
{children}
|
|
64
|
-
</Animated.View>
|
|
65
|
-
</BaseButton>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useColorScheme as useRNColorScheme } from 'react-native'
|
|
2
|
-
import { useChatContext } from '../GiftedChatContext'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Custom hook that returns the color scheme from GiftedChat context if provided,
|
|
6
|
-
* otherwise falls back to the system color scheme from React Native.
|
|
7
|
-
*
|
|
8
|
-
* @returns The current color scheme ('light', 'dark', null, or undefined)
|
|
9
|
-
*/
|
|
10
|
-
export function useColorScheme() {
|
|
11
|
-
const { getColorScheme } = useChatContext()
|
|
12
|
-
const contextColorScheme = getColorScheme()
|
|
13
|
-
const systemColorScheme = useRNColorScheme()
|
|
14
|
-
|
|
15
|
-
return contextColorScheme !== undefined && contextColorScheme !== null
|
|
16
|
-
? contextColorScheme
|
|
17
|
-
: systemColorScheme
|
|
18
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DependencyList, useLayoutEffect, useRef } from 'react'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A custom useEffect hook that only triggers on updates, not on initial mount
|
|
5
|
-
* Idea stolen from: https://stackoverflow.com/a/55075818/1526448
|
|
6
|
-
* @param {()=>void} effect the function to call
|
|
7
|
-
* @param {DependencyList} dependencies the state(s) that fires the update
|
|
8
|
-
*/
|
|
9
|
-
export function useUpdateLayoutEffect (
|
|
10
|
-
effect: () => void,
|
|
11
|
-
dependencies: DependencyList = []
|
|
12
|
-
) {
|
|
13
|
-
const isInitialMount = useRef(true)
|
|
14
|
-
|
|
15
|
-
useLayoutEffect(() => {
|
|
16
|
-
if (isInitialMount.current)
|
|
17
|
-
isInitialMount.current = false
|
|
18
|
-
else
|
|
19
|
-
effect()
|
|
20
|
-
}, dependencies)
|
|
21
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as utils from './utils'
|
|
2
|
-
|
|
3
|
-
export * from './GiftedChat'
|
|
4
|
-
export * from './Constant'
|
|
5
|
-
export { utils }
|
|
6
|
-
export * from './GiftedChatContext'
|
|
7
|
-
export * from './types'
|
|
8
|
-
export * from './linkParser'
|
|
9
|
-
export * from './Reply'
|
|
10
|
-
export { Actions } from './Actions'
|
|
11
|
-
export { Avatar } from './Avatar'
|
|
12
|
-
export { Bubble } from './Bubble'
|
|
13
|
-
export { SystemMessage } from './SystemMessage'
|
|
14
|
-
export { MessageImage } from './MessageImage'
|
|
15
|
-
export { MessageText } from './MessageText'
|
|
16
|
-
export { Composer } from './Composer'
|
|
17
|
-
export { Day } from './Day'
|
|
18
|
-
export { InputToolbar } from './InputToolbar'
|
|
19
|
-
export { LoadEarlierMessages } from './LoadEarlierMessages'
|
|
20
|
-
export { Message } from './Message'
|
|
21
|
-
export { MessagesContainer } from './MessagesContainer'
|
|
22
|
-
export { Send } from './Send'
|
|
23
|
-
export { Time } from './Time'
|
|
24
|
-
export { GiftedAvatar } from './GiftedAvatar'
|
|
25
|
-
export { MessageAudio } from './MessageAudio'
|
|
26
|
-
export { MessageVideo } from './MessageVideo'
|
|
27
|
-
export { MessageReply } from './components/MessageReply'
|
|
28
|
-
export { ReplyPreview } from './components/ReplyPreview'
|
|
29
|
-
export { useColorScheme } from './hooks/useColorScheme'
|