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/).
3
3
4
4
# Upcoming
5
5
6
+ ### ✅ Added
7
+ - Add factory method for custom attachments in quoted messages
8
+
6
9
### 🐞 Fixed
7
10
- Fix marked read while the app is in the background
8
11
- 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 {
60
60
@Injected ( \. images) private var images
61
61
@Injected ( \. fonts) private var fonts
62
62
@Injected ( \. colors) private var colors
63
-
63
+ @Injected ( \. utils) private var utils
64
+
64
65
private let attachmentWidth : CGFloat = 36
65
66
66
67
public var factory : Factory
67
68
public var quotedMessage : ChatMessage
68
69
public var fillAvailableSpace : Bool
69
70
public var forceLeftToRight : Bool
71
+
72
+ private var messageTypeResolver : MessageTypeResolving {
73
+ utils. messageTypeResolver
74
+ }
70
75
71
76
public init (
72
77
factory: Factory ,
@@ -84,7 +89,9 @@ public struct QuotedMessageView<Factory: ViewFactory>: View {
84
89
HStack ( alignment: . top) {
85
90
if !quotedMessage. attachmentCounts. isEmpty {
86
91
ZStack {
87
- if !quotedMessage. imageAttachments. isEmpty {
92
+ if messageTypeResolver. hasCustomAttachment ( message: quotedMessage) {
93
+ factory. makeCustomAttachmentQuotedView ( for: quotedMessage)
94
+ } else if !quotedMessage. imageAttachments. isEmpty {
88
95
LazyLoadingImage (
89
96
source: quotedMessage. imageAttachments [ 0 ] . imageURL,
90
97
width: attachmentWidth,
Original file line number Diff line number Diff line change @@ -830,6 +830,10 @@ extension ViewFactory {
830
830
)
831
831
}
832
832
833
+ public func makeCustomAttachmentQuotedView( for message: ChatMessage ) -> some View {
834
+ EmptyView ( )
835
+ }
836
+
833
837
public func makeEditedMessageHeaderView(
834
838
editedMessage: Binding < ChatMessage ? >
835
839
) -> some View {
Original file line number Diff line number Diff line change @@ -822,6 +822,12 @@ public protocol ViewFactory: AnyObject {
822
822
isInComposer: Bool ,
823
823
scrolledId: Binding < String ? >
824
824
) -> 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
825
831
826
832
associatedtype EditedMessageHeaderViewType : View
827
833
/// 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 {
819
819
// Then
820
820
XCTAssert ( view is BottomReactionsView )
821
821
}
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
+ }
822
833
}
823
834
824
835
extension ChannelAction : Equatable {
You can’t perform that action at this time.
0 commit comments