Skip to content

Commit

Permalink
Merge pull request #61 from RakuyoKit/feature/2024-07-16
Browse files Browse the repository at this point in the history
Feature/2024 07 16
  • Loading branch information
rakuyoMo authored Jul 16, 2024
2 parents 6240e53 + 8849875 commit 1615e48
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
20 changes: 17 additions & 3 deletions Sources/Core/Extensions/UICollectionView+RAK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand All @@ -46,19 +60,19 @@ 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: [])
}
}
)
}

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)
}
}
Expand Down
22 changes: 18 additions & 4 deletions Sources/Core/Extensions/UITableView+RAK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand All @@ -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)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion Sources/Epoxy/Row/BaseStyledEpoxyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ open class BaseStyledEpoxyView<Style: Hashable>: RAKBase.BaseView, StyledView {

// MARK: Config

override open func config() {
@objc
override open dynamic func config() {
super.config()

translatesAutoresizingMaskIntoConstraints = false
Expand Down

0 comments on commit 1615e48

Please sign in to comment.