Skip to content

Commit 4da693f

Browse files
Fixed message text color when using link detection (#452)
1 parent 703d656 commit 4da693f

File tree

6 files changed

+52
-2
lines changed

6 files changed

+52
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33

44
# Upcoming
55

6-
### 🔄 Changed
6+
### 🐞 Fixed
7+
- Message text color when using link detection
78

89
# [4.50.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.50.0)
910
_March 12, 2024_

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ struct LinkDetectionTextView: View {
263263

264264
var body: some View {
265265
Text(displayedText)
266+
.foregroundColor(textColor(for: message))
267+
.font(fonts.body)
266268
.onAppear {
267269
let attributedText = NSMutableAttributedString(
268270
string: text,

StreamChatSwiftUITests/Tests/ChatChannel/MessageContainerView_Tests.swift

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class MessageContainerView_Tests: StreamChatTestCase {
3636

3737
func test_messageContainerEdited_snapshot() {
3838
// Given
39-
streamChat = StreamChat(chatClient: chatClient)
39+
let utils = Utils(dateFormatter: EmptyDateFormatter())
40+
streamChat = StreamChat(chatClient: chatClient, utils: utils)
4041
let message = ChatMessage.mock(
4142
id: .unique,
4243
cid: .unique,
@@ -52,6 +53,52 @@ class MessageContainerView_Tests: StreamChatTestCase {
5253
// Then
5354
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
5455
}
56+
57+
func test_messageContainerCurrentUserColor_snapshot() {
58+
// Given
59+
let utils = Utils(dateFormatter: EmptyDateFormatter())
60+
var colors = ColorPalette()
61+
colors.messageCurrentUserTextColor = .red
62+
let appearance = Appearance(colors: colors)
63+
streamChat = StreamChat(chatClient: chatClient, appearance: appearance, utils: utils)
64+
let message = ChatMessage.mock(
65+
id: .unique,
66+
cid: .unique,
67+
text: "Message sent by current user",
68+
author: .mock(id: Self.currentUserId, name: "Martin"),
69+
isSentByCurrentUser: true,
70+
textUpdatedAt: Date()
71+
)
72+
73+
// When
74+
let view = testMessageViewContainer(message: message)
75+
76+
// Then
77+
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
78+
}
79+
80+
func test_messageContainerOtherUserColor_snapshot() {
81+
// Given
82+
let utils = Utils(dateFormatter: EmptyDateFormatter())
83+
var colors = ColorPalette()
84+
colors.messageOtherUserTextColor = .red
85+
let appearance = Appearance(colors: colors)
86+
streamChat = StreamChat(chatClient: chatClient, appearance: appearance, utils: utils)
87+
let message = ChatMessage.mock(
88+
id: .unique,
89+
cid: .unique,
90+
text: "Message sent by other user",
91+
author: .mock(id: Self.currentUserId, name: "Martin"),
92+
isSentByCurrentUser: false,
93+
textUpdatedAt: Date()
94+
)
95+
96+
// When
97+
let view = testMessageViewContainer(message: message)
98+
99+
// Then
100+
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
101+
}
55102

56103
func test_messageContainerViewSentOtherUser_snapshot() {
57104
// Given
Loading
Loading
Loading

0 commit comments

Comments
 (0)