forked from shadowfacts/Tusker
Hide live text controls when other gallery controls are hidden
Closes #189
This commit is contained in:
parent
868df25417
commit
bb3e1b44b1
|
@ -14,6 +14,7 @@ import VisionKit
|
||||||
protocol LargeImageContentView: UIView {
|
protocol LargeImageContentView: UIView {
|
||||||
var animationImage: UIImage? { get }
|
var animationImage: UIImage? { get }
|
||||||
var activityItemsForSharing: [Any] { get }
|
var activityItemsForSharing: [Any] { get }
|
||||||
|
func setControlsVisible(_ controlsVisible: Bool)
|
||||||
func grayscaleStateChanged()
|
func grayscaleStateChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +23,9 @@ class LargeImageImageContentView: UIImageView, LargeImageContentView {
|
||||||
#if !targetEnvironment(macCatalyst)
|
#if !targetEnvironment(macCatalyst)
|
||||||
@available(iOS 16.0, *)
|
@available(iOS 16.0, *)
|
||||||
private static let analyzer = ImageAnalyzer()
|
private static let analyzer = ImageAnalyzer()
|
||||||
|
private var _analysisInteraction: AnyObject?
|
||||||
|
@available(iOS 16.0, *)
|
||||||
|
private var analysisInteraction: ImageAnalysisInteraction? { _analysisInteraction as? ImageAnalysisInteraction }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var animationImage: UIImage? { image! }
|
var animationImage: UIImage? { image! }
|
||||||
|
@ -45,6 +49,7 @@ class LargeImageImageContentView: UIImageView, LargeImageContentView {
|
||||||
if #available(iOS 16.0, *),
|
if #available(iOS 16.0, *),
|
||||||
ImageAnalyzer.isSupported {
|
ImageAnalyzer.isSupported {
|
||||||
let interaction = ImageAnalysisInteraction()
|
let interaction = ImageAnalysisInteraction()
|
||||||
|
self._analysisInteraction = interaction
|
||||||
interaction.delegate = self
|
interaction.delegate = self
|
||||||
interaction.preferredInteractionTypes = .automatic
|
interaction.preferredInteractionTypes = .automatic
|
||||||
addInteraction(interaction)
|
addInteraction(interaction)
|
||||||
|
@ -64,6 +69,17 @@ class LargeImageImageContentView: UIImageView, LargeImageContentView {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setControlsVisible(_ controlsVisible: Bool) {
|
||||||
|
#if !targetEnvironment(macCatalyst)
|
||||||
|
if #available(iOS 16.0, *),
|
||||||
|
let analysisInteraction {
|
||||||
|
// note: passing animated: true here doesn't seem to do anything by itself as of iOS 16.2 (20C5032e)
|
||||||
|
// so the LargeImageViewController handles animating, but we still need to pass true here otherwise it doesn't animate
|
||||||
|
analysisInteraction.setSupplementaryInterfaceHidden(!controlsVisible, animated: true)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
func grayscaleStateChanged() {
|
func grayscaleStateChanged() {
|
||||||
guard let data = sourceData else {
|
guard let data = sourceData else {
|
||||||
return
|
return
|
||||||
|
@ -113,6 +129,9 @@ class LargeImageGifContentView: GIFImageView, LargeImageContentView {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setControlsVisible(_ controlsVisible: Bool) {
|
||||||
|
}
|
||||||
|
|
||||||
func grayscaleStateChanged() {
|
func grayscaleStateChanged() {
|
||||||
// todo
|
// todo
|
||||||
}
|
}
|
||||||
|
@ -151,6 +170,9 @@ class LargeImageGifvContentView: GifvAttachmentView, LargeImageContentView {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setControlsVisible(_ controlsVisible: Bool) {
|
||||||
|
}
|
||||||
|
|
||||||
func grayscaleStateChanged() {
|
func grayscaleStateChanged() {
|
||||||
// no-op, GifvAttachmentView observes the grayscale state itself
|
// no-op, GifvAttachmentView observes the grayscale state itself
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,6 +174,7 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate, LargeIma
|
||||||
self.controlsVisible = controlsVisible
|
self.controlsVisible = controlsVisible
|
||||||
if animated {
|
if animated {
|
||||||
UIView.animate(withDuration: 0.2) {
|
UIView.animate(withDuration: 0.2) {
|
||||||
|
self.contentView.setControlsVisible(controlsVisible)
|
||||||
self.updateControlsView()
|
self.updateControlsView()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue