11//
2- // Copyright © 2021 Stream.io Inc. All rights reserved.
2+ // Copyright © 2021 Stream.io Inc. All rights reserved.
33//
44
55import Foundation
66import StreamChat
7- import SwiftUI
87import StreamChatSwiftUI
8+ import SwiftUI
99
1010extension AttachmentType {
1111 static let contact = Self ( rawValue: " contact " )
1212}
1313
1414struct ContactAttachmentPayload : AttachmentPayload {
1515 static let type : AttachmentType = . contact
16-
16+
1717 let name : String
1818 let phoneNumber : String
1919}
@@ -23,7 +23,6 @@ extension ContactAttachmentPayload: Identifiable {
2323 var id : String {
2424 " \( name) - \( phoneNumber) "
2525 }
26-
2726}
2827
2928class CustomAttachmentsFactory : ViewFactory {
@@ -108,16 +107,14 @@ class CustomAttachmentsFactory: ViewFactory {
108107 onCustomAttachmentTap: onCustomAttachmentTap
109108 )
110109 }
111-
112110}
113111
114112class CustomMessageTypeResolver : MessageTypeResolving {
115113
116114 func hasCustomAttachment( message: ChatMessage ) -> Bool {
117115 let contactAttachments = message. attachments ( payloadType: ContactAttachmentPayload . self)
118- return contactAttachments. count > 0
116+ return ! contactAttachments. isEmpty
119117 }
120-
121118}
122119
123120struct CustomAttachmentSourcePickerView : View {
@@ -163,7 +160,6 @@ struct CustomAttachmentSourcePickerView: View {
163160 . frame ( height: 56 )
164161 . background ( Color ( colors. background1) )
165162 }
166-
167163}
168164
169165struct CustomContactAttachmentView : View {
@@ -174,7 +170,7 @@ struct CustomContactAttachmentView: View {
174170 let contacts : [ CustomAttachment ]
175171 let addedContacts : [ CustomAttachment ]
176172 var onCustomAttachmentTap : ( CustomAttachment ) -> Void
177-
173+
178174 var body : some View {
179175 AttachmentTypeContainer {
180176 VStack ( alignment: . leading) {
@@ -202,7 +198,6 @@ struct CustomContactAttachmentView: View {
202198 }
203199 }
204200 }
205-
206201}
207202
208203struct CustomContactAttachmentComposerPreview : View {
@@ -239,7 +234,6 @@ struct CustomContactAttachmentComposerPreview: View {
239234 }
240235 }
241236 }
242-
243237}
244238
245239struct CustomContactAttachmentPreview : View {
@@ -252,7 +246,7 @@ struct CustomContactAttachmentPreview: View {
252246 var onCustomAttachmentTap : ( CustomAttachment ) -> Void
253247 var isAttachmentSelected : Bool
254248 var hasSpacing = true
255-
249+
256250 var body : some View {
257251 Button {
258252 withAnimation {
@@ -283,8 +277,6 @@ struct CustomContactAttachmentPreview: View {
283277 . foregroundColor ( Color ( colors. textLowEmphasis) )
284278 }
285279 }
286-
287280 }
288281 }
289-
290282}
0 commit comments