Update Feeds to use higher resolution images when available. Issue #1208

This commit is contained in:
Maurice Parker
2019-10-28 20:57:26 -05:00
parent 55b9310f9c
commit 66b6d43408
4 changed files with 56 additions and 34 deletions

View File

@@ -14,11 +14,30 @@ final class MasterTimelineAvatarView: UIView {
didSet {
if image !== oldValue {
imageView.image = image
setNeedsLayout()
if self.traitCollection.userInterfaceStyle == .dark {
DispatchQueue.global(qos: .background).async {
if self.image?.isDark() ?? false {
DispatchQueue.main.async {
self.isDisconcernable = false
self.setNeedsLayout()
}
} else {
DispatchQueue.main.async {
self.isDisconcernable = true
self.setNeedsLayout()
}
}
}
} else {
self.setNeedsLayout()
}
}
}
}
private var isDisconcernable = true
private let imageView: UIImageView = {
let imageView = NonIntrinsicImageView(image: AppAssets.faviconTemplateImage)
imageView.contentMode = .scaleAspectFit
@@ -27,10 +46,14 @@ final class MasterTimelineAvatarView: UIView {
return imageView
}()
private var hasExposedVerticalBackground: Bool {
private var isVerticalBackgroundExposed: Bool {
return imageView.frame.size.height < bounds.size.height
}
private var isSymbolImage: Bool {
return imageView.image?.isSymbolImage ?? false
}
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
@@ -51,7 +74,7 @@ final class MasterTimelineAvatarView: UIView {
override func layoutSubviews() {
imageView.setFrameIfNotEqual(rectForImageView())
if hasExposedVerticalBackground {
if (isVerticalBackgroundExposed && !isSymbolImage) || !isDisconcernable {
backgroundColor = AppAssets.avatarBackgroundColor
} else {
backgroundColor = nil