Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display the overlay view when calling swipe function #459

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix
Masataka-n committed May 27, 2021
commit 8c9c4371859fde362032216a1ba512af3861546d
18 changes: 10 additions & 8 deletions Pod/Classes/KolodaView/KolodaView.swift
Original file line number Diff line number Diff line change
@@ -748,30 +748,33 @@ open class KolodaView: UIView, DraggableCardDelegate {

// MARK: Cards managing - Deletion

private func proceedDeletionInRange(_ range: CountableClosedRange<Int>) {
private func proceedDeletionInRange(_ range: CountableClosedRange<Int>, animated: Bool = true) {
let deletionIndexes = [Int](range)
deletionIndexes.sorted { $0 > $1 }.forEach { deletionIndex in
let visibleCardIndex = deletionIndex - currentCardIndex
let card = visibleCards[visibleCardIndex]
card.delegate = nil
card.swipe(.right) {

if animated {
card.delegate = nil
card.swipe(.right) {
}
visibleCards.remove(at: visibleCardIndex)
} else {
removeCards([card])
visibleCards.remove(at: visibleCardIndex)
}
visibleCards.remove(at: visibleCardIndex)
}
}

public func removeCardInIndexRange(_ indexRange: CountableRange<Int>, animated: Bool) {
guard let dataSource = dataSource else {
return
}

animationSemaphore.increment()
let currentItemsCount = countOfCards
countOfCards = dataSource.kolodaNumberOfCards(self)
let visibleIndexes = [Int](indexRange).filter { $0 >= currentCardIndex && $0 < currentCardIndex + countOfVisibleCards }
if !visibleIndexes.isEmpty {
proceedDeletionInRange(visibleIndexes[0]...visibleIndexes[visibleIndexes.count - 1])
proceedDeletionInRange(visibleIndexes[0]...visibleIndexes[visibleIndexes.count - 1], animated: animated)
}
currentCardIndex -= Array(indexRange).filter { $0 < currentCardIndex }.count
loadMissingCards(missingCardsCount())
@@ -781,7 +784,6 @@ open class KolodaView: UIView, DraggableCardDelegate {
card.isUserInteractionEnabled = index == 0
}
animationSemaphore.decrement()

assert(
currentItemsCount - indexRange.count == countOfCards,
"Cards count after update is not equal to data source count"