File tree Expand file tree Collapse file tree 6 files changed +47
-2
lines changed
Sources/StreamChatSwiftUI
StreamChatSwiftUITests/Tests/ChatChannel
__Snapshots__/MessageView_Tests Expand file tree Collapse file tree 6 files changed +47
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88- Opens ` MarkdownFormatter ` so that it can be customised [ #978 ] ( https://github.com/GetStream/stream-chat-swiftui/pull/978 )
99- Add participant actions in channel info view [ #982 ] ( https://github.com/GetStream/stream-chat-swiftui/pull/982 )
1010- Add support for overriding ` onImageTap ` in ` LinkAttachmentView ` [ #986 ] ( https://github.com/GetStream/stream-chat-swiftui/pull/986 )
11+ - Add support for customizing text colors in ` LinkAttachmentView ` [ #992 ] ( https://github.com/GetStream/stream-chat-swiftui/pull/992 )
1112
1213### 🐞 Fixed
1314- Fix openChannel not working when searching or another chat shown [ #975 ] ( https://github.com/GetStream/stream-chat-swiftui/pull/975 )
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ public struct LinkAttachmentView: View {
129129 if !authorHidden {
130130 BottomLeftView {
131131 Text ( linkAttachment. author ?? " " )
132- . foregroundColor ( colors. tintColor )
132+ . foregroundColor ( colors. messageLinkAttachmentAuthorColor )
133133 . font ( fonts. bodyBold)
134134 . standardPadding ( )
135135 . bubble (
@@ -146,12 +146,14 @@ public struct LinkAttachmentView: View {
146146 if let title = linkAttachment. title {
147147 Text ( title)
148148 . font ( fonts. footnoteBold)
149+ . foregroundColor ( colors. messageLinkAttachmentTitleColor)
149150 . lineLimit ( 1 )
150151 }
151152
152153 if let description = linkAttachment. text {
153154 Text ( description)
154155 . font ( fonts. footnote)
156+ . foregroundColor ( colors. messageLinkAttachmentTextColor)
155157 . lineLimit ( 3 )
156158 }
157159 }
Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ public struct ColorPalette {
1111 navigationBarTitle = text
1212 navigationBarSubtitle = textLowEmphasis
1313 navigationBarTintColor = tintColor
14+
15+ messageLinkAttachmentAuthorColor = tintColor
16+ messageLinkAttachmentTitleColor = Color ( text)
17+ messageLinkAttachmentTextColor = Color ( text)
1418 }
1519
1620 /// Tint color used in UI components.
@@ -86,6 +90,12 @@ public struct ColorPalette {
8690 public lazy var selectedReactionBackgroundColor : UIColor ? = nil
8791 public var voiceMessageControlBackground : UIColor = . streamWhiteStatic
8892
93+ // MARK: - Link Attachment View
94+
95+ public var messageLinkAttachmentAuthorColor : Color
96+ public var messageLinkAttachmentTitleColor : Color
97+ public var messageLinkAttachmentTextColor : Color
98+
8999 // MARK: - Composer
90100
91101 public lazy var composerPlaceholderColor : UIColor = subtitleText
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ internal enum L10n {
115115 }
116116 /// Remove User
117117 internal static var removeUserConfirmationTitle : String { L10n . tr ( " Localizable " , " channel.item.remove-user-confirmation-title " ) }
118- /// Send direct message
118+ /// Send Direct Message
119119 internal static var sendDirectMessage : String { L10n . tr ( " Localizable " , " channel.item.send-direct-message " ) }
120120 /// are typing ...
121121 internal static var typingPlural : String { L10n . tr ( " Localizable " , " channel.item.typing-plural " ) }
Original file line number Diff line number Diff line change @@ -575,6 +575,38 @@ class MessageView_Tests: StreamChatTestCase {
575575 assertSnapshot ( matching: view, as: . image( perceptualPrecision: precision) )
576576 }
577577
578+ func test_linkAttachmentView_customColors_snapshot( ) {
579+ // Given
580+ var colorPalette = ColorPalette ( )
581+ colorPalette. messageLinkAttachmentAuthorColor = . orange
582+ colorPalette. messageLinkAttachmentTitleColor = . blue
583+ colorPalette. messageLinkAttachmentTextColor = . red
584+ streamChat = StreamChat (
585+ chatClient: chatClient,
586+ appearance: . init( colors: colorPalette)
587+ )
588+
589+ // When
590+ let view = LinkAttachmentView (
591+ linkAttachment: . mock(
592+ id: . unique,
593+ originalURL: URL ( string: " https://getstream.io " ) !,
594+ title: " Stream " ,
595+ text: " Some link text description " ,
596+ author: " Nuno Vieira " ,
597+ titleLink: nil ,
598+ assetURL: nil ,
599+ previewURL: . localYodaImage
600+ ) ,
601+ width: 200 ,
602+ isFirst: true
603+ )
604+ . frame ( width: 200 , height: 140 )
605+
606+ // Then
607+ assertSnapshot ( matching: view, as: . image( perceptualPrecision: precision) )
608+ }
609+
578610 func test_linkAttachmentView_shouldNotRenderLinkPreviewWithOtherAttachments( ) {
579611 // Given
580612 let messageWithLinkAndImages = ChatMessage . mock (
You can’t perform that action at this time.
0 commit comments