Skip to content

Commit 7c2567c

Browse files
authored
feat: add sender and receiver message theme background color (#2485)
1 parent 8b79f5b commit 7c2567c

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

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

+14-12
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,10 @@ const MessageContentWithContext = <
164164
},
165165
containerInner,
166166
errorContainer,
167+
receiverMessageBackgroundColor,
167168
replyBorder,
168169
replyContainer,
170+
senderMessageBackgroundColor,
169171
wrapper,
170172
},
171173
reactionList: { radius, reactionSize },
@@ -225,7 +227,9 @@ const MessageContentWithContext = <
225227
);
226228
}
227229

228-
let backgroundColor = grey_gainsboro;
230+
const isMessageReceivedOrErrorType = !isMyMessage || error;
231+
232+
let backgroundColor = senderMessageBackgroundColor || grey_gainsboro;
229233
if (onlyEmojis && !message.quoted_message) {
230234
backgroundColor = transparent;
231235
} else if (otherAttachments.length) {
@@ -234,13 +238,11 @@ const MessageContentWithContext = <
234238
} else {
235239
backgroundColor = blue_alice;
236240
}
237-
} else if (alignment === 'left' || error) {
238-
backgroundColor = white;
241+
} else if (isMessageReceivedOrErrorType) {
242+
backgroundColor = receiverMessageBackgroundColor || white;
239243
}
240244

241-
const repliesCurveColor = isMyMessage && !error ? backgroundColor : grey_whisper;
242-
243-
const isBorderColor = isMyMessage && !error;
245+
const repliesCurveColor = !isMessageReceivedOrErrorType ? backgroundColor : grey_gainsboro;
244246

245247
const getBorderRadius = () => {
246248
// enum('top', 'middle', 'bottom', 'single')
@@ -252,10 +254,10 @@ const MessageContentWithContext = <
252254

253255
if (isBottomOrSingle && (!hasThreadReplies || threadList)) {
254256
// add relevant sharp corner
255-
if (alignment === 'left') {
256-
borderBottomLeftRadius = borderRadiusS;
257-
} else {
257+
if (isMyMessage) {
258258
borderBottomRightRadius = borderRadiusS;
259+
} else {
260+
borderBottomLeftRadius = borderRadiusS;
259261
}
260262
}
261263

@@ -319,7 +321,7 @@ const MessageContentWithContext = <
319321
* Otherwise background is transparent, so border radius is not really visible.
320322
*/
321323
style={[
322-
alignment === 'left' ? styles.leftAlignItems : styles.rightAlignItems,
324+
isMyMessage ? styles.rightAlignItems : styles.leftAlignItems,
323325
{ paddingTop: hasReactions ? reactionSize / 2 + radius : 2 },
324326
error ? errorContainer : {},
325327
container,
@@ -329,7 +331,7 @@ const MessageContentWithContext = <
329331
<MessageHeader
330332
alignment={alignment}
331333
formattedDate={getDateText(formatDate)}
332-
isDeleted={!!isMessageTypeDeleted}
334+
isDeleted={isMessageTypeDeleted}
333335
lastGroupMessage={lastGroupMessage}
334336
members={members}
335337
message={message}
@@ -358,7 +360,7 @@ const MessageContentWithContext = <
358360
styles.containerInner,
359361
{
360362
backgroundColor,
361-
borderColor: isBorderColor ? backgroundColor : grey_whisper,
363+
borderColor: isMessageReceivedOrErrorType ? grey_whisper : backgroundColor,
362364
...getBorderRadius(),
363365
...getBorderRadiusFromTheme(),
364366
},

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

+2
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ export type Theme = {
426426
onlyEmojiMarkdown: MarkdownStyle;
427427
};
428428
wrapper: ViewStyle;
429+
receiverMessageBackgroundColor?: ColorValue;
430+
senderMessageBackgroundColor?: ColorValue;
429431
};
430432
file: {
431433
container: ViewStyle;

0 commit comments

Comments
 (0)