Skip to content

Commit

Permalink
fix SwiftLint violations
Browse files Browse the repository at this point in the history
  • Loading branch information
stonko1994 committed Oct 11, 2024
1 parent 8f371b0 commit e0385f1
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -29,13 +29,21 @@ internal class MulticastScrollViewDelegate: NSObject, UIScrollViewDelegate {
callAll { $0.scrollViewWillBeginDragging?(scrollView) }
}

func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
func scrollViewWillEndDragging(
_ scrollView: UIScrollView,
withVelocity velocity: CGPoint,
targetContentOffset: UnsafeMutablePointer<CGPoint>
) {
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)
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e0385f1

Please sign in to comment.