From e156a978618535384849594188169736ff9fbb9f Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 4 Feb 2024 11:52:48 -0500 Subject: [PATCH] visionOS: Don't use gallery VC transition --- Tusker/Extensions/UIViewController+Delegates.swift | 2 ++ Tusker/Screens/Utilities/CustomAlertController.swift | 12 ++++++++++++ Tusker/TuskerNavigationDelegate.swift | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/Tusker/Extensions/UIViewController+Delegates.swift b/Tusker/Extensions/UIViewController+Delegates.swift index 0bfa53e5c2..03e8e24a9a 100644 --- a/Tusker/Extensions/UIViewController+Delegates.swift +++ b/Tusker/Extensions/UIViewController+Delegates.swift @@ -6,6 +6,7 @@ // Copyright © 2018 Shadowfacts. All rights reserved. // +#if !os(visionOS) import UIKit extension UIViewController: UIViewControllerTransitioningDelegate { @@ -34,3 +35,4 @@ extension UIViewController: UIViewControllerTransitioningDelegate { return nil } } +#endif diff --git a/Tusker/Screens/Utilities/CustomAlertController.swift b/Tusker/Screens/Utilities/CustomAlertController.swift index 58bd2429ec..1eae7befa4 100644 --- a/Tusker/Screens/Utilities/CustomAlertController.swift +++ b/Tusker/Screens/Utilities/CustomAlertController.swift @@ -470,6 +470,17 @@ class CustomAlertActionButton: UIControl { } } +#if os(visionOS) +extension CustomAlertController: UIViewControllerTransitioningDelegate { + func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { + return CustomAlertPresentationAnimation() + } + + func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { + return CustomAlertDismissAnimation() + } +} +#else extension CustomAlertController { override func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { return CustomAlertPresentationAnimation() @@ -479,6 +490,7 @@ extension CustomAlertController { return CustomAlertDismissAnimation() } } +#endif class CustomAlertPresentationAnimation: NSObject, UIViewControllerAnimatedTransitioning { func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { diff --git a/Tusker/TuskerNavigationDelegate.swift b/Tusker/TuskerNavigationDelegate.swift index eb3be9c0cb..5de7f56777 100644 --- a/Tusker/TuskerNavigationDelegate.swift +++ b/Tusker/TuskerNavigationDelegate.swift @@ -129,13 +129,17 @@ extension TuskerNavigationDelegate { func showLoadingLargeImage(url: URL, cache: ImageCache, description: String?, animatingFrom sourceView: UIImageView) { let vc = LoadingLargeImageViewController(url: url, cache: cache, imageDescription: description) vc.animationSourceView = sourceView + #if !os(visionOS) vc.transitioningDelegate = self + #endif present(vc, animated: true) } func gallery(attachments: [Attachment], sourceViews: [UIImageView?], startIndex: Int) -> GalleryViewController { let vc = GalleryViewController(attachments: attachments, sourceViews: sourceViews, startIndex: startIndex) + #if !os(visionOS) vc.transitioningDelegate = self + #endif return vc }