mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-09 12:56:15 +10:00
show DiscoveredAttachment's image if it isTemporary
This commit is contained in:
@@ -2778,6 +2778,10 @@ struct DiscoveredAttachment {
|
||||
|
||||
var image: UIImage?
|
||||
|
||||
var isTemporary: Bool {
|
||||
return image != nil
|
||||
}
|
||||
|
||||
var thumbnailImage: UIImage? {
|
||||
|
||||
guard (metadata as NSString).length > 0 else {
|
||||
|
||||
@@ -585,7 +585,7 @@ class NewFeedViewController: SegueViewController {
|
||||
// resize to smaller, not need fixRotation
|
||||
|
||||
if let image = image.resizeToSize(fixedSize, withInterpolationQuality: .Medium) {
|
||||
return DiscoveredAttachment(metadata: "", URLString: "", image: nil)
|
||||
return DiscoveredAttachment(metadata: "", URLString: "", image: image)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -71,8 +71,13 @@ class FeedBiggerImageCell: FeedBasicCell {
|
||||
}
|
||||
|
||||
if let onlyAttachment = feed.imageAttachments?.first {
|
||||
biggerImageView.yep_showActivityIndicatorWhenLoading = true
|
||||
biggerImageView.yep_setImageOfAttachment(onlyAttachment, withSize: YepConfig.FeedBiggerImageCell.imageSize)
|
||||
if onlyAttachment.isTemporary {
|
||||
biggerImageView.image = onlyAttachment.image
|
||||
|
||||
} else {
|
||||
biggerImageView.yep_showActivityIndicatorWhenLoading = true
|
||||
biggerImageView.yep_setImageOfAttachment(onlyAttachment, withSize: YepConfig.FeedBiggerImageCell.imageSize)
|
||||
}
|
||||
}
|
||||
|
||||
if layoutCache.layout == nil {
|
||||
|
||||
@@ -112,8 +112,14 @@ class FeedNormalImagesCell: FeedBasicCell {
|
||||
for i in 0..<imageViews.count {
|
||||
|
||||
if let attachment = attachments[safe: i] {
|
||||
imageViews[i].yep_showActivityIndicatorWhenLoading = true
|
||||
imageViews[i].yep_setImageOfAttachment(attachment, withSize: YepConfig.FeedNormalImagesCell.imageSize)
|
||||
|
||||
if attachment.isTemporary {
|
||||
imageViews[i].image = attachment.image
|
||||
|
||||
} else {
|
||||
imageViews[i].yep_showActivityIndicatorWhenLoading = true
|
||||
imageViews[i].yep_setImageOfAttachment(attachment, withSize: YepConfig.FeedNormalImagesCell.imageSize)
|
||||
}
|
||||
|
||||
imageViews[i].hidden = false
|
||||
|
||||
|
||||
@@ -38,10 +38,15 @@ class FeedMediaCell: UICollectionViewCell {
|
||||
|
||||
func configureWithAttachment(attachment: DiscoveredAttachment, bigger: Bool) {
|
||||
|
||||
let size = bigger ? feedAttachmentBiggerImageSize : feedAttachmentImageSize
|
||||
if attachment.isTemporary {
|
||||
imageView.image = attachment.image
|
||||
|
||||
imageView.yep_showActivityIndicatorWhenLoading = true
|
||||
imageView.yep_setImageOfAttachment(attachment, withSize: size)
|
||||
} else {
|
||||
let size = bigger ? feedAttachmentBiggerImageSize : feedAttachmentImageSize
|
||||
|
||||
imageView.yep_showActivityIndicatorWhenLoading = true
|
||||
imageView.yep_setImageOfAttachment(attachment, withSize: size)
|
||||
}
|
||||
|
||||
deleteImageView.hidden = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user