Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add sender and receiver message theme background color #2485

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions package/src/components/Message/MessageSimple/MessageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ const MessageContentWithContext = <
},
containerInner,
errorContainer,
receiverMessageBackgroundColor,
replyBorder,
replyContainer,
senderMessageBackgroundColor,
wrapper,
},
reactionList: { radius, reactionSize },
Expand Down Expand Up @@ -225,7 +227,9 @@ const MessageContentWithContext = <
);
}

let backgroundColor = grey_gainsboro;
const isMessageReceivedOrErrorType = !isMyMessage || error;

let backgroundColor = senderMessageBackgroundColor || grey_gainsboro;
if (onlyEmojis && !message.quoted_message) {
backgroundColor = transparent;
} else if (otherAttachments.length) {
Expand All @@ -234,13 +238,11 @@ const MessageContentWithContext = <
} else {
backgroundColor = blue_alice;
}
} else if (alignment === 'left' || error) {
backgroundColor = white;
} else if (isMessageReceivedOrErrorType) {
backgroundColor = receiverMessageBackgroundColor || white;
}

const repliesCurveColor = isMyMessage && !error ? backgroundColor : grey_whisper;

const isBorderColor = isMyMessage && !error;
const repliesCurveColor = !isMessageReceivedOrErrorType ? backgroundColor : grey_gainsboro;

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

if (isBottomOrSingle && (!hasThreadReplies || threadList)) {
// add relevant sharp corner
if (alignment === 'left') {
borderBottomLeftRadius = borderRadiusS;
} else {
if (isMyMessage) {
borderBottomRightRadius = borderRadiusS;
} else {
borderBottomLeftRadius = borderRadiusS;
}
}

Expand Down Expand Up @@ -319,7 +321,7 @@ const MessageContentWithContext = <
* Otherwise background is transparent, so border radius is not really visible.
*/
style={[
alignment === 'left' ? styles.leftAlignItems : styles.rightAlignItems,
isMyMessage ? styles.rightAlignItems : styles.leftAlignItems,
{ paddingTop: hasReactions ? reactionSize / 2 + radius : 2 },
error ? errorContainer : {},
container,
Expand All @@ -329,7 +331,7 @@ const MessageContentWithContext = <
<MessageHeader
alignment={alignment}
formattedDate={getDateText(formatDate)}
isDeleted={!!isMessageTypeDeleted}
isDeleted={isMessageTypeDeleted}
lastGroupMessage={lastGroupMessage}
members={members}
message={message}
Expand Down Expand Up @@ -358,7 +360,7 @@ const MessageContentWithContext = <
styles.containerInner,
{
backgroundColor,
borderColor: isBorderColor ? backgroundColor : grey_whisper,
borderColor: isMessageReceivedOrErrorType ? grey_whisper : backgroundColor,
...getBorderRadius(),
...getBorderRadiusFromTheme(),
},
Expand Down
2 changes: 2 additions & 0 deletions package/src/contexts/themeContext/utils/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ export type Theme = {
onlyEmojiMarkdown: MarkdownStyle;
};
wrapper: ViewStyle;
receiverMessageBackgroundColor?: ColorValue;
senderMessageBackgroundColor?: ColorValue;
};
file: {
container: ViewStyle;
Expand Down
Loading