From 19b4be9f1a3251804d6f77125a0ae751583d4023 Mon Sep 17 00:00:00 2001 From: Kazumasa Shimomura Date: Thu, 15 Aug 2024 22:55:38 +0900 Subject: [PATCH] Update: Simplify scroll observer handling in `PanModalPresentationController` - Removed unnecessary `Task` and `@MainActor` wrapping for the scroll view observation - Streamlined code by directly calling `didPanOnScrollView` method if the container view exists - Enhanced readability by reducing indentation and code complexity --- .../PanModalPresentationController.swift | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/PanModal/Controller/PanModalPresentationController.swift b/PanModal/Controller/PanModalPresentationController.swift index 83eeb12..c06890c 100644 --- a/PanModal/Controller/PanModalPresentationController.swift +++ b/PanModal/Controller/PanModalPresentationController.swift @@ -711,15 +711,14 @@ private extension PanModalPresentationController { func observe(scrollView: UIScrollView?) { scrollObserver?.invalidate() scrollObserver = scrollView?.observe(\.contentOffset, options: .old) { [weak self] scrollView, change in - Task { @MainActor [weak self] in - /** - Incase we have a situation where we have two containerViews in the same presentation - */ - guard self?.containerView != nil - else { return } - self?.didPanOnScrollView(scrollView, change: change) - } + /** + Incase we have a situation where we have two containerViews in the same presentation + */ + guard self?.containerView != nil + else { return } + + self?.didPanOnScrollView(scrollView, change: change) } }