Commit 0bb45ffc authored by Quentin Muret's avatar Quentin Muret Committed by Andreas Traczyk

display images in the conversation page: improve performance and bug fix

- the app is now fluid when scrolling a conversation with images
- fix app bug that didn't display correctly images

Change-Id: I80f679b42f242f192e9d9454afb54f7602b872ad
parent 12173e78
......@@ -389,7 +389,7 @@ class MessageCell: UITableViewCell, NibReusable {
if let image = message.getTransferedImage(maxSize: maxDimsion, conversationID: conversationID) {
self.transferImageView.image = image
let newSize = self.transferImageView.image?.getNewSize(of: defaultSize)
let xOriginImageSend = self.bubble.bounds.size.width - (newSize?.width)!
let xOriginImageSend = screenWidth - 112 - (newSize?.width)!
if message.bubblePosition() == .sent {
self.transferImageView.frame = CGRect(x: xOriginImageSend, y: 0, width: ((newSize?.width ?? 200)), height: ((newSize?.height ?? 200)))
} else if message.bubblePosition() == .received {
......
......@@ -178,7 +178,8 @@ public final class DataTransferService: DataTransferAdapterDelegate {
guard let asset = PHAsset.fetchAssets(withLocalIdentifiers: [identifier], options: PHFetchOptions()).firstObject else {
return photo
}
imageManager.requestImage(for: asset, targetSize: CGSize(width: maxSize, height: maxSize * 2), contentMode: .aspectFit, options: requestOptions, resultHandler: {(result, _) -> Void in
imageManager.requestImage(for: asset, targetSize: CGSize(width: maxSize, height: maxSize), contentMode: .aspectFit, options: requestOptions, resultHandler: {(result, _) -> Void in
self.transferedImages[identifier] = (true, result!)
photo = result!
})
return photo
......@@ -201,10 +202,10 @@ public final class DataTransferService: DataTransferAdapterDelegate {
if fileExtension as String == "gif" {
let image = UIImage.gifImageWithUrl(pathUrl)
return image
} else {
let image = UIImage(contentsOfFile: pathUrl.path)
return image
}
let image = UIImage(contentsOfFile: pathUrl.path)
self.transferedImages[conversationID + name] = (true, image)
return image
}
} else {
self.transferedImages[conversationID + name] = (false, nil)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment