From b700e17d7ec40a50f5bc955a7377ff9be9bdf95b Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 25 Nov 2024 21:09:32 -0500 Subject: [PATCH] Hide video controls in gallery if loading fails Closes #546 --- .../Content/VideoGalleryContentViewController.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Packages/GalleryVC/Sources/GalleryVC/Content/VideoGalleryContentViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/Content/VideoGalleryContentViewController.swift index bcc85732..8d5488ee 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/Content/VideoGalleryContentViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/Content/VideoGalleryContentViewController.swift @@ -20,6 +20,7 @@ open class VideoGalleryContentViewController: UIViewController, GalleryContentVi private var statusObservation: NSKeyValueObservation? private var rateObservation: NSKeyValueObservation? private var hideControlsWorkItem: DispatchWorkItem? + private var isShowingError = false public init(url: URL, caption: String?) { self.url = url @@ -90,12 +91,15 @@ open class VideoGalleryContentViewController: UIViewController, GalleryContentVi self.container?.setGalleryContentLoading(false) self.showErrorView(error) self.statusObservation = nil + self.overlayVC.setVisible(false) } } }) } private func showErrorView(_ error: any Error) { + isShowingError = true + let image = UIImageView(image: UIImage(systemName: "exclamationmark.triangle.fill")!) image.tintColor = .secondaryLabel image.contentMode = .scaleAspectFit @@ -158,7 +162,7 @@ open class VideoGalleryContentViewController: UIViewController, GalleryContentVi } public var presentationAnimation: GalleryContentPresentationAnimation { - .fromSourceViewWithoutSnapshot + isShowingError ? .fade : .fromSourceViewWithoutSnapshot } private lazy var overlayVC = VideoOverlayViewController(player: player) @@ -169,7 +173,9 @@ open class VideoGalleryContentViewController: UIViewController, GalleryContentVi public private(set) lazy var bottomControlsAccessoryViewController: UIViewController? = VideoControlsViewController(player: player) public func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool) { - overlayVC.setVisible(visible) + if !isShowingError { + overlayVC.setVisible(visible) + } if !visible { hideControlsWorkItem?.cancel()