|
|
|
@ -8,17 +8,28 @@ public enum GalleryDirection {
|
|
|
|
|
case before, after, around
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct MediaGalleryItem: Equatable, Hashable {
|
|
|
|
|
public class MediaGalleryItem: Equatable, Hashable {
|
|
|
|
|
let logTag = "[MediaGalleryItem]"
|
|
|
|
|
|
|
|
|
|
let message: TSMessage
|
|
|
|
|
let attachmentStream: TSAttachmentStream
|
|
|
|
|
let galleryDate: GalleryDate
|
|
|
|
|
|
|
|
|
|
var presentationImage: UIImage?
|
|
|
|
|
|
|
|
|
|
init(message: TSMessage, attachmentStream: TSAttachmentStream) {
|
|
|
|
|
self.message = message
|
|
|
|
|
self.attachmentStream = attachmentStream
|
|
|
|
|
self.galleryDate = GalleryDate(message: message)
|
|
|
|
|
|
|
|
|
|
self.presentationImage = attachmentStream.thumbnailImageLarge(success: { [weak self] (image) in
|
|
|
|
|
guard let strongSelf = self else {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
strongSelf.presentationImage = image
|
|
|
|
|
}, failure: {
|
|
|
|
|
Logger.warn("Could not load presentation image.")
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var isVideo: Bool {
|
|
|
|
@ -38,15 +49,6 @@ public struct MediaGalleryItem: Equatable, Hashable {
|
|
|
|
|
return attachmentStream.thumbnailImageSmall(success: async, failure: {})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var fullSizedImage: UIImage {
|
|
|
|
|
guard let image = attachmentStream.originalImage else {
|
|
|
|
|
owsFail("\(logTag) in \(#function) unexpectedly unable to build attachment image")
|
|
|
|
|
return UIImage()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return image
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: Equatable
|
|
|
|
|
|
|
|
|
|
public static func == (lhs: MediaGalleryItem, rhs: MediaGalleryItem) -> Bool {
|
|
|
|
@ -304,7 +306,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
|
|
|
|
|
|
|
|
|
|
// loadView hasn't necessarily been called yet.
|
|
|
|
|
self.loadViewIfNeeded()
|
|
|
|
|
self.presentationView.image = initialDetailItem.fullSizedImage
|
|
|
|
|
self.presentationView.image = initialDetailItem.presentationImage
|
|
|
|
|
self.applyInitialMediaViewConstraints()
|
|
|
|
|
|
|
|
|
|
// Restore presentationView.alpha in case a previous dismiss left us in a bad state.
|
|
|
|
@ -481,7 +483,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
|
|
|
|
|
// it sits on the screen in the conversation view.
|
|
|
|
|
let changedItems = currentItem != self.initialDetailItem
|
|
|
|
|
if changedItems {
|
|
|
|
|
self.presentationView.image = currentItem.fullSizedImage
|
|
|
|
|
self.presentationView.image = currentItem.presentationImage
|
|
|
|
|
self.applyOffscreenMediaViewConstraints()
|
|
|
|
|
} else {
|
|
|
|
|
self.applyInitialMediaViewConstraints()
|
|
|
|
|