2
2
// Copyright © 2023 Stream.io Inc. All rights reserved.
3
3
//
4
4
5
+ import StreamChat
5
6
import SwiftUI
6
7
7
8
/// Config for customizing the composer.
@@ -13,20 +14,27 @@ public struct ComposerConfig {
13
14
public var inputFont : UIFont
14
15
public var adjustMessageOnSend : ( String ) -> ( String )
15
16
public var adjustMessageOnRead : ( String ) -> ( String )
17
+ public var attachmentPayloadConverter : ( ChatMessage ) -> [ AnyAttachmentPayload ]
16
18
17
19
public init (
18
20
inputViewMinHeight: CGFloat = 38 ,
19
21
inputViewMaxHeight: CGFloat = 76 ,
20
22
inputViewCornerRadius: CGFloat = 20 ,
21
23
inputFont: UIFont = UIFont . preferredFont ( forTextStyle: . body) ,
22
24
adjustMessageOnSend: @escaping ( String ) -> ( String ) = { $0 } ,
23
- adjustMessageOnRead: @escaping ( String ) -> ( String ) = { $0 }
25
+ adjustMessageOnRead: @escaping ( String ) -> ( String ) = { $0 } ,
26
+ attachmentPayloadConverter: @escaping ( ChatMessage ) -> [ AnyAttachmentPayload ] = ComposerConfig . defaultAttachmentPayloadConverter
24
27
) {
25
28
self . inputViewMinHeight = inputViewMinHeight
26
29
self . inputViewMaxHeight = inputViewMaxHeight
27
30
self . inputViewCornerRadius = inputViewCornerRadius
28
31
self . inputFont = inputFont
29
32
self . adjustMessageOnSend = adjustMessageOnSend
30
33
self . adjustMessageOnRead = adjustMessageOnRead
34
+ self . attachmentPayloadConverter = attachmentPayloadConverter
35
+ }
36
+
37
+ public static var defaultAttachmentPayloadConverter : ( ChatMessage ) -> [ AnyAttachmentPayload ] = { message in
38
+ message. allAttachments. toAnyAttachmentPayload ( )
31
39
}
32
40
}
0 commit comments