diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..5449bc82 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,43 @@ +# Report + +> The more information you provide, the faster we can help you. + +⚠️ Select what you want - **a feature request** or **report a bug**. Please remove the section you aren't interested in. + +## A feature request + +### What do you want to add? + +> Please describe what you want to add to the component. + +### How should it look like? + +> Please add images. + +## Report a bug + +### What did you do? + +> Please replace this with what you did. + +### What did you expect to happen? + +> Please replace this with what you expected to happen. + +### What happened instead? + +> Please replace this with what happened instead. + +### Your Environment + +- Version of the component: _insert here_ +- Swift version: _insert here_ +- iOS version: _insert here_ +- Device: _insert here_ +- Xcode version: _insert here_ +- If you use Cocoapods: _run `pod env | pbcopy` and insert here_ +- If you use Carthage: _run `carthage version | pbcopy` and insert here_ + +### Project that demonstrates the bug + +> Please add a link to a project we can download that reproduces the bug. diff --git a/Example/Koloda.xcodeproj/project.pbxproj b/Example/Koloda.xcodeproj/project.pbxproj index 542ba221..6b5d8441 100644 --- a/Example/Koloda.xcodeproj/project.pbxproj +++ b/Example/Koloda.xcodeproj/project.pbxproj @@ -143,12 +143,12 @@ isa = PBXNativeTarget; buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "Koloda_Example" */; buildPhases = ( - 0182469EE898CFC3334C577B /* Check Pods Manifest.lock */, + 0182469EE898CFC3334C577B /* [CP] Check Pods Manifest.lock */, 607FACCC1AFB9204008FA782 /* Sources */, 607FACCD1AFB9204008FA782 /* Frameworks */, 607FACCE1AFB9204008FA782 /* Resources */, - 64922D3147424C142700ED20 /* Embed Pods Frameworks */, - 822E414921E8C1E4C57072A9 /* Copy Pods Resources */, + 64922D3147424C142700ED20 /* [CP] Embed Pods Frameworks */, + 822E414921E8C1E4C57072A9 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -209,29 +209,29 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 0182469EE898CFC3334C577B /* Check Pods Manifest.lock */ = { + 0182469EE898CFC3334C577B /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "[CP] Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - 64922D3147424C142700ED20 /* Embed Pods Frameworks */ = { + 64922D3147424C142700ED20 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Embed Pods Frameworks"; + name = "[CP] Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -239,14 +239,14 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Koloda_Example/Pods-Koloda_Example-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 822E414921E8C1E4C57072A9 /* Copy Pods Resources */ = { + 822E414921E8C1E4C57072A9 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy Pods Resources"; + name = "[CP] Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Example/Koloda/BackgroundAnimationViewController.swift b/Example/Koloda/BackgroundAnimationViewController.swift index 2657bbad..def91ff4 100644 --- a/Example/Koloda/BackgroundAnimationViewController.swift +++ b/Example/Koloda/BackgroundAnimationViewController.swift @@ -35,11 +35,11 @@ class BackgroundAnimationViewController: UIViewController { //MARK: IBActions @IBAction func leftButtonTapped() { - kolodaView?.swipe(SwipeResultDirection.left) + kolodaView?.swipe(.left) } @IBAction func rightButtonTapped() { - kolodaView?.swipe(SwipeResultDirection.right) + kolodaView?.swipe(.right) } @IBAction func undoButtonTapped() { diff --git a/Koloda.xcodeproj/project.pbxproj b/Koloda.xcodeproj/project.pbxproj index 8526cd75..69eda9da 100644 --- a/Koloda.xcodeproj/project.pbxproj +++ b/Koloda.xcodeproj/project.pbxproj @@ -14,7 +14,6 @@ C517E4F21D9D00520002D88F /* KolodaViewAnimatior.swift in Sources */ = {isa = PBXBuildFile; fileRef = C517E4E81D9D00520002D88F /* KolodaViewAnimatior.swift */; }; C517E4F31D9D00520002D88F /* OverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C517E4EA1D9D00520002D88F /* OverlayView.swift */; }; C517E4F41D9D00520002D88F /* SwipeResultDirection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C517E4EB1D9D00520002D88F /* SwipeResultDirection.swift */; }; - C517E4F91D9D01920002D88F /* pop.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C517E4F81D9D01920002D88F /* pop.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -35,7 +34,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C517E4F91D9D01920002D88F /* pop.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -144,7 +142,6 @@ C517E4A71D9CF9010002D88F /* Frameworks */, C517E4A81D9CF9010002D88F /* Headers */, C517E4A91D9CF9010002D88F /* Resources */, - C517E4F61D9D01120002D88F /* Carthage */, ); buildRules = ( ); @@ -197,24 +194,6 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - C517E4F61D9D01120002D88F /* Carthage */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "$(SRCROOT)/Carthage/Build/iOS/pop.framework", - ); - name = Carthage; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/usr/local/bin/carthage copy-frameworks"; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ C517E4A61D9CF9010002D88F /* Sources */ = { isa = PBXSourcesBuildPhase; diff --git a/LICENSE b/LICENSE index 01ace4b9..f10f992c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 Yalantis +Copyright (c) 2017 Yalantis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Pod/Classes/KolodaView/KolodaView.swift b/Pod/Classes/KolodaView/KolodaView.swift index e3d17d62..90e2d35c 100644 --- a/Pod/Classes/KolodaView/KolodaView.swift +++ b/Pod/Classes/KolodaView/KolodaView.swift @@ -15,6 +15,7 @@ private let defaultBackgroundCardsTopMargin: CGFloat = 4.0 private let defaultBackgroundCardsScalePercent: CGFloat = 0.95 private let defaultBackgroundCardsLeftMargin: CGFloat = 8.0 private let defaultBackgroundCardFrameAnimationDuration: TimeInterval = 0.2 +private let defaultAppearanceAnimationDuration: TimeInterval = 0.8 //Opacity values private let defaultAlphaValueOpaque: CGFloat = 1.0 @@ -47,6 +48,7 @@ public protocol KolodaViewDelegate: class { func kolodaShouldApplyAppearAnimation(_ koloda: KolodaView) -> Bool func kolodaShouldMoveBackgroundCard(_ koloda: KolodaView) -> Bool func kolodaShouldTransparentizeNextCard(_ koloda: KolodaView) -> Bool + func kolodaOpacityForNextCard(_ koloda: KolodaView, at index: Int) -> CGFloat func koloda(_ koloda: KolodaView, draggedCardWithPercentage finishPercentage: CGFloat, in direction: SwipeResultDirection) func kolodaDidResetCard(_ koloda: KolodaView) func kolodaSwipeThresholdRatioMargin(_ koloda: KolodaView) -> CGFloat? @@ -66,6 +68,7 @@ public extension KolodaViewDelegate { func kolodaShouldApplyAppearAnimation(_ koloda: KolodaView) -> Bool { return true } func kolodaShouldMoveBackgroundCard(_ koloda: KolodaView) -> Bool { return true } func kolodaShouldTransparentizeNextCard(_ koloda: KolodaView) -> Bool { return true } + func kolodaOpacityForNextCard(_ koloda: KolodaView, at index: Int) -> CGFloat { return defaultAlphaValueSemiTransparent } func koloda(_ koloda: KolodaView, draggedCardWithPercentage finishPercentage: CGFloat, in direction: SwipeResultDirection) {} func kolodaDidResetCard(_ koloda: KolodaView) {} func kolodaSwipeThresholdRatioMargin(_ koloda: KolodaView) -> CGFloat? { return nil} @@ -82,6 +85,8 @@ open class KolodaView: UIView, DraggableCardDelegate { public var alphaValueSemiTransparent = defaultAlphaValueSemiTransparent public var shouldPassthroughTapsWhenNoVisibleCards = false + public var appearanceAnimationDuration = defaultAppearanceAnimationDuration + public weak var dataSource: KolodaViewDataSource? { didSet { setupDeck() @@ -129,7 +134,7 @@ open class KolodaView: UIView, DraggableCardDelegate { nextCardView.isUserInteractionEnabled = isTop nextCardView.alpha = alphaValueOpaque if shouldTransparentizeNextCard && !isTop { - nextCardView.alpha = alphaValueSemiTransparent + nextCardView.alpha = self.cardAlphaTransparent(at: index) } visibleCards.append(nextCardView) isTop ? addSubview(nextCardView) : insertSubview(nextCardView, belowSubview: visibleCards[index - 1]) @@ -222,7 +227,7 @@ open class KolodaView: UIView, DraggableCardDelegate { //For fully visible next card, when moving top card if shouldTransparentizeNextCard { if index == 1 { - card.alpha = alphaValueSemiTransparent + (alphaValueOpaque - alphaValueSemiTransparent) * fraction + card.alpha = alphaValueSemiTransparent + (alphaValueOpaque - self.cardAlphaTransparent(at: index)) * fraction } } } @@ -235,10 +240,10 @@ open class KolodaView: UIView, DraggableCardDelegate { isUserInteractionEnabled = false animating = true - animator.animateAppearanceWithCompletion { [weak self] _ in + animator.animateAppearance(duration: appearanceAnimationDuration, completion: { [weak self] _ in self?.isUserInteractionEnabled = true self?.animating = false - } + }) } public func applyAppearAnimationIfNeeded() { @@ -284,7 +289,7 @@ open class KolodaView: UIView, DraggableCardDelegate { for index in 1..<_self.visibleCards.count { let card = _self.visibleCards[index] if _self.shouldTransparentizeNextCard { - card.alpha = index == 0 ? _self.alphaValueOpaque : _self.alphaValueSemiTransparent + card.alpha = index == 0 ? _self.alphaValueOpaque : _self.cardAlphaTransparent(at: index) } } } @@ -324,7 +329,14 @@ open class KolodaView: UIView, DraggableCardDelegate { visibleCards.removeAll(keepingCapacity: true) } - // MARK: Actions + private func cardAlphaTransparent(at index: Int) -> CGFloat { + + let alphaTransparent: CGFloat = self.delegate != nil ? self.delegate!.kolodaOpacityForNextCard(self, at: index) : alphaValueSemiTransparent + return alphaTransparent + } + + + //MARK: Actions private func swipedAction(_ direction: SwipeResultDirection) { animating = true visibleCards.removeFirst() @@ -383,7 +395,7 @@ open class KolodaView: UIView, DraggableCardDelegate { var animationCompletion: ((Bool) -> Void)? = nil if index != 0 { if shouldTransparentizeNextCard { - currentCard.alpha = alphaValueSemiTransparent + currentCard.alpha = cardAlphaTransparent(at: index) } } else { animationCompletion = { finished in @@ -443,8 +455,8 @@ open class KolodaView: UIView, DraggableCardDelegate { for (index, card) in visibleCards.dropFirst().enumerated() { if shouldTransparentizeNextCard { - card.alpha = alphaValueSemiTransparent - } + card.alpha = cardAlphaTransparent(at: index) + } card.isUserInteractionEnabled = false let cardParameters = backgroundCardParametersForFrame(frameForCard(at: index + 1)) @@ -457,11 +469,10 @@ open class KolodaView: UIView, DraggableCardDelegate { ) } } - + private func loadMissingCards(_ missingCardsCount: Int) { - guard missingCardsCount > 0 else { - return - } + guard missingCardsCount > 0 else { return } + let cardsToAdd = min(missingCardsCount, countOfCards - currentCardIndex) let startIndex = visibleCards.count let endIndex = startIndex + cardsToAdd - 1 @@ -469,7 +480,7 @@ open class KolodaView: UIView, DraggableCardDelegate { for index in startIndex...endIndex { let nextCardView = generateCard(frameForTopCard()) layoutCard(nextCardView, at: index) - nextCardView.alpha = shouldTransparentizeNextCard ? alphaValueSemiTransparent : alphaValueOpaque + nextCardView.alpha = shouldTransparentizeNextCard ? cardAlphaTransparent(at: index) : alphaValueOpaque visibleCards.append(nextCardView) configureCard(nextCardView, at: currentCardIndex + index) @@ -520,8 +531,12 @@ open class KolodaView: UIView, DraggableCardDelegate { reconfigureCards() } } - - public func swipe(_ direction: SwipeResultDirection) { + + public func swipe(_ direction: SwipeResultDirection, force: Bool = false) { + let shouldSwipe = delegate?.koloda(self, shouldSwipeCardAt: currentCardIndex, in: direction) ?? true + guard force || shouldSwipe else { + return + } let validDirection = delegate?.koloda(self, allowedDirectionsForIndex: currentCardIndex).contains(direction) ?? true guard validDirection else { return } @@ -531,8 +546,10 @@ open class KolodaView: UIView, DraggableCardDelegate { animating = true if visibleCards.count > 1 { - let nextCard = visibleCards[1] - nextCard.alpha = shouldTransparentizeNextCard ? alphaValueSemiTransparent : alphaValueOpaque + for i in 1..) { + private func proceedDeletionInRange(_ range: CountableClosedRange, animated: Bool) { 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 { + animator.removeCardAnimation(card: card) + } else { + card.removeFromSuperview() + } visibleCards.remove(at: visibleCardIndex) } } @@ -658,13 +679,13 @@ open class KolodaView: UIView, DraggableCardDelegate { 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()) layoutDeck() for (index, card) in visibleCards.enumerated() { - card.alpha = shouldTransparentizeNextCard && index != 0 ? alphaValueSemiTransparent : alphaValueOpaque + card.alpha = shouldTransparentizeNextCard && index != 0 ? cardAlphaTransparent(at: index) : alphaValueOpaque card.isUserInteractionEnabled = index == 0 } animating = false diff --git a/Pod/Classes/KolodaView/KolodaViewAnimatior.swift b/Pod/Classes/KolodaView/KolodaViewAnimatior.swift index 5850d426..8c0181bf 100644 --- a/Pod/Classes/KolodaView/KolodaViewAnimatior.swift +++ b/Pod/Classes/KolodaView/KolodaViewAnimatior.swift @@ -20,11 +20,11 @@ open class KolodaViewAnimator { self.koloda = koloda } - open func animateAppearanceWithCompletion(_ completion: AnimationCompletionBlock = nil) { + open func animateAppearance(duration: TimeInterval, completion: AnimationCompletionBlock = nil) { let kolodaAppearScaleAnimation = POPBasicAnimation(propertyNamed: kPOPLayerScaleXY) kolodaAppearScaleAnimation?.beginTime = CACurrentMediaTime() + cardSwipeActionAnimationDuration - kolodaAppearScaleAnimation?.duration = 0.8 + kolodaAppearScaleAnimation?.duration = duration kolodaAppearScaleAnimation?.fromValue = NSValue(cgPoint: CGPoint(x: 0.1, y: 0.1)) kolodaAppearScaleAnimation?.toValue = NSValue(cgPoint: CGPoint(x: 1.0, y: 1.0)) kolodaAppearScaleAnimation?.completionBlock = { (_, finished) in @@ -36,7 +36,7 @@ open class KolodaViewAnimator { kolodaAppearAlphaAnimation?.beginTime = CACurrentMediaTime() + cardSwipeActionAnimationDuration kolodaAppearAlphaAnimation?.fromValue = NSNumber(value: 0.0) kolodaAppearAlphaAnimation?.toValue = NSNumber(value: 1.0) - kolodaAppearAlphaAnimation?.duration = 0.8 + kolodaAppearAlphaAnimation?.duration = duration koloda?.pop_add(kolodaAppearAlphaAnimation, forKey: "kolodaAppearScaleAnimation") koloda?.layer.pop_add(kolodaAppearScaleAnimation, forKey: "kolodaAppearAlphaAnimation") @@ -107,6 +107,11 @@ open class KolodaViewAnimator { } ) } + + open func removeCardAnimation(card: DraggableCardView, completion: AnimationCompletionBlock = nil) { + card.swipe(.right) + completion?(true) + } internal func resetBackgroundCardsWithCompletion(_ completion: AnimationCompletionBlock = nil) { UIView.animate( diff --git a/Pod/Info.plist b/Pod/Info.plist index 29e24f66..b1376a82 100644 --- a/Pod/Info.plist +++ b/Pod/Info.plist @@ -15,7 +15,9 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 4.0 + 3.1.2 + CFBundleSignature + ???? CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/README.md b/README.md index 3f87d054..cb10f970 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -KolodaView [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) ![Swift 2.2.x](https://img.shields.io/badge/Swift-2.2.x-orange.svg) +KolodaView [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) ![Swift 3.0.x](https://img.shields.io/badge/Swift-3.0.x-orange.svg) -------------- [![Yalantis](https://raw.githubusercontent.com/Yalantis/PullToMakeSoup/master/PullToMakeSoupDemo/Resouces/badge_dark.png)](https://Yalantis.com/?utm_source=github) @@ -17,7 +17,7 @@ KolodaView is a class designed to simplify the implementation of Tinder like car Supported OS & SDK Versions ----------------------------- -* Supported build target - iOS 9.0 (Xcode 8) +* Supported build target - iOS 9.0 (Xcode 7.3) ARC Compatibility ------------------ @@ -38,18 +38,12 @@ KolodaView is subclassed from UIView and - as with all UIKit components - it sho Installation -------------- -To install via CocoaPods add this lines to your Podfile +To install via CocoaPods add this lines to your Podfile. You need CocoaPods v. 1.1 or higher ```ruby use_frameworks! pod "Koloda" ``` -Note: Due to [CocoaPods/CocoaPods#4420 issue](https://github.com/CocoaPods/CocoaPods/issues/4420) there is problem with compiling project with Xcode 7.1 and CocoaPods v0.39.0. However there is a temporary workaround for this: -Add next lines to the end of your Podfile -```ruby -post_install do |installer| -`find Pods -regex 'Pods/pop.*\\.h' -print0 | xargs -0 sed -i '' 's/\\(<\\)pop\\/\\(.*\\)\\(>\\)/\\"\\2\\"/'` -end -``` + To install via Carthage add this lines to your Cartfile ```ruby github "Yalantis/Koloda" @@ -84,8 +78,8 @@ To install manually the KolodaView class in an app, just drag the KolodaView, Dr dataSource.reset() } - func koloda(koloda: KolodaView, didSelectCardAtIndex index: Int) { - UIApplication.sharedApplication().openURL(NSURL(string: "http://yalantis.com/")!) + func koloda(koloda: KolodaView, didSelectCardAt index: Int) { + UIApplication.sharedApplication().openURL(NSURL(string: "https://yalantis.com/")!) } } ``` @@ -97,11 +91,11 @@ To install manually the KolodaView class in an app, just drag the KolodaView, Dr return images.count } - func koloda(koloda: KolodaView, viewForCardAtIndex index: Int) -> UIView { - return UIImageView(image: images[Int(index)]) + func koloda(koloda: KolodaView, viewForCardAt index: Int) -> UIView { + return UIImageView(image: images[index]) } - func koloda(koloda: KolodaView, viewForCardOverlayAtIndex index: Int) -> OverlayView? { + func koloda(koloda: KolodaView, viewForCardOverlayAt index: Int) -> OverlayView? { return NSBundle.mainBundle().loadNibNamed("OverlayView", owner: self, options: nil)[0] as? OverlayView } @@ -158,11 +152,11 @@ func applyAppearAnimation() ``` Applies appear animation. ```swift -func swipe(.Left) +func swipe(.left) ``` Applies swipe left animation and action, increment currentCardNumber. ```swift -func swipe(.Right) +func swipe(.right) ``` Applies swipe right animation and action, increment currentCardNumber. @@ -180,11 +174,11 @@ func koloda(kolodaNumberOfCards koloda: KolodaView) -> Int ``` Return the number of items (views) in the KolodaView. ```swift -func koloda(koloda: KolodaView, viewForCardAtIndex index: Int) -> UIView +func koloda(koloda: KolodaView, viewForCardAt index: Int) -> UIView ``` Return a view to be displayed at the specified index in the KolodaView. ```swift -func koloda(koloda: KolodaView, viewForCardOverlayAtIndex index: Int) -> OverlayView? +func koloda(koloda: KolodaView, viewForCardOverlayAt index: Int) -> OverlayView? ``` Return a view for card overlay at the specified index. For setting custom overlay action on swiping(left/right), you should override didSet of overlayState property in OverlayView. (See Example) @@ -192,14 +186,14 @@ The KolodaViewDelegate protocol has the following methods: ```swift func koloda(koloda: KolodaView, allowedDirectionsForIndex index: Int) -> [SwipeResultDirection] ``` -Return the allowed directions for a given card, defaults to `[.Left, .Right]` +Return the allowed directions for a given card, defaults to `[.left, .right]` ```swift -func koloda(koloda: KolodaView, shouldSwipeCardAtIndex index: Int, inDirection direction: SwipeResultDirection) -> Bool +func koloda(koloda: KolodaView, shouldSwipeCardAt index: Int, in direction: SwipeResultDirection) -> Bool ``` This method is called before the KolodaView swipes card. Return `true` or `false` to allow or deny the swipe. ```swift -func koloda(koloda: KolodaView, didSwipeCardAtIndex index: Int, inDirection direction: SwipeResultDirection) +func koloda(koloda: KolodaView, didSwipeCardAt index: Int, in direction: SwipeResultDirection) ``` This method is called whenever the KolodaView swipes card. It is called regardless of whether the card was swiped programatically or through user interaction. ```swift @@ -207,7 +201,7 @@ func kolodaDidRunOutOfCards(koloda: KolodaView) ``` This method is called when the KolodaView has no cards to display. ```swift -func koloda(koloda: KolodaView, didSelectCardAtIndex index: Int) +func koloda(koloda: KolodaView, didSelectCardAt index: Int) ``` This method is called when one of cards is tapped. ```swift @@ -223,7 +217,7 @@ func kolodaShouldTransparentizeNextCard(koloda: KolodaView) -> Bool ``` This method is fired on koloda's layout and after swiping. If you return YES from the method or don't implement it, the koloda will transparentize next card below front card. ```swift -func koloda(koloda: KolodaView, draggedCardWithPercentage finishPercentage: CGFloat, inDirection direction: SwipeResultDirection) +func koloda(koloda: KolodaView, draggedCardWithPercentage finishPercentage: CGFloat, in direction: SwipeResultDirection) ``` This method is called whenever the KolodaView recognizes card dragging event. ```swift @@ -235,11 +229,11 @@ func kolodaDidResetCard(koloda: KolodaView) ``` This method is fired after resetting the card. ```swift -func koloda(koloda: KolodaView, didShowCardAtIndex index: Int) +func koloda(koloda: KolodaView, didShowCardAt index: Int) ``` This method is called after a card has been shown, after animation is complete ```swift -func koloda(koloda: KolodaView, shouldDragCardAtIndex index: Int) -> Bool +func koloda(koloda: KolodaView, shouldDragCardAt index: Int) -> Bool ``` This method is called when the card is beginning to be dragged. If you return YES from the method or don't implement it, the card will move in the direction of the drag. If you return NO the card will @@ -248,6 +242,11 @@ not move. Release Notes ---------------- +Version 4.0 +- Swift 3 support +- Get rid of UInt +- Common bugfix + Version 3.1 - Multiple Direction Support @@ -293,7 +292,7 @@ License The MIT License (MIT) -Copyright © 2016 Yalantis +Copyright © 2017 Yalantis Permission is hereby granted free of charge to any person obtaining a copy of this software and associated documentation files (the "Software") to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: