From 159b7ed3b1fa87dc17a0035e8951770e127be149 Mon Sep 17 00:00:00 2001 From: Rakuyo Date: Tue, 16 Jul 2024 17:00:46 +0800 Subject: [PATCH 1/5] fix: Fix the definition domain error of config in subclass --- Sources/Epoxy/Row/BaseStyledEpoxyView.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/Epoxy/Row/BaseStyledEpoxyView.swift b/Sources/Epoxy/Row/BaseStyledEpoxyView.swift index 9fe7cce..8bc82ef 100644 --- a/Sources/Epoxy/Row/BaseStyledEpoxyView.swift +++ b/Sources/Epoxy/Row/BaseStyledEpoxyView.swift @@ -29,7 +29,8 @@ open class BaseStyledEpoxyView: RAKBase.BaseView, StyledView { // MARK: Config - override open func config() { + @objc + override open dynamic func config() { super.config() translatesAutoresizingMaskIntoConstraints = false From 660ddfc48c24237945801d2bbcb481c62f2fa530 Mon Sep 17 00:00:00 2001 From: Rakuyo Date: Tue, 16 Jul 2024 17:01:30 +0800 Subject: [PATCH 2/5] feat: Allow passing `nil` to `edgeInsets` --- .../CollectionView/Layout/LayoutImplement/Layout+List.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Epoxy/CollectionView/Layout/LayoutImplement/Layout+List.swift b/Sources/Epoxy/CollectionView/Layout/LayoutImplement/Layout+List.swift index 3f178e1..7d83f97 100644 --- a/Sources/Epoxy/CollectionView/Layout/LayoutImplement/Layout+List.swift +++ b/Sources/Epoxy/CollectionView/Layout/LayoutImplement/Layout+List.swift @@ -37,7 +37,7 @@ extension Extendable where Base: Layout.Section { header: SupplementaryItem.Style? = nil, footer: SupplementaryItem.Style? = nil, decoration: DecorationStyle? = nil, - edgeInsets: SectionEdgeInsets + edgeInsets: SectionEdgeInsets? ) -> Base { custom( layoutEnvironment: environment, @@ -78,7 +78,7 @@ extension Extendable where Base: Layout.Compositional { header: SupplementaryItem.Style? = nil, footer: SupplementaryItem.Style? = nil, decoration: DecorationStyle? = nil, - edgeInsets: SectionEdgeInsets, + edgeInsets: SectionEdgeInsets?, configuration: Layout.CompositionalConfiguration? = nil ) -> Base { let sectionProvider: Layout.CompositionalSectionProvider = { _, environment in @@ -121,7 +121,7 @@ extension SectionProviderWrapper { header: SupplementaryItem.Style? = nil, footer: SupplementaryItem.Style? = nil, decoration: DecorationStyle? = nil, - edgeInsets: SectionEdgeInsets + edgeInsets: SectionEdgeInsets? ) -> Self { .init { Layout.Section.rak.list( From 4e171e196d8788a23c519b420d5cbd113350299b Mon Sep 17 00:00:00 2001 From: Rakuyo Date: Tue, 16 Jul 2024 17:02:31 +0800 Subject: [PATCH 3/5] fix: Fixed the issue where the `animated` parameter was not passed correctly --- Sources/Core/Extensions/UICollectionView+RAK.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Core/Extensions/UICollectionView+RAK.swift b/Sources/Core/Extensions/UICollectionView+RAK.swift index 55e9155..7fae953 100644 --- a/Sources/Core/Extensions/UICollectionView+RAK.swift +++ b/Sources/Core/Extensions/UICollectionView+RAK.swift @@ -58,7 +58,7 @@ extension Extendable where Base: UICollectionView { private func deselectItems(at selectedIndexPaths: [IndexPath], animated: Bool) { for selectedIndexPath in selectedIndexPaths { - base.deselectItem(at: selectedIndexPath, animated: true) + base.deselectItem(at: selectedIndexPath, animated: animated) base.delegate?.collectionView?(base, didDeselectItemAt: selectedIndexPath) } } From ce3c406bf9c5b4f3eb3d8dd2921cbf105fd00bcb Mon Sep 17 00:00:00 2001 From: Rakuyo Date: Tue, 16 Jul 2024 17:02:59 +0800 Subject: [PATCH 4/5] feat: Allow delayed unselection of cells --- Sources/Core/Extensions/UICollectionView+RAK.swift | 14 ++++++++++++++ Sources/Core/Extensions/UITableView+RAK.swift | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Sources/Core/Extensions/UICollectionView+RAK.swift b/Sources/Core/Extensions/UICollectionView+RAK.swift index 7fae953..475ebc4 100644 --- a/Sources/Core/Extensions/UICollectionView+RAK.swift +++ b/Sources/Core/Extensions/UICollectionView+RAK.swift @@ -32,6 +32,20 @@ extension Extendable where Base: UICollectionView { extension Extendable where Base: UICollectionView { public func deselectRowIfNeeded( + with transitionCoordinator: UIViewControllerTransitionCoordinator? = nil, + animated: Bool = true, + after deadline: DispatchTime? = nil + ) { + if let deadline { + DispatchQueue.main.asyncAfter(deadline: deadline) { + deselectRowIfNeeded(with: transitionCoordinator, animated: animated) + } + } else { + deselectRowIfNeeded(with: transitionCoordinator, animated: animated) + } + } + + private func deselectRowIfNeeded( with transitionCoordinator: UIViewControllerTransitionCoordinator?, animated: Bool ) { diff --git a/Sources/Core/Extensions/UITableView+RAK.swift b/Sources/Core/Extensions/UITableView+RAK.swift index b1a72fe..f0c6ac6 100644 --- a/Sources/Core/Extensions/UITableView+RAK.swift +++ b/Sources/Core/Extensions/UITableView+RAK.swift @@ -11,6 +11,20 @@ import UIKit extension Extendable where Base: UITableView { public func deselectRowIfNeeded( + with transitionCoordinator: UIViewControllerTransitionCoordinator? = nil, + animated: Bool = true, + after deadline: DispatchTime? = nil + ) { + if let deadline { + DispatchQueue.main.asyncAfter(deadline: deadline) { + deselectRowIfNeeded(with: transitionCoordinator, animated: animated) + } + } else { + deselectRowIfNeeded(with: transitionCoordinator, animated: animated) + } + } + + private func deselectRowIfNeeded( with transitionCoordinator: UIViewControllerTransitionCoordinator?, animated: Bool ) { From 884987507cb223ea5109a0286547302042e9ecbd Mon Sep 17 00:00:00 2001 From: Rakuyo Date: Tue, 16 Jul 2024 17:03:13 +0800 Subject: [PATCH 5/5] feat: test update --- Sources/Core/Extensions/UICollectionView+RAK.swift | 4 ++-- Sources/Core/Extensions/UITableView+RAK.swift | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/Core/Extensions/UICollectionView+RAK.swift b/Sources/Core/Extensions/UICollectionView+RAK.swift index 475ebc4..44e75b4 100644 --- a/Sources/Core/Extensions/UICollectionView+RAK.swift +++ b/Sources/Core/Extensions/UICollectionView+RAK.swift @@ -60,11 +60,11 @@ extension Extendable where Base: UICollectionView { alongsideTransition: { _ in deselectItems(at: selectedIndexPaths, animated: true) }, - completion: { context in + completion: { [weak base] context in guard context.isCancelled else { return } for selectedIndexPath in selectedIndexPaths { - base.selectItem(at: selectedIndexPath, animated: false, scrollPosition: []) + base?.selectItem(at: selectedIndexPath, animated: false, scrollPosition: []) } } ) diff --git a/Sources/Core/Extensions/UITableView+RAK.swift b/Sources/Core/Extensions/UITableView+RAK.swift index f0c6ac6..33b38eb 100644 --- a/Sources/Core/Extensions/UITableView+RAK.swift +++ b/Sources/Core/Extensions/UITableView+RAK.swift @@ -36,12 +36,12 @@ extension Extendable where Base: UITableView { } coordinator.animate( - alongsideTransition: { _ in - base.deselectRow(at: selectedIndexPath, animated: true) + alongsideTransition: { [weak base] _ in + base?.deselectRow(at: selectedIndexPath, animated: true) }, - completion: { context in + completion: { [weak base] context in guard context.isCancelled else { return } - base.selectRow(at: selectedIndexPath, animated: false, scrollPosition: .none) + base?.selectRow(at: selectedIndexPath, animated: false, scrollPosition: .none) } ) }