forked from shadowfacts/Tusker
parent
c3cf38b0c9
commit
28ee0908d7
|
@ -46,6 +46,13 @@ class CachedImageView: UIImageView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func showOnlyBlurHash(_ blurhash: String, for url: URL) {
|
||||||
|
if url != self.url {
|
||||||
|
self.url = url
|
||||||
|
updateBlurhash(blurhash, for: url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@objc private func preferencesChanged() {
|
@objc private func preferencesChanged() {
|
||||||
if isGrayscale != Preferences.shared.grayscaleImages {
|
if isGrayscale != Preferences.shared.grayscaleImages {
|
||||||
updateImage()
|
updateImage()
|
||||||
|
|
|
@ -30,7 +30,7 @@ class StatusCardView: UIView {
|
||||||
private var titleLabel: UILabel!
|
private var titleLabel: UILabel!
|
||||||
private var descriptionLabel: UILabel!
|
private var descriptionLabel: UILabel!
|
||||||
private var domainLabel: UILabel!
|
private var domainLabel: UILabel!
|
||||||
private var imageView: CachedImageView!
|
private var imageView: StatusCardImageView!
|
||||||
private var placeholderImageView: UIImageView!
|
private var placeholderImageView: UIImageView!
|
||||||
private var leadingSpacer: UIView!
|
private var leadingSpacer: UIView!
|
||||||
private var trailingSpacer: UIView!
|
private var trailingSpacer: UIView!
|
||||||
|
@ -80,7 +80,7 @@ class StatusCardView: UIView {
|
||||||
vStack.alignment = .leading
|
vStack.alignment = .leading
|
||||||
vStack.spacing = 0
|
vStack.spacing = 0
|
||||||
|
|
||||||
imageView = CachedImageView(cache: .attachments)
|
imageView = StatusCardImageView(cache: .attachments)
|
||||||
imageView.contentMode = .scaleAspectFill
|
imageView.contentMode = .scaleAspectFill
|
||||||
imageView.clipsToBounds = true
|
imageView.clipsToBounds = true
|
||||||
|
|
||||||
|
@ -167,7 +167,18 @@ class StatusCardView: UIView {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let image = card.image {
|
if let image = card.image {
|
||||||
|
if status.sensitive {
|
||||||
|
if let blurhash = card.blurhash {
|
||||||
|
imageView.blurImage = false
|
||||||
|
imageView.showOnlyBlurHash(blurhash, for: URL(image)!)
|
||||||
|
} else {
|
||||||
|
// if we don't have a blurhash, load the image and show it behind a blur
|
||||||
|
imageView.blurImage = true
|
||||||
|
imageView.update(for: URL(image), blurhash: nil)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
imageView.update(for: URL(image), blurhash: card.blurhash)
|
imageView.update(for: URL(image), blurhash: card.blurhash)
|
||||||
|
}
|
||||||
imageView.isHidden = false
|
imageView.isHidden = false
|
||||||
leadingSpacer.isHidden = true
|
leadingSpacer.isHidden = true
|
||||||
} else {
|
} else {
|
||||||
|
@ -257,3 +268,25 @@ extension StatusCardView: UIContextMenuInteractionDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class StatusCardImageView: CachedImageView {
|
||||||
|
@Lazy private var blurView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))
|
||||||
|
var blurImage = false {
|
||||||
|
didSet {
|
||||||
|
if blurImage {
|
||||||
|
if !_blurView.isInitialized {
|
||||||
|
blurView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
addSubview(blurView)
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
blurView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||||
|
blurView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||||
|
blurView.topAnchor.constraint(equalTo: topAnchor),
|
||||||
|
blurView.bottomAnchor.constraint(equalTo: bottomAnchor),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_blurView.valueIfInitialized?.removeFromSuperview()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue