Skip to content

Commit ab424e1

Browse files
committed
fix: add theme for different group styles in message bubble container
1 parent 70e6c70 commit ab424e1

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

package/src/components/Message/MessageSimple/MessageContent.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export type MessageContentPropsWithContext<
8888
MessagesContextValue<StreamChatGenerics>,
8989
| 'additionalPressableProps'
9090
| 'Attachment'
91+
| 'enableMessageGroupingByUser'
9192
| 'FileAttachmentGroup'
9293
| 'Gallery'
9394
| 'isAttachmentEqual'
@@ -102,10 +103,18 @@ export type MessageContentPropsWithContext<
102103
* Background color for the message content
103104
*/
104105
backgroundColor?: ColorValue;
106+
/**
107+
* If the message is the very last message in the message list
108+
*/
109+
isVeryLastMessage?: boolean;
105110
/**
106111
* If the message has no border radius
107112
*/
108113
noBorder?: boolean;
114+
/**
115+
* If the message is grouped in a single or bottom container
116+
*/
117+
messageGroupedSingleOrBottom?: boolean;
109118
};
110119

111120
/**
@@ -121,13 +130,16 @@ const MessageContentWithContext = <
121130
alignment,
122131
Attachment,
123132
backgroundColor,
133+
enableMessageGroupingByUser,
124134
FileAttachmentGroup,
125135
Gallery,
126136
groupStyles,
127137
isMessageAIGenerated,
128138
isMyMessage,
139+
isVeryLastMessage,
129140
message,
130141
messageContentOrder,
142+
messageGroupedSingleOrBottom = false,
131143
MessageError,
132144
noBorder,
133145
onLongPress,
@@ -159,6 +171,9 @@ const MessageContentWithContext = <
159171
...container
160172
},
161173
containerInner,
174+
lastMessageContainer,
175+
messageGroupedSingleOrBottomContainer,
176+
messageGroupedTopContainer,
162177
replyBorder,
163178
replyContainer,
164179
wrapper,
@@ -283,6 +298,11 @@ const MessageContentWithContext = <
283298
},
284299
noBorder ? { borderWidth: 0 } : {},
285300
containerInner,
301+
messageGroupedSingleOrBottom
302+
? isVeryLastMessage && enableMessageGroupingByUser
303+
? lastMessageContainer
304+
: messageGroupedSingleOrBottomContainer
305+
: messageGroupedTopContainer,
286306
]}
287307
testID='message-content-wrapper'
288308
>
@@ -520,6 +540,7 @@ export const MessageContent = <
520540
const {
521541
additionalPressableProps,
522542
Attachment,
543+
enableMessageGroupingByUser,
523544
FileAttachmentGroup,
524545
Gallery,
525546
isAttachmentEqual,
@@ -536,6 +557,7 @@ export const MessageContent = <
536557
additionalPressableProps,
537558
alignment,
538559
Attachment,
560+
enableMessageGroupingByUser,
539561
FileAttachmentGroup,
540562
Gallery,
541563
goToMessage,

package/src/components/Message/MessageSimple/MessageSimple.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ const MessageSimpleWithContext = <
278278
<View style={[styles.contentWrapper, contentWrapper]}>
279279
<MessageContent
280280
backgroundColor={backgroundColor}
281+
isVeryLastMessage={isVeryLastMessage}
282+
messageGroupedSingleOrBottom={messageGroupedSingleOrBottom}
281283
noBorder={noBorder}
282284
setMessageContentWidth={setMessageContentWidth}
283285
/>
@@ -293,6 +295,8 @@ const MessageSimpleWithContext = <
293295
ReactionListTop,
294296
backgroundColor,
295297
contentWrapper,
298+
isVeryLastMessage,
299+
messageGroupedSingleOrBottom,
296300
noBorder,
297301
],
298302
);
@@ -322,6 +326,10 @@ const MessageSimpleWithContext = <
322326
],
323327
);
324328

329+
if (messageGroupedSingleOrBottom) {
330+
console.log(message.text);
331+
}
332+
325333
return (
326334
<View
327335
style={[

package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ exports[`Thread should match thread snapshot 1`] = `
602602
},
603603
{},
604604
{},
605+
{},
605606
]
606607
}
607608
testID="message-content-wrapper"
@@ -1112,6 +1113,7 @@ exports[`Thread should match thread snapshot 1`] = `
11121113
},
11131114
{},
11141115
{},
1116+
{},
11151117
]
11161118
}
11171119
testID="message-content-wrapper"
@@ -1660,6 +1662,7 @@ exports[`Thread should match thread snapshot 1`] = `
16601662
},
16611663
{},
16621664
{},
1665+
{},
16631666
]
16641667
}
16651668
testID="message-content-wrapper"
@@ -2163,6 +2166,7 @@ exports[`Thread should match thread snapshot 1`] = `
21632166
},
21642167
{},
21652168
{},
2169+
{},
21662170
]
21672171
}
21682172
testID="message-content-wrapper"

package/src/contexts/themeContext/utils/theme.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,14 @@ export type Theme = {
539539
errorIcon: IconProps;
540540
errorIconContainer: ViewStyle;
541541
eyeIcon: IconProps;
542+
lastMessageContainer: ViewStyle;
542543
/**
543544
* Available options for styling text:
544545
* https://github.com/andangrd/react-native-markdown-package/blob/main/styles.js
545546
*/
546547
markdown: MarkdownStyle;
548+
messageGroupedSingleOrBottomContainer: ViewStyle;
549+
messageGroupedTopContainer: ViewStyle;
547550
messageUser: TextStyle;
548551
metaContainer: ViewStyle;
549552
metaText: TextStyle;
@@ -1325,7 +1328,10 @@ export const defaultTheme: Theme = {
13251328
height: 16,
13261329
width: 16,
13271330
},
1331+
lastMessageContainer: {},
13281332
markdown: {},
1333+
messageGroupedSingleOrBottomContainer: {},
1334+
messageGroupedTopContainer: {},
13291335
messageUser: {
13301336
fontSize: 12,
13311337
fontWeight: '700',

0 commit comments

Comments
 (0)