diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index c4a29490..28cadb8a 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1233,7 +1233,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 50; + CURRENT_PROJECT_VERSION = 51; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1270,7 +1270,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 50; + CURRENT_PROJECT_VERSION = 51; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/VDS/Classes/SelfSizingCollectionView.swift b/VDS/Classes/SelfSizingCollectionView.swift index b75e61e4..70ccc083 100644 --- a/VDS/Classes/SelfSizingCollectionView.swift +++ b/VDS/Classes/SelfSizingCollectionView.swift @@ -60,6 +60,10 @@ public final class SelfSizingCollectionView: UICollectionView { // MARK: - Private Methods //-------------------------------------------------- private func setupContentSizeObservation() { + //ensure autoLayout uses intrinsic height + setContentHuggingPriority(.required, for: .vertical) + setContentCompressionResistancePriority(.required, for: .vertical) + // Observing the value of contentSize seems to be the only reliable way to get the contentSize after the collection view lays out its subviews. self.contentSizeObservation = self.observe(\.contentSize, options: [.old, .new]) { [weak self] _, change in // If we don't specify `options: [.old, .new]`, the change.oldValue and .newValue will always be `nil`. diff --git a/VDS/Components/Loader/Loader.swift b/VDS/Components/Loader/Loader.swift index 234246b0..691fed89 100644 --- a/VDS/Components/Loader/Loader.swift +++ b/VDS/Components/Loader/Loader.swift @@ -52,7 +52,7 @@ open class Loader: View { } /// The natural size for the receiving view, considering only properties of the view itself. - open override var intrinsicContentSize: CGSize { .init(width: size, height: size) } + open override var intrinsicContentSize: CGSize { isActive ? .init(width: size, height: size) : .zero } //-------------------------------------------------- // MARK: - Overrides @@ -85,6 +85,7 @@ open class Loader: View { } else { stopAnimating() } + invalidateIntrinsicContentSize() } open override func updateAccessibility() { @@ -96,7 +97,9 @@ open class Loader: View { private let rotationLayerName = "rotationAnimation" private func startAnimating() { accessibilityLabel = "Loading" - + isAccessibilityElement = true + icon.isHidden = false + icon.layer.remove(layerName: rotationLayerName) let rotation : CABasicAnimation = CABasicAnimation(keyPath: "transform.rotation.z") rotation.fromValue = 0 @@ -115,6 +118,8 @@ open class Loader: View { } private func stopAnimating() { + isAccessibilityElement = false + icon.isHidden = true icon.layer.removeAnimation(forKey: rotationLayerName) loadingTimer?.invalidate() loadingTimer = nil diff --git a/VDS/Extensions/UIApplication.swift b/VDS/Extensions/UIApplication.swift index 956bd3d5..13c41d68 100644 --- a/VDS/Extensions/UIApplication.swift +++ b/VDS/Extensions/UIApplication.swift @@ -10,26 +10,36 @@ import UIKit extension UIApplication { - /// Helper method to find the top most viewcontroller in the app - /// - Parameter controller: UIViewController to test against - /// - Returns: Found top most UIViewController - public class func topViewController(controller: UIViewController? = UIApplication.shared.windows.first?.rootViewController) -> UIViewController? { - - if let nav = controller as? UINavigationController { - return topViewController(controller: nav.visibleViewController) + /// Synchronously finds the top most viewcontroller in the app + /// - Parameter controller: Optional UIViewController to start from. If nil, starts from the root view controller. + /// - Returns: The found top most UIViewController + public class func topViewController(controller: UIViewController? = nil) -> UIViewController? { + // Ensure we're on the main thread + guard Thread.isMainThread else { + fatalError("topViewController must be called from the main thread") } - - if let tab = controller as? UITabBarController { - if let selected = tab.selectedViewController { - return topViewController(controller: selected) + + var rootController = controller + + if rootController == nil { + if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, + let rootVC = windowScene.windows.first(where: { $0.isKeyWindow })?.rootViewController { + rootController = rootVC } } - - if let presented = controller?.presentedViewController { + + // Proceed with the logic to find the top view controller + if let nav = rootController as? UINavigationController { + return topViewController(controller: nav.visibleViewController) + } else if let tab = rootController as? UITabBarController, let selected = tab.selectedViewController { + return topViewController(controller: selected) + } else if let presented = rootController?.presentedViewController { return topViewController(controller: presented) } - - return controller + + return rootController } } + + diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index 1b5ac5f0..bf045627 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,3 +1,7 @@ +1.0.51 +---------------- +- ONEAPP-6239 - Loader is still showing when inactive. + 1.0.50 ---------------- - ONEAPP-6239 - Loader doesn't cancel 60 second timer on deallocation.