diff --git a/Sources/Core/Extensions/UICollectionView+RAK.swift b/Sources/Core/Extensions/UICollectionView+RAK.swift index 55e9155..44e75b4 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 ) { @@ -46,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: []) } } ) @@ -58,7 +72,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) } } diff --git a/Sources/Core/Extensions/UITableView+RAK.swift b/Sources/Core/Extensions/UITableView+RAK.swift index b1a72fe..33b38eb 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 ) { @@ -22,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) } ) } 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( 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