Skip to content
New issue

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

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

Already on GitHub? # 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
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ public class DraggableCardView: UIView, UIGestureRecognizerDelegate {
layer.pop_add(swipeRotationAnimation, forKey: "swipeRotationAnimation")

overlayView?.overlayState = direction
overlayView?.alpha = 1.0
let overlayAlphaAnimation = POPBasicAnimation(propertyNamed: kPOPViewAlpha)
overlayAlphaAnimation?.toValue = 1.0
overlayAlphaAnimation?.duration = cardSwipeActionAnimationDuration
Expand Down
18 changes: 10 additions & 8 deletions Pod/Classes/KolodaView/KolodaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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"
Expand Down