From e0385f1738d14c40523631eeaf5ad1053c29cf82 Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Fri, 11 Oct 2024 14:44:06 -0600 Subject: [PATCH] fix SwiftLint violations --- .../Helper/MulticastScrollViewDelegate.swift | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Sources/SimultaneouslyScrollView/Helper/MulticastScrollViewDelegate.swift b/Sources/SimultaneouslyScrollView/Helper/MulticastScrollViewDelegate.swift index b91caf5..e7ad874 100644 --- a/Sources/SimultaneouslyScrollView/Helper/MulticastScrollViewDelegate.swift +++ b/Sources/SimultaneouslyScrollView/Helper/MulticastScrollViewDelegate.swift @@ -13,7 +13,7 @@ internal class MulticastScrollViewDelegate: NSObject, UIScrollViewDelegate { delegates.remove(delegate) } - func callAll(_ closure: (_ delegate: UIScrollViewDelegate) -> ()) { + func callAll(_ closure: (_ delegate: UIScrollViewDelegate) -> Void) { delegates.allObjects.forEach(closure) } @@ -29,13 +29,21 @@ internal class MulticastScrollViewDelegate: NSObject, UIScrollViewDelegate { callAll { $0.scrollViewWillBeginDragging?(scrollView) } } - func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer) { + func scrollViewWillEndDragging( + _ scrollView: UIScrollView, + withVelocity velocity: CGPoint, + targetContentOffset: UnsafeMutablePointer + ) { let originalTargetContentOffset = targetContentOffset.pointee var proposedOffsets: [CGPoint] = [] for delegate in delegates.allObjects { targetContentOffset.pointee = originalTargetContentOffset - delegate.scrollViewWillEndDragging?(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset) + delegate.scrollViewWillEndDragging?( + scrollView, + withVelocity: velocity, + targetContentOffset: targetContentOffset + ) proposedOffsets.append(targetContentOffset.pointee) } @@ -78,8 +86,7 @@ internal class MulticastScrollViewDelegate: NSObject, UIScrollViewDelegate { func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool { delegates.allObjects - .compactMap { $0.scrollViewShouldScrollToTop?(scrollView) } - .reduce(true, { $0 && $1 }) + .allSatisfy { $0.scrollViewShouldScrollToTop?(scrollView) ?? true } } func scrollViewDidScrollToTop(_ scrollView: UIScrollView) {