parent
f2f6eb81f7
commit
8db5649cd5
|
@ -107,10 +107,6 @@ class AttachmentView: GIFImageView {
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadAttachment() {
|
func loadAttachment() {
|
||||||
guard AttachmentsContainerView.supportedAttachmentTypes.contains(attachment.kind) else {
|
|
||||||
fatalError("invalid attachment type")
|
|
||||||
}
|
|
||||||
|
|
||||||
if let hash = attachment.blurHash {
|
if let hash = attachment.blurHash {
|
||||||
AttachmentView.queue.async { [weak self] in
|
AttachmentView.queue.async { [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
@ -142,8 +138,8 @@ class AttachmentView: GIFImageView {
|
||||||
loadAudio()
|
loadAudio()
|
||||||
case .gifv:
|
case .gifv:
|
||||||
loadGifv()
|
loadGifv()
|
||||||
default:
|
case .unknown:
|
||||||
fatalError("invalid attachment type")
|
createUnknownLabel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,6 +297,25 @@ class AttachmentView: GIFImageView {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createUnknownLabel() {
|
||||||
|
backgroundColor = .appSecondaryBackground
|
||||||
|
let label = UILabel()
|
||||||
|
label.text = "Unknown Attachment Type"
|
||||||
|
label.numberOfLines = 0
|
||||||
|
label.textAlignment = .center
|
||||||
|
label.textColor = .secondaryLabel
|
||||||
|
label.font = .preferredFont(forTextStyle: .body)
|
||||||
|
label.adjustsFontForContentSizeCategory = true
|
||||||
|
label.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
addSubview(label)
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
label.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||||
|
label.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||||
|
label.topAnchor.constraint(equalTo: topAnchor),
|
||||||
|
label.bottomAnchor.constraint(equalTo: bottomAnchor),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
private func displayImage() {
|
private func displayImage() {
|
||||||
isGrayscale = Preferences.shared.grayscaleImages
|
isGrayscale = Preferences.shared.grayscaleImages
|
||||||
|
|
|
@ -10,8 +10,6 @@ import UIKit
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
|
|
||||||
class AttachmentsContainerView: UIView {
|
class AttachmentsContainerView: UIView {
|
||||||
|
|
||||||
static let supportedAttachmentTypes = [Attachment.Kind.image, .video, .audio, .gifv]
|
|
||||||
|
|
||||||
weak var delegate: AttachmentViewDelegate?
|
weak var delegate: AttachmentViewDelegate?
|
||||||
|
|
||||||
|
@ -70,7 +68,6 @@ class AttachmentsContainerView: UIView {
|
||||||
// MARK: - User Interaface
|
// MARK: - User Interaface
|
||||||
|
|
||||||
func updateUI(attachments: [Attachment]) {
|
func updateUI(attachments: [Attachment]) {
|
||||||
let attachments = attachments.filter { AttachmentsContainerView.supportedAttachmentTypes.contains($0.kind) }
|
|
||||||
let newTokens = attachments.map { AttachmentToken(attachment: $0) }
|
let newTokens = attachments.map { AttachmentToken(attachment: $0) }
|
||||||
|
|
||||||
guard self.attachmentTokens != newTokens else {
|
guard self.attachmentTokens != newTokens else {
|
||||||
|
|
Loading…
Reference in New Issue