parent
a80cbe79c2
commit
d36e0ad27d
|
@ -19,12 +19,16 @@ class ImageGalleryContentViewController: UIViewController, GalleryContentViewCon
|
|||
let image: UIImage
|
||||
let gifController: GIFController?
|
||||
|
||||
private var imageView: GIFImageView!
|
||||
|
||||
@available(iOS 16.0, macCatalyst 17.0, *)
|
||||
private static let analyzer = ImageAnalyzer()
|
||||
private var _analysisInteraction: AnyObject?
|
||||
@available(iOS 16.0, macCatalyst 17.0, *)
|
||||
private var analysisInteraction: ImageAnalysisInteraction? { _analysisInteraction as? ImageAnalysisInteraction }
|
||||
|
||||
private var isGrayscale = false
|
||||
|
||||
init(url: URL, caption: String?, originalData: Data?, image: UIImage, gifController: GIFController?) {
|
||||
self.url = url
|
||||
self.caption = caption
|
||||
|
@ -44,7 +48,14 @@ class ImageGalleryContentViewController: UIViewController, GalleryContentViewCon
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
let imageView = GIFImageView(image: image)
|
||||
isGrayscale = Preferences.shared.grayscaleImages
|
||||
let maybeGrayscaleImage = if isGrayscale {
|
||||
ImageGrayscalifier.convert(url: url, image: image) ?? image
|
||||
} else {
|
||||
image
|
||||
}
|
||||
|
||||
imageView = GIFImageView(image: maybeGrayscaleImage)
|
||||
imageView.translatesAutoresizingMaskIntoConstraints = false
|
||||
imageView.contentMode = .scaleAspectFit
|
||||
imageView.isUserInteractionEnabled = true
|
||||
|
@ -75,6 +86,8 @@ class ImageGalleryContentViewController: UIViewController, GalleryContentViewCon
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil)
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
|
@ -85,6 +98,20 @@ class ImageGalleryContentViewController: UIViewController, GalleryContentViewCon
|
|||
}
|
||||
}
|
||||
|
||||
@objc private func preferencesChanged() {
|
||||
if isGrayscale != Preferences.shared.grayscaleImages {
|
||||
isGrayscale = Preferences.shared.grayscaleImages
|
||||
let image = if isGrayscale {
|
||||
ImageGrayscalifier.convert(url: url, image: image)
|
||||
} else {
|
||||
image
|
||||
}
|
||||
if let image {
|
||||
imageView.image = image
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: GalleryContentViewController
|
||||
|
||||
var container: (any GalleryVC.GalleryContentViewControllerContainer)?
|
||||
|
|
Loading…
Reference in New Issue