From 093bd758714493d5209ad6e61fc3d531fec0e17d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 5 Jan 2024 12:45:24 -0600 Subject: [PATCH 1/5] ONEAPP-6239 - Loader isActive still showing when false with accessibility Signed-off-by: Matt Bruce --- VDS/Components/Loader/Loader.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/VDS/Components/Loader/Loader.swift b/VDS/Components/Loader/Loader.swift index 234246b0..e10c60b1 100644 --- a/VDS/Components/Loader/Loader.swift +++ b/VDS/Components/Loader/Loader.swift @@ -96,7 +96,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 +117,8 @@ open class Loader: View { } private func stopAnimating() { + isAccessibilityElement = false + icon.isHidden = true icon.layer.removeAnimation(forKey: rotationLayerName) loadingTimer?.invalidate() loadingTimer = nil From 2f57d8ebad0be6ded0f6839d89102b024ad57fa3 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 8 Jan 2024 12:31:56 -0600 Subject: [PATCH 2/5] updated intrinsic size Signed-off-by: Matt Bruce --- VDS/Components/Loader/Loader.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/VDS/Components/Loader/Loader.swift b/VDS/Components/Loader/Loader.swift index e10c60b1..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() { From 46e2876f071a9067219d4b4b32759827adcc261f Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 8 Jan 2024 12:33:18 -0600 Subject: [PATCH 3/5] updated version Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- VDS/SupportingFiles/ReleaseNotes.txt | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) 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/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. From 22f156d461eaf55612aa297ad910cc1cd246e406 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 8 Jan 2024 17:00:57 -0600 Subject: [PATCH 4/5] fixed bug in topViewController Signed-off-by: Matt Bruce --- VDS/Extensions/UIApplication.swift | 40 +++++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) 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 } } + + From b58cfbe1753a2d25322c4bb9738e09f13e420d0c Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 24 Jan 2024 16:50:58 -0600 Subject: [PATCH 5/5] added contentHugging and compressionResistance Signed-off-by: Matt Bruce --- VDS/Classes/SelfSizingCollectionView.swift | 4 ++++ 1 file changed, 4 insertions(+) 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`.