22// Copyright © 2023 Stream.io Inc. All rights reserved.
33//
44
5+ import StreamChat
56import SwiftUI
67
78/// Config for customizing the composer.
@@ -13,20 +14,27 @@ public struct ComposerConfig {
1314 public var inputFont : UIFont
1415 public var adjustMessageOnSend : ( String ) -> ( String )
1516 public var adjustMessageOnRead : ( String ) -> ( String )
17+ public var attachmentPayloadConverter : ( ChatMessage ) -> [ AnyAttachmentPayload ]
1618
1719 public init (
1820 inputViewMinHeight: CGFloat = 38 ,
1921 inputViewMaxHeight: CGFloat = 76 ,
2022 inputViewCornerRadius: CGFloat = 20 ,
2123 inputFont: UIFont = UIFont . preferredFont ( forTextStyle: . body) ,
2224 adjustMessageOnSend: @escaping ( String ) -> ( String ) = { $0 } ,
23- adjustMessageOnRead: @escaping ( String ) -> ( String ) = { $0 }
25+ adjustMessageOnRead: @escaping ( String ) -> ( String ) = { $0 } ,
26+ attachmentPayloadConverter: @escaping ( ChatMessage ) -> [ AnyAttachmentPayload ] = ComposerConfig . defaultAttachmentPayloadConverter
2427 ) {
2528 self . inputViewMinHeight = inputViewMinHeight
2629 self . inputViewMaxHeight = inputViewMaxHeight
2730 self . inputViewCornerRadius = inputViewCornerRadius
2831 self . inputFont = inputFont
2932 self . adjustMessageOnSend = adjustMessageOnSend
3033 self . adjustMessageOnRead = adjustMessageOnRead
34+ self . attachmentPayloadConverter = attachmentPayloadConverter
35+ }
36+
37+ public static var defaultAttachmentPayloadConverter : ( ChatMessage ) -> [ AnyAttachmentPayload ] = { message in
38+ message. allAttachments. toAnyAttachmentPayload ( )
3139 }
3240}
0 commit comments