react-native-gifted-chat 3.0.1 → 3.1.1

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/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'
@@ -14,48 +14,53 @@ import stylesCommon from './styles'
14
14
  export interface SystemMessageProps<TMessage extends IMessage> {
15
15
  currentMessage: TMessage
16
16
  containerStyle?: StyleProp<ViewStyle>
17
- wrapperStyle?: StyleProp<ViewStyle>
17
+ messageContainerStyle?: StyleProp<ViewStyle>
18
18
  textStyle?: StyleProp<TextStyle>
19
19
  children?: React.ReactNode
20
20
  }
21
21
 
22
- export function SystemMessage<TMessage extends IMessage = IMessage> ({
22
+ export function SystemMessage<TMessage extends IMessage> ({
23
23
  currentMessage,
24
24
  containerStyle,
25
- wrapperStyle,
25
+ messageContainerStyle,
26
26
  textStyle,
27
27
  children,
28
28
  }: SystemMessageProps<TMessage>) {
29
- if (currentMessage == null || currentMessage.system === false)
29
+ if (currentMessage == null)
30
30
  return null
31
31
 
32
32
  return (
33
- <View style={[stylesCommon.fill, stylesCommon.centerItems, styles.container, containerStyle]}>
34
- <View style={wrapperStyle}>
35
- <MessageText
36
- currentMessage={currentMessage}
37
- customTextStyle={[styles.text, textStyle]}
38
- containerStyle={{ left: styles.messageContainer, right: styles.messageContainer }}
39
- />
40
- {children}
41
- </View>
33
+ <View style={[stylesCommon.fill, styles.container, containerStyle]}>
34
+ {
35
+ !!currentMessage.text && (
36
+ <MessageText
37
+ currentMessage={currentMessage}
38
+ customTextStyle={[styles.text, textStyle]}
39
+ position='left'
40
+ containerStyle={{ left: [styles.messageContainer, messageContainerStyle] }}
41
+ />
42
+ )
43
+ }
44
+ {children}
42
45
  </View>
43
46
  )
44
47
  }
45
48
 
46
49
  const styles = StyleSheet.create({
47
50
  container: {
48
- marginTop: 5,
49
- marginBottom: 10,
50
- marginHorizontal: 20,
51
- },
52
- messageContainer: {
53
51
  borderRadius: 20,
54
52
  borderWidth: 1,
55
53
  borderColor: 'rgba(0,0,0,0.1)',
56
54
  paddingHorizontal: 10,
57
55
  paddingVertical: 10,
58
56
  backgroundColor: 'rgba(0,0,0,0.05)',
57
+ marginVertical: 5,
58
+ marginHorizontal: 10,
59
+ alignItems: 'flex-end',
60
+ },
61
+ messageContainer: {
62
+ marginVertical: 0,
63
+ marginHorizontal: 0,
59
64
  },
60
65
  text: {
61
66
  backgroundColor: Color.backgroundTransparent,
package/src/Time.tsx CHANGED
@@ -1,48 +1,27 @@
1
1
  import React, { useMemo } from 'react'
2
- import { StyleSheet, Text, View, ViewStyle, TextStyle } from 'react-native'
2
+ import { StyleSheet, View, ViewStyle, TextStyle } from 'react-native'
3
3
  import dayjs from 'dayjs'
4
4
 
5
+ import { Text } from 'react-native-gesture-handler'
5
6
  import { Color } from './Color'
6
7
  import { TIME_FORMAT } from './Constant'
7
8
  import { useChatContext } from './GiftedChatContext'
8
9
  import { LeftRightStyle, IMessage } from './Models'
10
+ import { getStyleWithPosition } from './styles'
9
11
 
10
- const { containerStyle } = StyleSheet.create({
11
- containerStyle: {
12
- marginLeft: 10,
13
- marginRight: 10,
14
- marginBottom: 5,
15
- },
16
- })
17
-
18
- const { textStyle } = StyleSheet.create({
19
- textStyle: {
12
+ const styles = StyleSheet.create({
13
+ text: {
20
14
  fontSize: 10,
21
15
  textAlign: 'right',
22
16
  },
17
+ text_left: {
18
+ color: Color.timeTextColor,
19
+ },
20
+ text_right: {
21
+ color: Color.white,
22
+ },
23
23
  })
24
24
 
25
- const styles = {
26
- left: StyleSheet.create({
27
- container: {
28
- ...containerStyle,
29
- },
30
- text: {
31
- color: Color.timeTextColor,
32
- ...textStyle,
33
- },
34
- }),
35
- right: StyleSheet.create({
36
- container: {
37
- ...containerStyle,
38
- },
39
- text: {
40
- color: Color.white,
41
- ...textStyle,
42
- },
43
- }),
44
- }
45
-
46
25
  export interface TimeProps<TMessage extends IMessage> {
47
26
  position?: 'left' | 'right'
48
27
  currentMessage: TMessage
@@ -71,15 +50,10 @@ export const Time = <TMessage extends IMessage = IMessage>({
71
50
  return null
72
51
 
73
52
  return (
74
- <View
75
- style={[
76
- styles[position].container,
77
- containerStyle?.[position],
78
- ]}
79
- >
53
+ <View style={containerStyle?.[position]}>
80
54
  <Text
81
55
  style={[
82
- styles[position].text,
56
+ getStyleWithPosition(styles, 'text', position),
83
57
  timeTextStyle?.[position],
84
58
  ]}
85
59
  >
@@ -10,7 +10,7 @@ const messages = [
10
10
  createdAt: new Date(),
11
11
  user: {
12
12
  _id: 2,
13
- name: 'React Native',
13
+ name: 'John Doe',
14
14
  },
15
15
  },
16
16
  ]
@@ -1,19 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`should render <Bubble /> and compare with snapshot 1`] = `
4
- <View
5
- style={
6
- [
7
- {
8
- "flex": 1,
9
- },
10
- {
11
- "alignItems": "flex-start",
12
- },
13
- undefined,
14
- ]
15
- }
16
- >
4
+ <View>
17
5
  <View
18
6
  style={
19
7
  [
@@ -21,7 +9,6 @@ exports[`should render <Bubble /> and compare with snapshot 1`] = `
21
9
  "backgroundColor": "#f0f0f0",
22
10
  "borderRadius": 15,
23
11
  "justifyContent": "flex-end",
24
- "marginRight": 60,
25
12
  "minHeight": 20,
26
13
  },
27
14
  null,
@@ -61,66 +48,67 @@ exports[`should render <Bubble /> and compare with snapshot 1`] = `
61
48
  onResponderTerminationRequest={[Function]}
62
49
  onStartShouldSetResponder={[Function]}
63
50
  >
64
- <View>
65
- <View>
66
- <View
67
- style={
68
- [
69
- {
70
- "marginBottom": 5,
71
- "marginLeft": 10,
72
- "marginRight": 10,
73
- "marginTop": 5,
74
- },
75
- undefined,
76
- ]
51
+ <View
52
+ style={
53
+ [
54
+ {
55
+ "marginHorizontal": 10,
56
+ "marginVertical": 5,
57
+ },
58
+ undefined,
59
+ ]
60
+ }
61
+ >
62
+ <Text
63
+ style={
64
+ [
65
+ {
66
+ "color": "black",
67
+ },
68
+ undefined,
69
+ undefined,
70
+ ]
71
+ }
72
+ user={
73
+ {
74
+ "_id": 1,
77
75
  }
78
- >
79
- <Text
80
- style={
81
- [
82
- {
83
- "color": "black",
84
- },
85
- undefined,
86
- undefined,
87
- ]
88
- }
89
- user={
90
- {
91
- "_id": 1,
92
- }
93
- }
94
- >
95
- <Text>
96
- test
97
- </Text>
98
- </Text>
99
- </View>
100
- </View>
76
+ }
77
+ >
78
+ <Text>
79
+ test
80
+ </Text>
81
+ </Text>
82
+ </View>
83
+ <View
84
+ style={
85
+ [
86
+ {
87
+ "alignItems": "flex-end",
88
+ "flexDirection": "row",
89
+ "justifyContent": "space-between",
90
+ "paddingBottom": 5,
91
+ "paddingHorizontal": 10,
92
+ },
93
+ undefined,
94
+ ]
95
+ }
96
+ >
101
97
  <View
102
98
  style={
103
99
  [
104
100
  {
101
+ "flex": 1,
102
+ },
103
+ {
104
+ "alignItems": "center",
105
105
  "flexDirection": "row",
106
- "justifyContent": "flex-start",
106
+ "justifyContent": "flex-end",
107
107
  },
108
- undefined,
109
108
  ]
110
109
  }
111
110
  >
112
- <View
113
- style={
114
- [
115
- {
116
- "marginBottom": 5,
117
- "marginLeft": 10,
118
- "marginRight": 10,
119
- },
120
- undefined,
121
- ]
122
- }
123
- >
111
+ <View>
124
112
  <Text
125
113
  style={
126
114
  [
@@ -11,10 +11,15 @@ exports[`should render <Composer /> and compare with snapshot 1`] = `
11
11
  <TextInput
12
12
  accessibilityLabel="Type a message..."
13
13
  accessible={true}
14
+ collapsable={false}
14
15
  enablesReturnKeyAutomatically={true}
16
+ handlerTag={-1}
17
+ handlerType="NativeViewGestureHandler"
15
18
  keyboardAppearance="default"
16
19
  multiline={true}
17
20
  onChange={[Function]}
21
+ onGestureHandlerEvent={[Function]}
22
+ onGestureHandlerStateChange={[Function]}
18
23
  placeholder="Type a message..."
19
24
  placeholderTextColor="#b2b2b2"
20
25
  style={
@@ -40,10 +40,15 @@ exports[`should render <InputToolbar /> and compare with snapshot 1`] = `
40
40
  <TextInput
41
41
  accessibilityLabel="Type a message..."
42
42
  accessible={true}
43
+ collapsable={false}
43
44
  enablesReturnKeyAutomatically={true}
45
+ handlerTag={-1}
46
+ handlerType="NativeViewGestureHandler"
44
47
  keyboardAppearance="default"
45
48
  multiline={true}
46
49
  onChange={[Function]}
50
+ onGestureHandlerEvent={[Function]}
51
+ onGestureHandlerStateChange={[Function]}
47
52
  placeholder="Type a message..."
48
53
  placeholderTextColor="#b2b2b2"
49
54
  style={