Chatto icon indicating copy to clipboard operation
Chatto copied to clipboard

How to setup, or how to send Avatar Image from url ?

Open toso123 opened this issue 6 years ago • 0 comments

I have issues, sending the avatar image into the MessageViewModel. I have followed the demo example

public func createViewModel(_ textMessage: DemoTextMessageModel) -> DemoTextMessageViewModel { let messageViewModel = self.messageViewModelBuilder.createMessageViewModel(textMessage) let textMessageViewModel = DemoTextMessageViewModel(textMessage: textMessage, messageViewModel: messageViewModel) textMessageViewModel.avatarImage.value = UIImage(named: "userAvatar") return textMessageViewModel }

and created similar func, where i load the images it depends of the incoming or not a try to load the image, but dont know how to send the image/ or the image url

if textMessageViewModel.isIncoming { textMessageViewModel.avatarImage.value = UIImage(named: "default_profile_picture") } else { DispatchQueue.global().async { let data = try? Data(contentsOf: url!) // here i load the url DispatchQueue.main.async { textMessageViewModel.avatarImage.value = UIImage(data: data!) } } }

so any ideas how to send the URL or how to send UIImage direct ? any examples that can help me ?

toso123 avatar Oct 31 '18 16:10 toso123