File tree Expand file tree Collapse file tree 5 files changed +33
-2
lines changed
Sources/StreamChatSwiftUI
StreamChatSwiftUITests/Tests/Utils Expand file tree Collapse file tree 5 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33
44# Upcoming
55
6+ ### ✅ Added
7+ - Add factory method for custom attachments in quoted messages
8+
69### 🐞 Fixed
710- Fix marked read while the app is in the background
811- Fix recently saved images to camera roll don't show up
Original file line number Diff line number Diff line change @@ -60,13 +60,18 @@ public struct QuotedMessageView<Factory: ViewFactory>: View {
6060 @Injected ( \. images) private var images
6161 @Injected ( \. fonts) private var fonts
6262 @Injected ( \. colors) private var colors
63-
63+ @Injected ( \. utils) private var utils
64+
6465 private let attachmentWidth : CGFloat = 36
6566
6667 public var factory : Factory
6768 public var quotedMessage : ChatMessage
6869 public var fillAvailableSpace : Bool
6970 public var forceLeftToRight : Bool
71+
72+ private var messageTypeResolver : MessageTypeResolving {
73+ utils. messageTypeResolver
74+ }
7075
7176 public init (
7277 factory: Factory ,
@@ -84,7 +89,9 @@ public struct QuotedMessageView<Factory: ViewFactory>: View {
8489 HStack ( alignment: . top) {
8590 if !quotedMessage. attachmentCounts. isEmpty {
8691 ZStack {
87- if !quotedMessage. imageAttachments. isEmpty {
92+ if messageTypeResolver. hasCustomAttachment ( message: quotedMessage) {
93+ factory. makeCustomAttachmentQuotedView ( for: quotedMessage)
94+ } else if !quotedMessage. imageAttachments. isEmpty {
8895 LazyLoadingImage (
8996 source: quotedMessage. imageAttachments [ 0 ] . imageURL,
9097 width: attachmentWidth,
Original file line number Diff line number Diff line change @@ -830,6 +830,10 @@ extension ViewFactory {
830830 )
831831 }
832832
833+ public func makeCustomAttachmentQuotedView( for message: ChatMessage ) -> some View {
834+ EmptyView ( )
835+ }
836+
833837 public func makeEditedMessageHeaderView(
834838 editedMessage: Binding < ChatMessage ? >
835839 ) -> some View {
Original file line number Diff line number Diff line change @@ -822,6 +822,12 @@ public protocol ViewFactory: AnyObject {
822822 isInComposer: Bool ,
823823 scrolledId: Binding < String ? >
824824 ) -> QuotedMessageViewType
825+
826+ associatedtype CustomAttachmentQuotedViewType : View
827+ /// Creates a quoted view for custom attachments. Returns `EmptyView` by default.
828+ /// - Parameter message: the quoted message.
829+ /// - Returns: view shown in quoted messages with custom attachments.
830+ func makeCustomAttachmentQuotedView( for message: ChatMessage ) -> CustomAttachmentQuotedViewType
825831
826832 associatedtype EditedMessageHeaderViewType : View
827833 /// Creates the edited message header view in the composer.
Original file line number Diff line number Diff line change @@ -819,6 +819,17 @@ class ViewFactory_Tests: StreamChatTestCase {
819819 // Then
820820 XCTAssert ( view is BottomReactionsView )
821821 }
822+
823+ func test_viewFactory_makeCustomAttachmentQuotedView( ) {
824+ // Given
825+ let viewFactory = DefaultViewFactory . shared
826+
827+ // When
828+ let view = viewFactory. makeCustomAttachmentQuotedView ( for: . mock( ) )
829+
830+ // Then
831+ XCTAssert ( view is EmptyView )
832+ }
822833}
823834
824835extension ChannelAction : Equatable {
You can’t perform that action at this time.
0 commit comments