react-native-gifted-chat 3.0.1 → 3.1.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 +1 -1
- package/package.json +1 -1
- package/src/Actions.tsx +2 -2
- package/src/Bubble/index.tsx +37 -42
- package/src/Bubble/styles.ts +54 -68
- package/src/Bubble/types.ts +3 -2
- package/src/Composer.tsx +1 -1
- package/src/Day/index.tsx +2 -2
- package/src/GiftedAvatar.tsx +2 -2
- package/src/GiftedChat/index.tsx +1 -2
- package/src/LoadEarlierMessages.tsx +2 -2
- package/src/Message/index.tsx +4 -3
- package/src/Message/styles.ts +16 -20
- package/src/MessageAudio.tsx +3 -2
- package/src/MessageImage.tsx +1 -1
- package/src/MessageText.tsx +3 -5
- package/src/MessageVideo.tsx +3 -2
- package/src/MessagesContainer/index.tsx +1 -2
- package/src/QuickReplies.tsx +1 -1
- package/src/Send.tsx +2 -2
- package/src/SystemMessage.tsx +23 -18
- package/src/Time.tsx +13 -39
- package/src/__tests__/GiftedChat.test.tsx +1 -1
- package/src/__tests__/__snapshots__/Bubble.test.tsx.snap +46 -65
- package/src/__tests__/__snapshots__/Composer.test.tsx.snap +5 -0
- package/src/__tests__/__snapshots__/InputToolbar.test.tsx.snap +5 -0
- package/src/__tests__/__snapshots__/Message.test.tsx.snap +143 -200
- package/src/__tests__/__snapshots__/MessageImage.test.tsx.snap +2 -29
- package/src/__tests__/__snapshots__/MessageText.test.tsx.snap +2 -4
- package/src/__tests__/__snapshots__/SystemMessage.test.tsx.snap +39 -42
- package/src/__tests__/__snapshots__/Time.test.tsx.snap +1 -12
- package/src/styles.ts +11 -2
package/README.md
CHANGED
package/package.json
CHANGED
package/src/Actions.tsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import React, { ReactNode, useCallback } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
StyleSheet,
|
|
4
|
-
Text,
|
|
5
4
|
View,
|
|
6
5
|
StyleProp,
|
|
7
6
|
ViewStyle,
|
|
8
7
|
TextStyle,
|
|
9
8
|
} from 'react-native'
|
|
9
|
+
import { Text } from 'react-native-gesture-handler'
|
|
10
10
|
import { Color } from './Color'
|
|
11
11
|
import { TouchableOpacity } from './components/TouchableOpacity'
|
|
12
|
-
import { useChatContext } from './GiftedChatContext'
|
|
13
12
|
|
|
13
|
+
import { useChatContext } from './GiftedChatContext'
|
|
14
14
|
import stylesCommon from './styles'
|
|
15
15
|
|
|
16
16
|
export interface ActionsProps {
|
package/src/Bubble/index.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useCallback, useMemo } from 'react'
|
|
2
2
|
import {
|
|
3
|
-
Text,
|
|
4
|
-
Pressable,
|
|
5
3
|
View,
|
|
4
|
+
Pressable, // don't use Pressable from gesture handler to issues with react-native-autolink (onPress doesn't work)
|
|
6
5
|
} from 'react-native'
|
|
7
6
|
|
|
7
|
+
import { Text } from 'react-native-gesture-handler'
|
|
8
8
|
import { useChatContext } from '../GiftedChatContext'
|
|
9
9
|
import { MessageAudio } from '../MessageAudio'
|
|
10
10
|
import { MessageImage } from '../MessageImage'
|
|
@@ -12,17 +12,17 @@ import { MessageText } from '../MessageText'
|
|
|
12
12
|
import { MessageVideo } from '../MessageVideo'
|
|
13
13
|
import { IMessage } from '../Models'
|
|
14
14
|
import { QuickReplies } from '../QuickReplies'
|
|
15
|
-
import stylesCommon from '../styles'
|
|
16
15
|
|
|
16
|
+
import stylesCommon, { getStyleWithPosition } from '../styles'
|
|
17
17
|
import { Time } from '../Time'
|
|
18
|
-
import { isSameUser, isSameDay, renderComponentOrElement } from '../utils'
|
|
19
18
|
|
|
19
|
+
import { isSameUser, isSameDay, renderComponentOrElement } from '../utils'
|
|
20
20
|
import styles from './styles'
|
|
21
21
|
import { BubbleProps, RenderMessageTextProps } from './types'
|
|
22
22
|
|
|
23
23
|
export * from './types'
|
|
24
24
|
|
|
25
|
-
export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessage>):
|
|
25
|
+
export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessage>): React.ReactElement => {
|
|
26
26
|
const {
|
|
27
27
|
currentMessage,
|
|
28
28
|
nextMessage,
|
|
@@ -56,7 +56,7 @@ export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<
|
|
|
56
56
|
onLongPressMessageProp,
|
|
57
57
|
])
|
|
58
58
|
|
|
59
|
-
const styledBubbleToNext =
|
|
59
|
+
const styledBubbleToNext = useMemo(() => {
|
|
60
60
|
if (
|
|
61
61
|
currentMessage &&
|
|
62
62
|
nextMessage &&
|
|
@@ -65,7 +65,7 @@ export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<
|
|
|
65
65
|
isSameDay(currentMessage, nextMessage)
|
|
66
66
|
)
|
|
67
67
|
return [
|
|
68
|
-
styles
|
|
68
|
+
getStyleWithPosition(styles, 'containerToNext', position),
|
|
69
69
|
containerToNextStyle?.[position],
|
|
70
70
|
]
|
|
71
71
|
|
|
@@ -77,7 +77,7 @@ export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<
|
|
|
77
77
|
containerToNextStyle,
|
|
78
78
|
])
|
|
79
79
|
|
|
80
|
-
const styledBubbleToPrevious =
|
|
80
|
+
const styledBubbleToPrevious = useMemo(() => {
|
|
81
81
|
if (
|
|
82
82
|
currentMessage &&
|
|
83
83
|
previousMessage &&
|
|
@@ -86,7 +86,7 @@ export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<
|
|
|
86
86
|
isSameDay(currentMessage, previousMessage)
|
|
87
87
|
)
|
|
88
88
|
return [
|
|
89
|
-
styles
|
|
89
|
+
getStyleWithPosition(styles, 'containerToPrevious', position),
|
|
90
90
|
containerToPreviousStyle?.[position],
|
|
91
91
|
]
|
|
92
92
|
|
|
@@ -147,7 +147,10 @@ export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<
|
|
|
147
147
|
...messageTextPropsRest
|
|
148
148
|
} = props
|
|
149
149
|
|
|
150
|
-
const combinedProps = {
|
|
150
|
+
const combinedProps = {
|
|
151
|
+
...messageTextPropsRest,
|
|
152
|
+
...messageTextProps,
|
|
153
|
+
} as RenderMessageTextProps<TMessage>
|
|
151
154
|
|
|
152
155
|
if (props.renderMessageText)
|
|
153
156
|
return renderComponentOrElement(props.renderMessageText, combinedProps)
|
|
@@ -234,19 +237,19 @@ export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<
|
|
|
234
237
|
(currentMessage.sent || currentMessage.received || currentMessage.pending)
|
|
235
238
|
)
|
|
236
239
|
return (
|
|
237
|
-
<View style={styles.
|
|
240
|
+
<View style={styles.tickView}>
|
|
238
241
|
{!!currentMessage.sent && (
|
|
239
|
-
<Text style={[styles.
|
|
242
|
+
<Text style={[styles.tick, props.tickStyle]}>
|
|
240
243
|
{'✓'}
|
|
241
244
|
</Text>
|
|
242
245
|
)}
|
|
243
246
|
{!!currentMessage.received && (
|
|
244
|
-
<Text style={[styles.
|
|
247
|
+
<Text style={[styles.tick, props.tickStyle]}>
|
|
245
248
|
{'✓'}
|
|
246
249
|
</Text>
|
|
247
250
|
)}
|
|
248
251
|
{!!currentMessage.pending && (
|
|
249
|
-
<Text style={[styles.
|
|
252
|
+
<Text style={[styles.tick, props.tickStyle]}>
|
|
250
253
|
{'🕓'}
|
|
251
254
|
</Text>
|
|
252
255
|
)}
|
|
@@ -275,6 +278,7 @@ export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<
|
|
|
275
278
|
|
|
276
279
|
return <Time {...timeProps} />
|
|
277
280
|
}
|
|
281
|
+
|
|
278
282
|
return null
|
|
279
283
|
}, [props, currentMessage])
|
|
280
284
|
|
|
@@ -292,13 +296,10 @@ export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<
|
|
|
292
296
|
return renderComponentOrElement(renderUsername, currentMessage.user)
|
|
293
297
|
|
|
294
298
|
return (
|
|
295
|
-
<View style={styles.
|
|
299
|
+
<View style={styles.usernameContainer}>
|
|
296
300
|
<Text
|
|
297
|
-
style={
|
|
298
|
-
[styles.content.username, props.usernameStyle]
|
|
299
|
-
}
|
|
301
|
+
style={[styles.username, props.usernameStyle]}
|
|
300
302
|
>
|
|
301
|
-
{'~ '}
|
|
302
303
|
{currentMessage.user.name}
|
|
303
304
|
</Text>
|
|
304
305
|
</View>
|
|
@@ -320,14 +321,14 @@ export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<
|
|
|
320
321
|
|
|
321
322
|
const renderBubbleContent = useCallback(() => {
|
|
322
323
|
return (
|
|
323
|
-
|
|
324
|
+
<>
|
|
324
325
|
{!props.isCustomViewBottom && renderCustomView()}
|
|
325
326
|
{renderMessageImage()}
|
|
326
327
|
{renderMessageVideo()}
|
|
327
328
|
{renderMessageAudio()}
|
|
328
329
|
{renderMessageText()}
|
|
329
330
|
{props.isCustomViewBottom && renderCustomView()}
|
|
330
|
-
|
|
331
|
+
</>
|
|
331
332
|
)
|
|
332
333
|
}, [
|
|
333
334
|
renderCustomView,
|
|
@@ -339,19 +340,13 @@ export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<
|
|
|
339
340
|
])
|
|
340
341
|
|
|
341
342
|
return (
|
|
342
|
-
<View
|
|
343
|
-
style={[
|
|
344
|
-
stylesCommon.fill,
|
|
345
|
-
styles[position].container,
|
|
346
|
-
containerStyle && containerStyle[position],
|
|
347
|
-
]}
|
|
348
|
-
>
|
|
343
|
+
<View style={containerStyle?.[position]}>
|
|
349
344
|
<View
|
|
350
345
|
style={[
|
|
351
|
-
styles
|
|
352
|
-
styledBubbleToNext
|
|
353
|
-
styledBubbleToPrevious
|
|
354
|
-
wrapperStyle
|
|
346
|
+
getStyleWithPosition(styles, 'wrapper', position),
|
|
347
|
+
styledBubbleToNext,
|
|
348
|
+
styledBubbleToPrevious,
|
|
349
|
+
wrapperStyle?.[position],
|
|
355
350
|
]}
|
|
356
351
|
>
|
|
357
352
|
<Pressable
|
|
@@ -359,15 +354,15 @@ export const Bubble = <TMessage extends IMessage = IMessage>(props: BubbleProps<
|
|
|
359
354
|
onLongPress={onLongPress}
|
|
360
355
|
{...props.touchableProps}
|
|
361
356
|
>
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
357
|
+
{renderBubbleContent()}
|
|
358
|
+
<View
|
|
359
|
+
style={[
|
|
360
|
+
styles.bottom,
|
|
361
|
+
bottomContainerStyle?.[position],
|
|
362
|
+
]}
|
|
363
|
+
>
|
|
364
|
+
{renderUsername()}
|
|
365
|
+
<View style={stylesCommon.fill}>
|
|
371
366
|
{renderTime()}
|
|
372
367
|
{renderTicks()}
|
|
373
368
|
</View>
|
package/src/Bubble/styles.ts
CHANGED
|
@@ -1,73 +1,59 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native'
|
|
2
2
|
import { Color } from '../Color'
|
|
3
3
|
|
|
4
|
-
const styles = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
username: {
|
|
60
|
-
top: -3,
|
|
61
|
-
left: 0,
|
|
62
|
-
fontSize: 12,
|
|
63
|
-
backgroundColor: Color.backgroundTransparent,
|
|
64
|
-
color: '#aaa',
|
|
65
|
-
},
|
|
66
|
-
usernameView: {
|
|
67
|
-
flexDirection: 'row',
|
|
68
|
-
marginHorizontal: 10,
|
|
69
|
-
},
|
|
70
|
-
}),
|
|
71
|
-
}
|
|
4
|
+
const styles = StyleSheet.create({
|
|
5
|
+
wrapper: {
|
|
6
|
+
borderRadius: 15,
|
|
7
|
+
minHeight: 20,
|
|
8
|
+
},
|
|
9
|
+
wrapper_left: {
|
|
10
|
+
backgroundColor: Color.leftBubbleBackground,
|
|
11
|
+
justifyContent: 'flex-end',
|
|
12
|
+
},
|
|
13
|
+
wrapper_right: {
|
|
14
|
+
backgroundColor: Color.defaultBlue,
|
|
15
|
+
justifyContent: 'flex-end',
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
bottom: {
|
|
19
|
+
flexDirection: 'row',
|
|
20
|
+
justifyContent: 'space-between',
|
|
21
|
+
alignItems: 'flex-end',
|
|
22
|
+
paddingHorizontal: 10,
|
|
23
|
+
paddingBottom: 5,
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
containerToNext_left: {
|
|
27
|
+
borderBottomLeftRadius: 3,
|
|
28
|
+
},
|
|
29
|
+
containerToNext_right: {
|
|
30
|
+
borderBottomRightRadius: 3,
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
containerToPrevious_left: {
|
|
34
|
+
borderTopLeftRadius: 3,
|
|
35
|
+
},
|
|
36
|
+
containerToPrevious_right: {
|
|
37
|
+
borderTopRightRadius: 3,
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
tick: {
|
|
41
|
+
fontSize: 10,
|
|
42
|
+
color: Color.white,
|
|
43
|
+
},
|
|
44
|
+
tickView: {
|
|
45
|
+
flexDirection: 'row',
|
|
46
|
+
marginLeft: 5,
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
usernameContainer: {
|
|
50
|
+
flexDirection: 'row',
|
|
51
|
+
marginRight: 5,
|
|
52
|
+
},
|
|
53
|
+
username: {
|
|
54
|
+
fontSize: 12,
|
|
55
|
+
color: '#aaa',
|
|
56
|
+
},
|
|
57
|
+
})
|
|
72
58
|
|
|
73
59
|
export default styles
|
package/src/Bubble/types.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { ComponentProps } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
StyleProp,
|
|
4
4
|
ViewStyle,
|
|
5
5
|
TextStyle,
|
|
6
|
+
Pressable,
|
|
6
7
|
} from 'react-native'
|
|
7
8
|
import { MessageImageProps } from '../MessageImage'
|
|
8
9
|
import { MessageTextProps } from '../MessageText'
|
|
@@ -46,7 +47,7 @@ export type RenderMessageTextProps<TMessage extends IMessage> = Omit<
|
|
|
46
47
|
|
|
47
48
|
export interface BubbleProps<TMessage extends IMessage> {
|
|
48
49
|
user?: User
|
|
49
|
-
touchableProps?:
|
|
50
|
+
touchableProps?: ComponentProps<typeof Pressable>
|
|
50
51
|
isUsernameVisible?: boolean
|
|
51
52
|
isCustomViewBottom?: boolean
|
|
52
53
|
isInverted?: boolean
|
package/src/Composer.tsx
CHANGED
|
@@ -2,13 +2,13 @@ import React, { useCallback, useMemo, useState } from 'react'
|
|
|
2
2
|
import {
|
|
3
3
|
Platform,
|
|
4
4
|
StyleSheet,
|
|
5
|
-
TextInput,
|
|
6
5
|
TextInputChangeEvent,
|
|
7
6
|
TextInputContentSizeChangeEvent,
|
|
8
7
|
TextInputProps,
|
|
9
8
|
useColorScheme,
|
|
10
9
|
View,
|
|
11
10
|
} from 'react-native'
|
|
11
|
+
import { TextInput } from 'react-native-gesture-handler'
|
|
12
12
|
import { Color } from './Color'
|
|
13
13
|
import stylesCommon, { getColorSchemeStyle } from './styles'
|
|
14
14
|
|
package/src/Day/index.tsx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React, { useMemo } from 'react'
|
|
2
2
|
import {
|
|
3
|
-
Text,
|
|
4
3
|
View,
|
|
5
4
|
} from 'react-native'
|
|
6
5
|
import dayjs from 'dayjs'
|
|
7
6
|
import calendar from 'dayjs/plugin/calendar'
|
|
8
7
|
import relativeTime from 'dayjs/plugin/relativeTime'
|
|
9
8
|
|
|
9
|
+
import { Text } from 'react-native-gesture-handler'
|
|
10
10
|
import { DATE_FORMAT } from '../Constant'
|
|
11
|
-
import { useChatContext } from '../GiftedChatContext'
|
|
12
11
|
|
|
12
|
+
import { useChatContext } from '../GiftedChatContext'
|
|
13
13
|
import stylesCommon from '../styles'
|
|
14
14
|
import styles from './styles'
|
|
15
15
|
import { DayProps } from './types'
|
package/src/GiftedAvatar.tsx
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { useCallback, useMemo } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
Image,
|
|
4
|
-
Text,
|
|
5
4
|
View,
|
|
6
5
|
StyleSheet,
|
|
7
6
|
StyleProp,
|
|
8
7
|
ImageStyle,
|
|
9
8
|
TextStyle,
|
|
10
9
|
} from 'react-native'
|
|
10
|
+
import { Text } from 'react-native-gesture-handler'
|
|
11
11
|
import { Color } from './Color'
|
|
12
12
|
import { TouchableOpacity } from './components/TouchableOpacity'
|
|
13
13
|
import { User } from './Models'
|
|
@@ -170,7 +170,7 @@ export function GiftedAvatar (
|
|
|
170
170
|
|
|
171
171
|
return (
|
|
172
172
|
<TouchableOpacity
|
|
173
|
-
|
|
173
|
+
enabled={!!onPress}
|
|
174
174
|
onPress={handleOnPress}
|
|
175
175
|
onLongPress={handleOnLongPress}
|
|
176
176
|
style={[
|
package/src/GiftedChat/index.tsx
CHANGED
|
@@ -8,7 +8,6 @@ import React, {
|
|
|
8
8
|
RefObject,
|
|
9
9
|
} from 'react'
|
|
10
10
|
import {
|
|
11
|
-
TextInput,
|
|
12
11
|
View,
|
|
13
12
|
LayoutChangeEvent,
|
|
14
13
|
} from 'react-native'
|
|
@@ -18,7 +17,7 @@ import {
|
|
|
18
17
|
} from '@expo/react-native-action-sheet'
|
|
19
18
|
import dayjs from 'dayjs'
|
|
20
19
|
import localizedFormat from 'dayjs/plugin/localizedFormat'
|
|
21
|
-
import { GestureHandlerRootView } from 'react-native-gesture-handler'
|
|
20
|
+
import { GestureHandlerRootView, TextInput } from 'react-native-gesture-handler'
|
|
22
21
|
import { KeyboardAvoidingView, KeyboardProvider } from 'react-native-keyboard-controller'
|
|
23
22
|
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
24
23
|
import { TEST_ID } from '../Constant'
|
|
@@ -2,12 +2,12 @@ import React from 'react'
|
|
|
2
2
|
import {
|
|
3
3
|
ActivityIndicator,
|
|
4
4
|
StyleSheet,
|
|
5
|
-
Text,
|
|
6
5
|
View,
|
|
7
6
|
StyleProp,
|
|
8
7
|
ViewStyle,
|
|
9
8
|
TextStyle,
|
|
10
9
|
} from 'react-native'
|
|
10
|
+
import { Text } from 'react-native-gesture-handler'
|
|
11
11
|
import { Color } from './Color'
|
|
12
12
|
import { TouchableOpacity } from './components/TouchableOpacity'
|
|
13
13
|
import stylesCommon from './styles'
|
|
@@ -41,7 +41,7 @@ export const LoadEarlierMessages: React.FC<LoadEarlierMessagesProps> = ({
|
|
|
41
41
|
<TouchableOpacity
|
|
42
42
|
style={[styles.container, containerStyle]}
|
|
43
43
|
onPress={onPress}
|
|
44
|
-
|
|
44
|
+
enabled={!isLoading}
|
|
45
45
|
accessibilityRole='button'
|
|
46
46
|
>
|
|
47
47
|
<View style={[stylesCommon.centerItems, styles.wrapper, wrapperStyle]}>
|
package/src/Message/index.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { View } from 'react-native'
|
|
|
4
4
|
import { Avatar } from '../Avatar'
|
|
5
5
|
import { Bubble } from '../Bubble'
|
|
6
6
|
import { IMessage } from '../Models'
|
|
7
|
+
import { getStyleWithPosition } from '../styles'
|
|
7
8
|
import { SystemMessage } from '../SystemMessage'
|
|
8
9
|
import { isSameUser, renderComponentOrElement } from '../utils'
|
|
9
10
|
import styles from './styles'
|
|
@@ -96,15 +97,15 @@ export const Message = <TMessage extends IMessage = IMessage>(props: MessageProp
|
|
|
96
97
|
: (
|
|
97
98
|
<View
|
|
98
99
|
style={[
|
|
99
|
-
styles
|
|
100
|
+
getStyleWithPosition(styles, 'container', position),
|
|
100
101
|
{ marginBottom: sameUser ? 2 : 10 },
|
|
101
102
|
!props.isInverted && { marginBottom: 2 },
|
|
102
103
|
containerStyle?.[position],
|
|
103
104
|
]}
|
|
104
105
|
>
|
|
105
|
-
{position === 'left'
|
|
106
|
+
{position === 'left' && renderAvatar()}
|
|
106
107
|
{renderBubble()}
|
|
107
|
-
{position === 'right'
|
|
108
|
+
{position === 'right' && renderAvatar()}
|
|
108
109
|
</View>
|
|
109
110
|
)}
|
|
110
111
|
</View>
|
package/src/Message/styles.ts
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native'
|
|
2
2
|
|
|
3
|
-
export default {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
marginRight: 8,
|
|
20
|
-
},
|
|
21
|
-
}),
|
|
22
|
-
}
|
|
3
|
+
export default StyleSheet.create({
|
|
4
|
+
container: {
|
|
5
|
+
flexDirection: 'row',
|
|
6
|
+
alignItems: 'flex-end',
|
|
7
|
+
maxWidth: '80%',
|
|
8
|
+
},
|
|
9
|
+
container_left: {
|
|
10
|
+
justifyContent: 'flex-start',
|
|
11
|
+
marginLeft: 8,
|
|
12
|
+
},
|
|
13
|
+
container_right: {
|
|
14
|
+
justifyContent: 'flex-end',
|
|
15
|
+
marginRight: 8,
|
|
16
|
+
alignSelf: 'flex-end',
|
|
17
|
+
},
|
|
18
|
+
})
|
package/src/MessageAudio.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { useMemo } from 'react'
|
|
2
|
-
import { View,
|
|
2
|
+
import { View, StyleSheet } from 'react-native'
|
|
3
|
+
import { Text } from 'react-native-gesture-handler'
|
|
3
4
|
import { Color } from './Color'
|
|
4
5
|
|
|
5
6
|
const styles = StyleSheet.create({
|
|
6
7
|
container: {
|
|
7
|
-
padding:
|
|
8
|
+
padding: 10,
|
|
8
9
|
},
|
|
9
10
|
text: {
|
|
10
11
|
color: Color.alizarin,
|
package/src/MessageImage.tsx
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
StyleProp,
|
|
9
9
|
ImageStyle,
|
|
10
10
|
ImageURISource,
|
|
11
|
-
TouchableOpacity,
|
|
12
11
|
LayoutChangeEvent,
|
|
13
12
|
useWindowDimensions,
|
|
14
13
|
StatusBar,
|
|
@@ -24,6 +23,7 @@ import Animated, {
|
|
|
24
23
|
} from 'react-native-reanimated'
|
|
25
24
|
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
26
25
|
import Zoom from 'react-native-zoom-reanimated'
|
|
26
|
+
import { TouchableOpacity } from './components/TouchableOpacity'
|
|
27
27
|
import { IMessage } from './Models'
|
|
28
28
|
import commonStyles from './styles'
|
|
29
29
|
|
package/src/MessageText.tsx
CHANGED
|
@@ -26,7 +26,7 @@ export type MessageTextProps<TMessage extends IMessage> = {
|
|
|
26
26
|
} & Omit<AutolinkProps, 'text' | 'onPress'>
|
|
27
27
|
|
|
28
28
|
export const MessageText: React.FC<MessageTextProps<IMessage>> = ({
|
|
29
|
-
currentMessage
|
|
29
|
+
currentMessage,
|
|
30
30
|
position = 'left',
|
|
31
31
|
containerStyle,
|
|
32
32
|
textStyle,
|
|
@@ -69,10 +69,8 @@ export const MessageText: React.FC<MessageTextProps<IMessage>> = ({
|
|
|
69
69
|
|
|
70
70
|
const styles = StyleSheet.create({
|
|
71
71
|
container: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
marginLeft: 10,
|
|
75
|
-
marginRight: 10,
|
|
72
|
+
marginVertical: 5,
|
|
73
|
+
marginHorizontal: 10,
|
|
76
74
|
},
|
|
77
75
|
text: {
|
|
78
76
|
fontSize: 16,
|
package/src/MessageVideo.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { useMemo } from 'react'
|
|
2
|
-
import { View,
|
|
2
|
+
import { View, StyleSheet } from 'react-native'
|
|
3
|
+
import { Text } from 'react-native-gesture-handler'
|
|
3
4
|
import { Color } from './Color'
|
|
4
5
|
|
|
5
6
|
const styles = StyleSheet.create({
|
|
6
7
|
container: {
|
|
7
|
-
padding:
|
|
8
|
+
padding: 10,
|
|
8
9
|
},
|
|
9
10
|
text: {
|
|
10
11
|
color: Color.alizarin,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
View,
|
|
4
|
-
Text,
|
|
5
4
|
LayoutChangeEvent,
|
|
6
5
|
ListRenderItemInfo,
|
|
7
6
|
CellRendererProps,
|
|
8
7
|
} from 'react-native'
|
|
9
|
-
import { FlatList, Pressable } from 'react-native-gesture-handler'
|
|
8
|
+
import { FlatList, Pressable, Text } from 'react-native-gesture-handler'
|
|
10
9
|
import Animated, { runOnJS, useAnimatedScrollHandler, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated'
|
|
11
10
|
import { LoadEarlierMessages } from '../LoadEarlierMessages'
|
|
12
11
|
import { warning } from '../logging'
|
package/src/QuickReplies.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { useState, useMemo, useCallback } from 'react'
|
|
2
2
|
import {
|
|
3
|
-
Text,
|
|
4
3
|
StyleSheet,
|
|
5
4
|
View,
|
|
6
5
|
StyleProp,
|
|
7
6
|
ViewStyle,
|
|
8
7
|
TextStyle,
|
|
9
8
|
} from 'react-native'
|
|
9
|
+
import { Text } from 'react-native-gesture-handler'
|
|
10
10
|
import { Color } from './Color'
|
|
11
11
|
import { TouchableOpacity } from './components/TouchableOpacity'
|
|
12
12
|
import { warning } from './logging'
|
package/src/Send.tsx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React, { useMemo, useCallback, useEffect } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
StyleSheet,
|
|
4
|
-
Text,
|
|
5
4
|
StyleProp,
|
|
6
5
|
ViewStyle,
|
|
7
6
|
TextStyle,
|
|
8
7
|
useColorScheme,
|
|
9
8
|
} from 'react-native'
|
|
9
|
+
import { Text } from 'react-native-gesture-handler'
|
|
10
10
|
import Animated, { useSharedValue, useAnimatedStyle, withTiming } from 'react-native-reanimated'
|
|
11
|
-
import { Color } from './Color'
|
|
12
11
|
|
|
12
|
+
import { Color } from './Color'
|
|
13
13
|
import { TouchableOpacity, TouchableOpacityProps } from './components/TouchableOpacity'
|
|
14
14
|
import { TEST_ID } from './Constant'
|
|
15
15
|
import { IMessage } from './Models'
|