diff --git a/Cartfile b/Cartfile index 7408d330..6044c4c9 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "facebook/pop" +github "facebook/pop" ~> 1.0 diff --git a/Example/Koloda.xcodeproj/project.pbxproj b/Example/Koloda.xcodeproj/project.pbxproj index 1fcde420..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 = ( ); @@ -166,11 +166,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = CocoaPods; TargetAttributes = { 607FACCF1AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; + LastSwiftMigration = 0800; }; }; }; @@ -208,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; @@ -238,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; @@ -313,8 +314,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -358,8 +361,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -378,6 +383,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.3; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; @@ -386,6 +392,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = CF2C9E50C19A9188464AE19E /* Pods-Koloda_Example.debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; INFOPLIST_FILE = Koloda/Info.plist; @@ -393,6 +400,7 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "com.yalantis.Koloda-Example"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -400,6 +408,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 093C6CC368001B8BAFD235CB /* Pods-Koloda_Example.release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; INFOPLIST_FILE = Koloda/Info.plist; @@ -407,6 +416,7 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "com.yalantis.Koloda-Example"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/Example/Koloda.xcodeproj/xcshareddata/xcschemes/Koloda-Example.xcscheme b/Example/Koloda.xcodeproj/xcshareddata/xcschemes/Koloda-Example.xcscheme index 7f24602c..6508425d 100644 --- a/Example/Koloda.xcodeproj/xcshareddata/xcschemes/Koloda-Example.xcscheme +++ b/Example/Koloda.xcodeproj/xcshareddata/xcschemes/Koloda-Example.xcscheme @@ -1,6 +1,6 @@ Bool { - // Override point for customization after application launch. - return true - } - - func applicationWillResignActive(application: UIApplication) { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - } - - func applicationDidEnterBackground(application: UIApplication) { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - } - - func applicationWillEnterForeground(application: UIApplication) { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. - } - - func applicationDidBecomeActive(application: UIApplication) { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - } - - func applicationWillTerminate(application: UIApplication) { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. - } - - } - diff --git a/Example/Koloda/BackgroundAnimationViewController.swift b/Example/Koloda/BackgroundAnimationViewController.swift index 8adbdb09..def91ff4 100644 --- a/Example/Koloda/BackgroundAnimationViewController.swift +++ b/Example/Koloda/BackgroundAnimationViewController.swift @@ -10,7 +10,7 @@ import UIKit import Koloda import pop -private let numberOfCards: UInt = 5 +private let numberOfCards: Int = 5 private let frameAnimationSpringBounciness: CGFloat = 9 private let frameAnimationSpringSpeed: CGFloat = 16 private let kolodaCountOfVisibleCards = 2 @@ -29,17 +29,17 @@ class BackgroundAnimationViewController: UIViewController { kolodaView.dataSource = self kolodaView.animator = BackgroundKolodaAnimator(koloda: kolodaView) - self.modalTransitionStyle = UIModalTransitionStyle.FlipHorizontal + self.modalTransitionStyle = UIModalTransitionStyle.flipHorizontal } //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() { @@ -50,47 +50,46 @@ class BackgroundAnimationViewController: UIViewController { //MARK: KolodaViewDelegate extension BackgroundAnimationViewController: KolodaViewDelegate { - func kolodaDidRunOutOfCards(koloda: KolodaView) { + func kolodaDidRunOutOfCards(_ koloda: KolodaView) { kolodaView.resetCurrentCardIndex() } - func koloda(koloda: KolodaView, didSelectCardAtIndex index: UInt) { - UIApplication.sharedApplication().openURL(NSURL(string: "http://yalantis.com/")!) + func koloda(_ koloda: KolodaView, didSelectCardAt index: Int) { + UIApplication.shared.openURL(URL(string: "https://yalantis.com/")!) } - func kolodaShouldApplyAppearAnimation(koloda: KolodaView) -> Bool { + func kolodaShouldApplyAppearAnimation(_ koloda: KolodaView) -> Bool { return true } - func kolodaShouldMoveBackgroundCard(koloda: KolodaView) -> Bool { + func kolodaShouldMoveBackgroundCard(_ koloda: KolodaView) -> Bool { return false } - func kolodaShouldTransparentizeNextCard(koloda: KolodaView) -> Bool { + func kolodaShouldTransparentizeNextCard(_ koloda: KolodaView) -> Bool { return true } func koloda(kolodaBackgroundCardAnimation koloda: KolodaView) -> POPPropertyAnimation? { let animation = POPSpringAnimation(propertyNamed: kPOPViewFrame) - animation.springBounciness = frameAnimationSpringBounciness - animation.springSpeed = frameAnimationSpringSpeed + animation?.springBounciness = frameAnimationSpringBounciness + animation?.springSpeed = frameAnimationSpringSpeed return animation } } -//MARK: KolodaViewDataSource +// MARK: KolodaViewDataSource extension BackgroundAnimationViewController: KolodaViewDataSource { - func kolodaNumberOfCards(koloda: KolodaView) -> UInt { + func kolodaNumberOfCards(_ koloda: KolodaView) -> Int { return numberOfCards } - func koloda(koloda: KolodaView, viewForCardAtIndex index: UInt) -> UIView { + func koloda(_ koloda: KolodaView, viewForCardAt index: Int) -> UIView { return UIImageView(image: UIImage(named: "cards_\(index + 1)")) } - func koloda(koloda: KolodaView, viewForCardOverlayAtIndex index: UInt) -> OverlayView? { - return NSBundle.mainBundle().loadNibNamed("CustomOverlayView", - owner: self, options: nil)[0] as? OverlayView + func koloda(_ koloda: KolodaView, viewForCardOverlayAt index: Int) -> OverlayView? { + return Bundle.main.loadNibNamed("CustomOverlayView", owner: self, options: nil)?[0] as? OverlayView } } diff --git a/Example/Koloda/BackgroundKolodaAnimator.swift b/Example/Koloda/BackgroundKolodaAnimator.swift index 453032f8..4f49487a 100644 --- a/Example/Koloda/BackgroundKolodaAnimator.swift +++ b/Example/Koloda/BackgroundKolodaAnimator.swift @@ -12,24 +12,24 @@ import pop class BackgroundKolodaAnimator: KolodaViewAnimator { - override func applyScaleAnimation(card: DraggableCardView, scale: CGSize, frame: CGRect, duration: NSTimeInterval, completion: AnimationCompletionBlock) { + override func applyScaleAnimation(_ card: DraggableCardView, scale: CGSize, frame: CGRect, duration: TimeInterval, completion: AnimationCompletionBlock) { let scaleAnimation = POPSpringAnimation(propertyNamed: kPOPLayerScaleXY) - scaleAnimation.springBounciness = 9 - scaleAnimation.springSpeed = 16 - scaleAnimation.toValue = NSValue(CGSize: scale) - card.layer.pop_addAnimation(scaleAnimation, forKey: "scaleAnimation") + scaleAnimation?.springBounciness = 9 + scaleAnimation?.springSpeed = 16 + scaleAnimation?.toValue = NSValue(cgSize: scale) + card.layer.pop_add(scaleAnimation, forKey: "scaleAnimation") let frameAnimation = POPSpringAnimation(propertyNamed: kPOPViewFrame) - frameAnimation.springBounciness = 9 - frameAnimation.springSpeed = 16 - frameAnimation.toValue = NSValue(CGRect: frame) + frameAnimation?.springBounciness = 9 + frameAnimation?.springSpeed = 16 + frameAnimation?.toValue = NSValue(cgRect: frame) if let completion = completion { - frameAnimation.completionBlock = { _, finished in + frameAnimation?.completionBlock = { _, finished in completion(finished) } } - card.pop_addAnimation(frameAnimation, forKey: "frameAnimation") + card.pop_add(frameAnimation, forKey: "frameAnimation") } -} \ No newline at end of file +} diff --git a/Example/Koloda/Base.lproj/LaunchScreen.xib b/Example/Koloda/Base.lproj/LaunchScreen.xib index 5fd32715..d3c301e5 100644 --- a/Example/Koloda/Base.lproj/LaunchScreen.xib +++ b/Example/Koloda/Base.lproj/LaunchScreen.xib @@ -1,8 +1,13 @@ - - + + + + + - + + + @@ -24,7 +29,7 @@ - + diff --git a/Example/Koloda/Base.lproj/Main.storyboard b/Example/Koloda/Base.lproj/Main.storyboard index 9587facb..77e53603 100644 --- a/Example/Koloda/Base.lproj/Main.storyboard +++ b/Example/Koloda/Base.lproj/Main.storyboard @@ -1,8 +1,13 @@ - - + + + + + - + + + @@ -14,10 +19,10 @@ - + - + - - + @@ -52,13 +57,14 @@ - + - + - + - + - + @@ -109,7 +116,6 @@ - @@ -127,60 +133,60 @@ - + - + - + - - - + - - - + @@ -191,16 +197,16 @@ - + - + - + @@ -223,7 +229,6 @@ - diff --git a/Example/Koloda/Base.lproj/OverlayView.xib b/Example/Koloda/Base.lproj/OverlayView.xib index 6510115c..bcbd0a52 100644 --- a/Example/Koloda/Base.lproj/OverlayView.xib +++ b/Example/Koloda/Base.lproj/OverlayView.xib @@ -1,20 +1,25 @@ - - + + + + + - + + + - + - + - + diff --git a/Example/Koloda/CustomKolodaView.swift b/Example/Koloda/CustomKolodaView.swift index dc097c50..3836ad38 100644 --- a/Example/Koloda/CustomKolodaView.swift +++ b/Example/Koloda/CustomKolodaView.swift @@ -9,22 +9,21 @@ import UIKit import Koloda -let defaultBottomOffset:CGFloat = 0 -let defaultTopOffset:CGFloat = 20 -let defaultHorizontalOffset:CGFloat = 10 -let defaultHeightRatio:CGFloat = 1.25 -let backgroundCardHorizontalMarginMultiplier:CGFloat = 0.25 -let backgroundCardScalePercent:CGFloat = 1.5 +let defaultTopOffset: CGFloat = 20 +let defaultHorizontalOffset: CGFloat = 10 +let defaultHeightRatio: CGFloat = 1.25 +let backgroundCardHorizontalMarginMultiplier: CGFloat = 0.25 +let backgroundCardScalePercent: CGFloat = 1.5 class CustomKolodaView: KolodaView { - override func frameForCardAtIndex(index: UInt) -> CGRect { + override func frameForCard(at index: Int) -> CGRect { if index == 0 { - let topOffset:CGFloat = defaultTopOffset - let xOffset:CGFloat = defaultHorizontalOffset - let width = CGRectGetWidth(self.frame ) - 2 * defaultHorizontalOffset + let topOffset: CGFloat = defaultTopOffset + let xOffset: CGFloat = defaultHorizontalOffset + let width = (self.frame).width - 2 * defaultHorizontalOffset let height = width * defaultHeightRatio - let yOffset:CGFloat = topOffset + let yOffset: CGFloat = topOffset let frame = CGRect(x: xOffset, y: yOffset, width: width, height: height) return frame @@ -34,7 +33,7 @@ class CustomKolodaView: KolodaView { let height = width * defaultHeightRatio return CGRect(x: horizontalMargin, y: 0, width: width, height: height) } - return CGRectZero + return CGRect.zero } } diff --git a/Example/Koloda/CustomOverlayView.swift b/Example/Koloda/CustomOverlayView.swift index 3d2b82b3..bc660488 100644 --- a/Example/Koloda/CustomOverlayView.swift +++ b/Example/Koloda/CustomOverlayView.swift @@ -26,9 +26,9 @@ class CustomOverlayView: OverlayView { override var overlayState: SwipeResultDirection? { didSet { switch overlayState { - case .Left? : + case .left? : overlayImageView.image = UIImage(named: overlayLeftImageName) - case .Right? : + case .right? : overlayImageView.image = UIImage(named: overlayRightImageName) default: overlayImageView.image = nil diff --git a/Example/Koloda/CustomOverlayView.xib b/Example/Koloda/CustomOverlayView.xib index e59831b5..22dde59c 100644 --- a/Example/Koloda/CustomOverlayView.xib +++ b/Example/Koloda/CustomOverlayView.xib @@ -1,20 +1,25 @@ - - + + + + + - + + + - + - + - + diff --git a/Example/Koloda/ExampleOverlayView.swift b/Example/Koloda/ExampleOverlayView.swift index ae70c8af..49fc2599 100644 --- a/Example/Koloda/ExampleOverlayView.swift +++ b/Example/Koloda/ExampleOverlayView.swift @@ -26,9 +26,9 @@ class ExampleOverlayView: OverlayView { override var overlayState: SwipeResultDirection? { didSet { switch overlayState { - case .Left? : + case .left? : overlayImageView.image = UIImage(named: overlayLeftImageName) - case .Right? : + case .right? : overlayImageView.image = UIImage(named: overlayRightImageName) default: overlayImageView.image = nil diff --git a/Example/Koloda/ViewController.swift b/Example/Koloda/ViewController.swift index 5294d935..29f1fc3f 100644 --- a/Example/Koloda/ViewController.swift +++ b/Example/Koloda/ViewController.swift @@ -9,14 +9,14 @@ import UIKit import Koloda -private var numberOfCards: UInt = 5 +private var numberOfCards: Int = 5 class ViewController: UIViewController { @IBOutlet weak var kolodaView: KolodaView! - private var dataSource: Array = { - var array: Array = [] + fileprivate var dataSource: [UIImage] = { + var array: [UIImage] = [] for index in 0.. UInt { - return UInt(dataSource.count) + func kolodaNumberOfCards(_ koloda: KolodaView) -> Int { + return dataSource.count } - func koloda(koloda: KolodaView, viewForCardAtIndex index: UInt) -> UIView { + func koloda(_ koloda: KolodaView, viewForCardAt index: Int) -> UIView { return UIImageView(image: dataSource[Int(index)]) } - func koloda(koloda: KolodaView, viewForCardOverlayAtIndex index: UInt) -> OverlayView? { - return NSBundle.mainBundle().loadNibNamed("OverlayView", - owner: self, options: nil)[0] as? OverlayView + func koloda(_ koloda: KolodaView, viewForCardOverlayAt index: Int) -> OverlayView? { + return Bundle.main.loadNibNamed("OverlayView", owner: self, options: nil)?[0] as? OverlayView } } diff --git a/Koloda.podspec b/Koloda.podspec index 4221c488..3012b446 100644 --- a/Koloda.podspec +++ b/Koloda.podspec @@ -1,8 +1,6 @@ - - Pod::Spec.new do |s| s.name = "Koloda" -s.version = "3.1.2" +s.version = "4.0" s.summary = "KolodaView is a class designed to simplify the implementation of Tinder like cards on iOS. " s.homepage = "https://github.com/Yalantis/Koloda" @@ -12,8 +10,6 @@ s.source = { :git => "https://github.com/Yalantis/Koloda.git", :tag => s.social_media_url = 'https://twitter.com/yalantis' s.platform = :ios, '8.0' -s.requires_arc = true - s.source_files = 'Pod/Classes/**/*' s.frameworks = 'UIKit' diff --git a/Koloda.xcodeproj/project.pbxproj b/Koloda.xcodeproj/project.pbxproj index 58ca0a4a..8526cd75 100644 --- a/Koloda.xcodeproj/project.pbxproj +++ b/Koloda.xcodeproj/project.pbxproj @@ -7,159 +7,188 @@ objects = { /* Begin PBXBuildFile section */ - 442337AD1CDBCB10007B868C /* SwipeResultDirection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442337AC1CDBCB10007B868C /* SwipeResultDirection.swift */; }; - 733C4A3D1CA43F50009A467E /* DraggableCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 733C4A391CA43F50009A467E /* DraggableCardView.swift */; }; - 733C4A3E1CA43F50009A467E /* KolodaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 733C4A3A1CA43F50009A467E /* KolodaView.swift */; }; - 733C4A3F1CA43F50009A467E /* OverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 733C4A3C1CA43F50009A467E /* OverlayView.swift */; }; - 734475981CB279D8006E6726 /* KolodaCardStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 734475961CB279D8006E6726 /* KolodaCardStorage.swift */; }; - 734475991CB279D8006E6726 /* KolodaViewAnimatior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 734475971CB279D8006E6726 /* KolodaViewAnimatior.swift */; }; - 73CC28AE1CA44035009CE177 /* pop.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 73CC28AD1CA44035009CE177 /* pop.framework */; }; + C517E4B61D9CF9470002D88F /* Koloda.h in Headers */ = {isa = PBXBuildFile; fileRef = C517E4AE1D9CF9010002D88F /* Koloda.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C517E4EF1D9D00520002D88F /* DraggableCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C517E4E51D9D00520002D88F /* DraggableCardView.swift */; }; + C517E4F01D9D00520002D88F /* KolodaCardStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C517E4E61D9D00520002D88F /* KolodaCardStorage.swift */; }; + C517E4F11D9D00520002D88F /* KolodaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C517E4E71D9D00520002D88F /* KolodaView.swift */; }; + 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 */ - 442337AC1CDBCB10007B868C /* SwipeResultDirection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeResultDirection.swift; sourceTree = ""; }; - 733C4A2C1CA43E7C009A467E /* Koloda.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Koloda.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 733C4A311CA43E7C009A467E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 733C4A391CA43F50009A467E /* DraggableCardView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DraggableCardView.swift; sourceTree = ""; }; - 733C4A3A1CA43F50009A467E /* KolodaView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KolodaView.swift; sourceTree = ""; }; - 733C4A3C1CA43F50009A467E /* OverlayView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OverlayView.swift; sourceTree = ""; }; - 734475961CB279D8006E6726 /* KolodaCardStorage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KolodaCardStorage.swift; sourceTree = ""; }; - 734475971CB279D8006E6726 /* KolodaViewAnimatior.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KolodaViewAnimatior.swift; sourceTree = ""; }; - 73CC28AD1CA44035009CE177 /* pop.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = pop.framework; path = Carthage/Build/iOS/pop.framework; sourceTree = ""; }; + C517E4AB1D9CF9010002D88F /* Koloda.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Koloda.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C517E4AE1D9CF9010002D88F /* Koloda.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Koloda.h; sourceTree = ""; }; + C517E4AF1D9CF9010002D88F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C517E4E51D9D00520002D88F /* DraggableCardView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DraggableCardView.swift; sourceTree = ""; }; + C517E4E61D9D00520002D88F /* KolodaCardStorage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KolodaCardStorage.swift; sourceTree = ""; }; + C517E4E71D9D00520002D88F /* KolodaView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KolodaView.swift; sourceTree = ""; }; + C517E4E81D9D00520002D88F /* KolodaViewAnimatior.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KolodaViewAnimatior.swift; sourceTree = ""; }; + C517E4EA1D9D00520002D88F /* OverlayView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OverlayView.swift; sourceTree = ""; }; + C517E4EB1D9D00520002D88F /* SwipeResultDirection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeResultDirection.swift; sourceTree = ""; }; + C517E4F81D9D01920002D88F /* pop.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = pop.framework; path = Carthage/Build/iOS/pop.framework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 733C4A281CA43E7C009A467E /* Frameworks */ = { + C517E4A71D9CF9010002D88F /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 73CC28AE1CA44035009CE177 /* pop.framework in Frameworks */, + C517E4F91D9D01920002D88F /* pop.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 733C4A221CA43E7C009A467E = { + C517E4A11D9CF9010002D88F = { isa = PBXGroup; children = ( - 73CC28AD1CA44035009CE177 /* pop.framework */, - 733C4A2E1CA43E7C009A467E /* Koloda */, - 733C4A2D1CA43E7C009A467E /* Products */, + C517E4AD1D9CF9010002D88F /* Pod */, + C517E4AC1D9CF9010002D88F /* Products */, + C517E4F71D9D01910002D88F /* Frameworks */, ); sourceTree = ""; }; - 733C4A2D1CA43E7C009A467E /* Products */ = { + C517E4AC1D9CF9010002D88F /* Products */ = { isa = PBXGroup; children = ( - 733C4A2C1CA43E7C009A467E /* Koloda.framework */, + C517E4AB1D9CF9010002D88F /* Koloda.framework */, ); name = Products; sourceTree = ""; }; - 733C4A2E1CA43E7C009A467E /* Koloda */ = { + C517E4AD1D9CF9010002D88F /* Pod */ = { isa = PBXGroup; children = ( - 733C4A371CA43F50009A467E /* KolodaView */, - 733C4A311CA43E7C009A467E /* Info.plist */, + C517E4E11D9D00520002D88F /* Classes */, + C517E4EC1D9D00520002D88F /* Assets */, + C517E4AE1D9CF9010002D88F /* Koloda.h */, + C517E4AF1D9CF9010002D88F /* Info.plist */, ); - path = Koloda; + path = Pod; sourceTree = ""; }; - 733C4A371CA43F50009A467E /* KolodaView */ = { + C517E4E11D9D00520002D88F /* Classes */ = { isa = PBXGroup; children = ( - 442337AC1CDBCB10007B868C /* SwipeResultDirection.swift */, - 734475961CB279D8006E6726 /* KolodaCardStorage.swift */, - 734475971CB279D8006E6726 /* KolodaViewAnimatior.swift */, - 733C4A381CA43F50009A467E /* DraggableCardView */, - 733C4A3A1CA43F50009A467E /* KolodaView.swift */, - 733C4A3B1CA43F50009A467E /* OverlayView */, + C517E4E31D9D00520002D88F /* KolodaView */, ); - name = KolodaView; - path = Pod/Classes/KolodaView; - sourceTree = SOURCE_ROOT; + path = Classes; + sourceTree = ""; }; - 733C4A381CA43F50009A467E /* DraggableCardView */ = { + C517E4E31D9D00520002D88F /* KolodaView */ = { isa = PBXGroup; children = ( - 733C4A391CA43F50009A467E /* DraggableCardView.swift */, + C517E4E41D9D00520002D88F /* DraggableCardView */, + C517E4E61D9D00520002D88F /* KolodaCardStorage.swift */, + C517E4E71D9D00520002D88F /* KolodaView.swift */, + C517E4E81D9D00520002D88F /* KolodaViewAnimatior.swift */, + C517E4E91D9D00520002D88F /* OverlayView */, + C517E4EB1D9D00520002D88F /* SwipeResultDirection.swift */, + ); + path = KolodaView; + sourceTree = ""; + }; + C517E4E41D9D00520002D88F /* DraggableCardView */ = { + isa = PBXGroup; + children = ( + C517E4E51D9D00520002D88F /* DraggableCardView.swift */, ); path = DraggableCardView; sourceTree = ""; }; - 733C4A3B1CA43F50009A467E /* OverlayView */ = { + C517E4E91D9D00520002D88F /* OverlayView */ = { isa = PBXGroup; children = ( - 733C4A3C1CA43F50009A467E /* OverlayView.swift */, + C517E4EA1D9D00520002D88F /* OverlayView.swift */, ); path = OverlayView; sourceTree = ""; }; + C517E4EC1D9D00520002D88F /* Assets */ = { + isa = PBXGroup; + children = ( + ); + path = Assets; + sourceTree = ""; + }; + C517E4F71D9D01910002D88F /* Frameworks */ = { + isa = PBXGroup; + children = ( + C517E4F81D9D01920002D88F /* pop.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ - 733C4A291CA43E7C009A467E /* Headers */ = { + C517E4A81D9CF9010002D88F /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + C517E4B61D9CF9470002D88F /* Koloda.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ - 733C4A2B1CA43E7C009A467E /* Koloda */ = { + C517E4AA1D9CF9010002D88F /* Koloda */ = { isa = PBXNativeTarget; - buildConfigurationList = 733C4A341CA43E7C009A467E /* Build configuration list for PBXNativeTarget "Koloda" */; + buildConfigurationList = C517E4B31D9CF9010002D88F /* Build configuration list for PBXNativeTarget "Koloda" */; buildPhases = ( - 733C4A271CA43E7C009A467E /* Sources */, - 733C4A281CA43E7C009A467E /* Frameworks */, - 733C4A291CA43E7C009A467E /* Headers */, - 733C4A2A1CA43E7C009A467E /* Resources */, + C517E4A61D9CF9010002D88F /* Sources */, + C517E4A71D9CF9010002D88F /* Frameworks */, + C517E4A81D9CF9010002D88F /* Headers */, + C517E4A91D9CF9010002D88F /* Resources */, + C517E4F61D9D01120002D88F /* Carthage */, ); buildRules = ( ); dependencies = ( ); name = Koloda; - productName = Koloda; - productReference = 733C4A2C1CA43E7C009A467E /* Koloda.framework */; + productName = Pod; + productReference = C517E4AB1D9CF9010002D88F /* Koloda.framework */; productType = "com.apple.product-type.framework"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ - 733C4A231CA43E7C009A467E /* Project object */ = { + C517E4A21D9CF9010002D88F /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0730; - ORGANIZATIONNAME = "Толя Ларин"; + LastUpgradeCheck = 0800; + ORGANIZATIONNAME = Yalantis; TargetAttributes = { - 733C4A2B1CA43E7C009A467E = { - CreatedOnToolsVersion = 7.3; + C517E4AA1D9CF9010002D88F = { + CreatedOnToolsVersion = 8.0; + ProvisioningStyle = Automatic; }; }; }; - buildConfigurationList = 733C4A261CA43E7C009A467E /* Build configuration list for PBXProject "Koloda" */; + buildConfigurationList = C517E4A51D9CF9010002D88F /* Build configuration list for PBXProject "Koloda" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, ); - mainGroup = 733C4A221CA43E7C009A467E; - productRefGroup = 733C4A2D1CA43E7C009A467E /* Products */; + mainGroup = C517E4A11D9CF9010002D88F; + productRefGroup = C517E4AC1D9CF9010002D88F /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( - 733C4A2B1CA43E7C009A467E /* Koloda */, + C517E4AA1D9CF9010002D88F /* Koloda */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - 733C4A2A1CA43E7C009A467E /* Resources */ = { + C517E4A91D9CF9010002D88F /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( @@ -168,24 +197,42 @@ }; /* 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 */ - 733C4A271CA43E7C009A467E /* Sources */ = { + C517E4A61D9CF9010002D88F /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 733C4A3F1CA43F50009A467E /* OverlayView.swift in Sources */, - 733C4A3E1CA43F50009A467E /* KolodaView.swift in Sources */, - 733C4A3D1CA43F50009A467E /* DraggableCardView.swift in Sources */, - 442337AD1CDBCB10007B868C /* SwipeResultDirection.swift in Sources */, - 734475991CB279D8006E6726 /* KolodaViewAnimatior.swift in Sources */, - 734475981CB279D8006E6726 /* KolodaCardStorage.swift in Sources */, + C517E4EF1D9D00520002D88F /* DraggableCardView.swift in Sources */, + C517E4F21D9D00520002D88F /* KolodaViewAnimatior.swift in Sources */, + C517E4F01D9D00520002D88F /* KolodaCardStorage.swift in Sources */, + C517E4F41D9D00520002D88F /* SwipeResultDirection.swift in Sources */, + C517E4F11D9D00520002D88F /* KolodaView.swift in Sources */, + C517E4F31D9D00520002D88F /* OverlayView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ - 733C4A321CA43E7C009A467E /* Debug */ = { + C517E4B11D9CF9010002D88F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -197,10 +244,13 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -223,10 +273,11 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; @@ -234,7 +285,7 @@ }; name = Debug; }; - 733C4A331CA43E7C009A467E /* Release */ = { + C517E4B21D9CF9010002D88F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -246,10 +297,13 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -266,9 +320,10 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -276,9 +331,10 @@ }; name = Release; }; - 733C4A351CA43E7C009A467E /* Debug */ = { + C517E4B41D9CF9010002D88F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_IDENTITY = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -287,19 +343,20 @@ "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", ); - INFOPLIST_FILE = Info.plist; + INFOPLIST_FILE = Pod/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = me.wayd.Koloda; + PRODUCT_BUNDLE_IDENTIFIER = com.cocoapods.Koloda; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; }; name = Debug; }; - 733C4A361CA43E7C009A467E /* Release */ = { + C517E4B51D9CF9010002D88F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_IDENTITY = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -308,38 +365,38 @@ "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", ); - INFOPLIST_FILE = Info.plist; + INFOPLIST_FILE = Pod/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = me.wayd.Koloda; + PRODUCT_BUNDLE_IDENTIFIER = com.cocoapods.Koloda; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 733C4A261CA43E7C009A467E /* Build configuration list for PBXProject "Koloda" */ = { + C517E4A51D9CF9010002D88F /* Build configuration list for PBXProject "Koloda" */ = { isa = XCConfigurationList; buildConfigurations = ( - 733C4A321CA43E7C009A467E /* Debug */, - 733C4A331CA43E7C009A467E /* Release */, + C517E4B11D9CF9010002D88F /* Debug */, + C517E4B21D9CF9010002D88F /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 733C4A341CA43E7C009A467E /* Build configuration list for PBXNativeTarget "Koloda" */ = { + C517E4B31D9CF9010002D88F /* Build configuration list for PBXNativeTarget "Koloda" */ = { isa = XCConfigurationList; buildConfigurations = ( - 733C4A351CA43E7C009A467E /* Debug */, - 733C4A361CA43E7C009A467E /* Release */, + C517E4B41D9CF9010002D88F /* Debug */, + C517E4B51D9CF9010002D88F /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; - rootObject = 733C4A231CA43E7C009A467E /* Project object */; + rootObject = C517E4A21D9CF9010002D88F /* Project object */; } diff --git a/Koloda.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Koloda.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 84bd16c3..6a3b6298 100644 --- a/Koloda.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/Koloda.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:/Users/serhii/Documents/Development/Xcode/KOLODATEST/Pod/Koloda.xcodeproj"> diff --git a/Koloda.xcodeproj/xcshareddata/xcschemes/Koloda.xcscheme b/Koloda.xcodeproj/xcshareddata/xcschemes/Koloda.xcscheme index f1444200..4dddbfad 100644 --- a/Koloda.xcodeproj/xcshareddata/xcschemes/Koloda.xcscheme +++ b/Koloda.xcodeproj/xcshareddata/xcschemes/Koloda.xcscheme @@ -1,6 +1,6 @@ @@ -45,7 +45,7 @@ @@ -63,7 +63,7 @@ diff --git a/Pod/Classes/KolodaView/DraggableCardView/DraggableCardView.swift b/Pod/Classes/KolodaView/DraggableCardView/DraggableCardView.swift index 79b48459..ed0699dd 100644 --- a/Pod/Classes/KolodaView/DraggableCardView/DraggableCardView.swift +++ b/Pod/Classes/KolodaView/DraggableCardView/DraggableCardView.swift @@ -11,9 +11,9 @@ import pop protocol DraggableCardDelegate: class { - func card(card: DraggableCardView, wasDraggedWithFinishPercentage percentage: CGFloat, inDirection direction: SwipeResultDirection) - func card(card: DraggableCardView, wasSwipedInDirection direction: SwipeResultDirection) - func card(card: DraggableCardView, shouldSwipeInDirection direction: SwipeResultDirection) -> Bool + func card(_ card: DraggableCardView, wasDraggedWithFinishPercentage percentage: CGFloat, inDirection direction: SwipeResultDirection) + func card(_ card: DraggableCardView, wasSwipedIn direction: SwipeResultDirection) + func card(_ card: DraggableCardView, shouldSwipeIn direction: SwipeResultDirection) -> Bool func card(cardWasReset card: DraggableCardView) func card(cardWasTapped card: DraggableCardView) func card(cardSwipeThresholdRatioMargin card: DraggableCardView) -> CGFloat? @@ -25,15 +25,15 @@ protocol DraggableCardDelegate: class { private let rotationMax: CGFloat = 1.0 private let defaultRotationAngle = CGFloat(M_PI) / 10.0 private let scaleMin: CGFloat = 0.8 -public let cardSwipeActionAnimationDuration: NSTimeInterval = 0.4 +public let cardSwipeActionAnimationDuration: TimeInterval = 0.4 -private let screenSize = UIScreen.mainScreen().bounds.size +private let screenSize = UIScreen.main.bounds.size //Reset animation constants private let cardResetAnimationSpringBounciness: CGFloat = 10.0 private let cardResetAnimationSpringSpeed: CGFloat = 20.0 private let cardResetAnimationKey = "resetPositionAnimation" -private let cardResetAnimationDuration: NSTimeInterval = 0.2 +private let cardResetAnimationDuration: TimeInterval = 0.2 public class DraggableCardView: UIView, UIGestureRecognizerDelegate { @@ -46,12 +46,12 @@ public class DraggableCardView: UIView, UIGestureRecognizerDelegate { private var tapGestureRecognizer: UITapGestureRecognizer! private var animationDirectionY: CGFloat = 1.0 private var dragBegin = false - private var dragDistance = CGPointZero + private var dragDistance = CGPoint.zero private var swipePercentageMargin: CGFloat = 0.0 //MARK: Lifecycle init() { - super.init(frame: CGRectZero) + super.init(frame: CGRect.zero) setup() } @@ -67,7 +67,7 @@ public class DraggableCardView: UIView, UIGestureRecognizerDelegate { override public var frame: CGRect { didSet { - if let ratio = delegate?.card(cardSwipeThresholdRatioMargin: self) where ratio != 0 { + if let ratio = delegate?.card(cardSwipeThresholdRatioMargin: self) , ratio != 0 { swipePercentageMargin = ratio } else { swipePercentageMargin = 1.0 @@ -90,7 +90,7 @@ public class DraggableCardView: UIView, UIGestureRecognizerDelegate { } //MARK: Configurations - func configure(view: UIView, overlayView: OverlayView?) { + func configure(_ view: UIView, overlayView: OverlayView?) { self.overlayView?.removeFromSuperview() self.contentView?.removeFromSuperview() @@ -114,34 +114,34 @@ public class DraggableCardView: UIView, UIGestureRecognizerDelegate { let width = NSLayoutConstraint( item: overlay, - attribute: NSLayoutAttribute.Width, - relatedBy: NSLayoutRelation.Equal, + attribute: NSLayoutAttribute.width, + relatedBy: NSLayoutRelation.equal, toItem: self, - attribute: NSLayoutAttribute.Width, + attribute: NSLayoutAttribute.width, multiplier: 1.0, constant: 0) let height = NSLayoutConstraint( item: overlay, - attribute: NSLayoutAttribute.Height, - relatedBy: NSLayoutRelation.Equal, + attribute: NSLayoutAttribute.height, + relatedBy: NSLayoutRelation.equal, toItem: self, - attribute: NSLayoutAttribute.Height, + attribute: NSLayoutAttribute.height, multiplier: 1.0, constant: 0) let top = NSLayoutConstraint ( item: overlay, - attribute: NSLayoutAttribute.Top, - relatedBy: NSLayoutRelation.Equal, + attribute: NSLayoutAttribute.top, + relatedBy: NSLayoutRelation.equal, toItem: self, - attribute: NSLayoutAttribute.Top, + attribute: NSLayoutAttribute.top, multiplier: 1.0, constant: 0) let leading = NSLayoutConstraint ( item: overlay, - attribute: NSLayoutAttribute.Leading, - relatedBy: NSLayoutRelation.Equal, + attribute: NSLayoutAttribute.leading, + relatedBy: NSLayoutRelation.equal, toItem: self, - attribute: NSLayoutAttribute.Leading, + attribute: NSLayoutAttribute.leading, multiplier: 1.0, constant: 0) addConstraints([width,height,top,leading]) @@ -154,34 +154,34 @@ public class DraggableCardView: UIView, UIGestureRecognizerDelegate { let width = NSLayoutConstraint( item: contentView, - attribute: NSLayoutAttribute.Width, - relatedBy: NSLayoutRelation.Equal, + attribute: NSLayoutAttribute.width, + relatedBy: NSLayoutRelation.equal, toItem: self, - attribute: NSLayoutAttribute.Width, + attribute: NSLayoutAttribute.width, multiplier: 1.0, constant: 0) let height = NSLayoutConstraint( item: contentView, - attribute: NSLayoutAttribute.Height, - relatedBy: NSLayoutRelation.Equal, + attribute: NSLayoutAttribute.height, + relatedBy: NSLayoutRelation.equal, toItem: self, - attribute: NSLayoutAttribute.Height, + attribute: NSLayoutAttribute.height, multiplier: 1.0, constant: 0) let top = NSLayoutConstraint ( item: contentView, - attribute: NSLayoutAttribute.Top, - relatedBy: NSLayoutRelation.Equal, + attribute: NSLayoutAttribute.top, + relatedBy: NSLayoutRelation.equal, toItem: self, - attribute: NSLayoutAttribute.Top, + attribute: NSLayoutAttribute.top, multiplier: 1.0, constant: 0) let leading = NSLayoutConstraint ( item: contentView, - attribute: NSLayoutAttribute.Leading, - relatedBy: NSLayoutRelation.Equal, + attribute: NSLayoutAttribute.leading, + relatedBy: NSLayoutRelation.equal, toItem: self, - attribute: NSLayoutAttribute.Leading, + attribute: NSLayoutAttribute.leading, multiplier: 1.0, constant: 0) @@ -190,16 +190,16 @@ public class DraggableCardView: UIView, UIGestureRecognizerDelegate { } //MARK: GestureRecognizers - func panGestureRecognized(gestureRecognizer: UIPanGestureRecognizer) { - dragDistance = gestureRecognizer.translationInView(self) + func panGestureRecognized(_ gestureRecognizer: UIPanGestureRecognizer) { + dragDistance = gestureRecognizer.translation(in: self) - let touchLocation = gestureRecognizer.locationInView(self) + let touchLocation = gestureRecognizer.location(in: self) switch gestureRecognizer.state { - case .Began: + case .began: - let firstTouchPoint = gestureRecognizer.locationInView(self) - let newAnchorPoint = CGPointMake(firstTouchPoint.x / bounds.width, firstTouchPoint.y / bounds.height) + let firstTouchPoint = gestureRecognizer.location(in: self) + let newAnchorPoint = CGPoint(x: firstTouchPoint.x / bounds.width, y: firstTouchPoint.y / bounds.height) let oldPosition = CGPoint(x: bounds.size.width * layer.anchorPoint.x, y: bounds.size.height * layer.anchorPoint.y) let newPosition = CGPoint(x: bounds.size.width * newAnchorPoint.x, y: bounds.size.height * newAnchorPoint.y) layer.anchorPoint = newAnchorPoint @@ -209,11 +209,11 @@ public class DraggableCardView: UIView, UIGestureRecognizerDelegate { dragBegin = true animationDirectionY = touchLocation.y >= frame.size.height / 2 ? -1.0 : 1.0 - layer.rasterizationScale = UIScreen.mainScreen().scale + layer.rasterizationScale = UIScreen.main.scale layer.shouldRasterize = true - case .Changed: - let rotationStrength = min(dragDistance.x / CGRectGetWidth(frame), rotationMax) + case .changed: + let rotationStrength = min(dragDistance.x / frame.width, rotationMax) let rotationAngle = animationDirectionY * defaultRotationAngle * rotationStrength let scaleStrength = 1 - ((1 - scaleMin) * fabs(rotationStrength)) let scale = max(scaleStrength, scaleMin) @@ -231,7 +231,7 @@ public class DraggableCardView: UIView, UIGestureRecognizerDelegate { delegate?.card(self, wasDraggedWithFinishPercentage: min(fabs(100 * percentage), 100), inDirection: dragDirection) } - case .Ended: + case .ended: swipeMadeAction() layer.shouldRasterize = false @@ -242,18 +242,18 @@ public class DraggableCardView: UIView, UIGestureRecognizerDelegate { } } - public func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool { + public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool { return delegate?.card(cardShouldDrag: self) ?? true } - func tapRecognized(recogznier: UITapGestureRecognizer) { + func tapRecognized(_ recogznier: UITapGestureRecognizer) { delegate?.card(cardWasTapped: self) } //MARK: Private private var directions: [SwipeResultDirection] { - return delegate?.card(cardAllowedDirections: self) ?? [.Left, .Right] + return delegate?.card(cardAllowedDirections: self) ?? [.left, .right] } private var dragDirection: SwipeResultDirection? { @@ -289,52 +289,52 @@ public class DraggableCardView: UIView, UIGestureRecognizerDelegate { return rect.perimeterLines .flatMap { CGPoint.intersectionBetweenLines(targetLine, line2: $0) } .map { centerDistance / $0.distanceTo(.zero) } - .minElement() ?? 0 + .min() ?? 0 } } - private func updateOverlayWithFinishPercent(percent: CGFloat, direction: SwipeResultDirection?) { + private func updateOverlayWithFinishPercent(_ percent: CGFloat, direction: SwipeResultDirection?) { overlayView?.overlayState = direction let progress = max(min(percent/swipePercentageMargin, 1.0), 0) - overlayView?.updateWithProgress(progress) + overlayView?.update(progress: progress) } private func swipeMadeAction() { let shouldSwipe = { direction in - return self.delegate?.card(self, shouldSwipeInDirection: direction) ?? true + return self.delegate?.card(self, shouldSwipeIn: direction) ?? true } - if let dragDirection = dragDirection where shouldSwipe(dragDirection) && dragPercentage >= swipePercentageMargin && directions.contains(dragDirection) { + if let dragDirection = dragDirection , shouldSwipe(dragDirection) && dragPercentage >= swipePercentageMargin && directions.contains(dragDirection) { swipeAction(dragDirection) } else { resetViewPositionAndTransformations() } } - private func animationPointForDirection(direction: SwipeResultDirection) -> CGPoint { + private func animationPointForDirection(_ direction: SwipeResultDirection) -> CGPoint { let point = direction.point let animatePoint = CGPoint(x: point.x * 4, y: point.y * 4) //should be 2 let retPoint = animatePoint.screenPointForSize(screenSize) return retPoint } - private func animationRotationForDirection(direction: SwipeResultDirection) -> CGFloat { + private func animationRotationForDirection(_ direction: SwipeResultDirection) -> CGFloat { return CGFloat(direction.bearing / 2.0 - M_PI_4) } - private func swipeAction(direction: SwipeResultDirection) { + private func swipeAction(_ direction: SwipeResultDirection) { overlayView?.overlayState = direction overlayView?.alpha = 1.0 - delegate?.card(self, wasSwipedInDirection: direction) + delegate?.card(self, wasSwipedIn: direction) let translationAnimation = POPBasicAnimation(propertyNamed: kPOPLayerTranslationXY) - translationAnimation.duration = cardSwipeActionAnimationDuration - translationAnimation.fromValue = NSValue(CGPoint: POPLayerGetTranslationXY(layer)) - translationAnimation.toValue = NSValue(CGPoint: animationPointForDirection(direction)) - translationAnimation.completionBlock = { _, _ in + translationAnimation?.duration = cardSwipeActionAnimationDuration + translationAnimation?.fromValue = NSValue(cgPoint: POPLayerGetTranslationXY(layer)) + translationAnimation?.toValue = NSValue(cgPoint: animationPointForDirection(direction)) + translationAnimation?.completionBlock = { _, _ in self.removeFromSuperview() } - layer.pop_addAnimation(translationAnimation, forKey: "swipeTranslationAnimation") + layer.pop_add(translationAnimation, forKey: "swipeTranslationAnimation") } private func resetViewPositionAndTransformations() { @@ -343,37 +343,37 @@ public class DraggableCardView: UIView, UIGestureRecognizerDelegate { removeAnimations() let resetPositionAnimation = POPSpringAnimation(propertyNamed: kPOPLayerTranslationXY) - resetPositionAnimation.fromValue = NSValue(CGPoint:POPLayerGetTranslationXY(layer)) - resetPositionAnimation.toValue = NSValue(CGPoint: CGPointZero) - resetPositionAnimation.springBounciness = cardResetAnimationSpringBounciness - resetPositionAnimation.springSpeed = cardResetAnimationSpringSpeed - resetPositionAnimation.completionBlock = { + resetPositionAnimation?.fromValue = NSValue(cgPoint:POPLayerGetTranslationXY(layer)) + resetPositionAnimation?.toValue = NSValue(cgPoint: CGPoint.zero) + resetPositionAnimation?.springBounciness = cardResetAnimationSpringBounciness + resetPositionAnimation?.springSpeed = cardResetAnimationSpringSpeed + resetPositionAnimation?.completionBlock = { (_, _) in self.layer.transform = CATransform3DIdentity self.dragBegin = false } - layer.pop_addAnimation(resetPositionAnimation, forKey: "resetPositionAnimation") + layer.pop_add(resetPositionAnimation, forKey: "resetPositionAnimation") let resetRotationAnimation = POPBasicAnimation(propertyNamed: kPOPLayerRotation) - resetRotationAnimation.fromValue = POPLayerGetRotationZ(layer) - resetRotationAnimation.toValue = CGFloat(0.0) - resetRotationAnimation.duration = cardResetAnimationDuration + resetRotationAnimation?.fromValue = POPLayerGetRotationZ(layer) + resetRotationAnimation?.toValue = CGFloat(0.0) + resetRotationAnimation?.duration = cardResetAnimationDuration - layer.pop_addAnimation(resetRotationAnimation, forKey: "resetRotationAnimation") + layer.pop_add(resetRotationAnimation, forKey: "resetRotationAnimation") let overlayAlphaAnimation = POPBasicAnimation(propertyNamed: kPOPViewAlpha) - overlayAlphaAnimation.toValue = 0.0 - overlayAlphaAnimation.duration = cardResetAnimationDuration - overlayAlphaAnimation.completionBlock = { _, _ in + overlayAlphaAnimation?.toValue = 0.0 + overlayAlphaAnimation?.duration = cardResetAnimationDuration + overlayAlphaAnimation?.completionBlock = { _, _ in self.overlayView?.alpha = 0 } - overlayView?.pop_addAnimation(overlayAlphaAnimation, forKey: "resetOverlayAnimation") + overlayView?.pop_add(overlayAlphaAnimation, forKey: "resetOverlayAnimation") let resetScaleAnimation = POPBasicAnimation(propertyNamed: kPOPLayerScaleXY) - resetScaleAnimation.toValue = NSValue(CGPoint: CGPoint(x: 1.0, y: 1.0)) - resetScaleAnimation.duration = cardResetAnimationDuration - layer.pop_addAnimation(resetScaleAnimation, forKey: "resetScaleAnimation") + resetScaleAnimation?.toValue = NSValue(cgPoint: CGPoint(x: 1.0, y: 1.0)) + resetScaleAnimation?.duration = cardResetAnimationDuration + layer.pop_add(resetScaleAnimation, forKey: "resetScaleAnimation") } //MARK: Public @@ -382,33 +382,33 @@ public class DraggableCardView: UIView, UIGestureRecognizerDelegate { layer.pop_removeAllAnimations() } - func swipe(direction: SwipeResultDirection) { + func swipe(_ direction: SwipeResultDirection) { if !dragBegin { - delegate?.card(self, wasSwipedInDirection: direction) + delegate?.card(self, wasSwipedIn: direction) let swipePositionAnimation = POPBasicAnimation(propertyNamed: kPOPLayerTranslationXY) - swipePositionAnimation.fromValue = NSValue(CGPoint:POPLayerGetTranslationXY(layer)) - swipePositionAnimation.toValue = NSValue(CGPoint:animationPointForDirection(direction)) - swipePositionAnimation.duration = cardSwipeActionAnimationDuration - swipePositionAnimation.completionBlock = { + swipePositionAnimation?.fromValue = NSValue(cgPoint:POPLayerGetTranslationXY(layer)) + swipePositionAnimation?.toValue = NSValue(cgPoint:animationPointForDirection(direction)) + swipePositionAnimation?.duration = cardSwipeActionAnimationDuration + swipePositionAnimation?.completionBlock = { (_, _) in self.removeFromSuperview() } - layer.pop_addAnimation(swipePositionAnimation, forKey: "swipePositionAnimation") + layer.pop_add(swipePositionAnimation, forKey: "swipePositionAnimation") let swipeRotationAnimation = POPBasicAnimation(propertyNamed: kPOPLayerRotation) - swipeRotationAnimation.fromValue = POPLayerGetRotationZ(layer) - swipeRotationAnimation.toValue = CGFloat(animationRotationForDirection(direction)) - swipeRotationAnimation.duration = cardSwipeActionAnimationDuration + swipeRotationAnimation?.fromValue = POPLayerGetRotationZ(layer) + swipeRotationAnimation?.toValue = CGFloat(animationRotationForDirection(direction)) + swipeRotationAnimation?.duration = cardSwipeActionAnimationDuration - layer.pop_addAnimation(swipeRotationAnimation, forKey: "swipeRotationAnimation") + layer.pop_add(swipeRotationAnimation, forKey: "swipeRotationAnimation") overlayView?.overlayState = direction let overlayAlphaAnimation = POPBasicAnimation(propertyNamed: kPOPViewAlpha) - overlayAlphaAnimation.toValue = 1.0 - overlayAlphaAnimation.duration = cardSwipeActionAnimationDuration - overlayView?.pop_addAnimation(overlayAlphaAnimation, forKey: "swipeOverlayAnimation") + overlayAlphaAnimation?.toValue = 1.0 + overlayAlphaAnimation?.duration = cardSwipeActionAnimationDuration + overlayView?.pop_add(overlayAlphaAnimation, forKey: "swipeOverlayAnimation") } } } diff --git a/Pod/Classes/KolodaView/KolodaCardStorage.swift b/Pod/Classes/KolodaView/KolodaCardStorage.swift index 9c3f85f4..b9fdc018 100644 --- a/Pod/Classes/KolodaView/KolodaCardStorage.swift +++ b/Pod/Classes/KolodaView/KolodaCardStorage.swift @@ -11,23 +11,23 @@ import UIKit extension KolodaView { - func createCardAtIndex(index: UInt, frame: CGRect? = nil) -> DraggableCardView { + func createCard(at index: Int, frame: CGRect? = nil) -> DraggableCardView { let cardView = generateCard(frame ?? frameForTopCard()) - configureCard(cardView, atIndex: index) + configureCard(cardView, at: index) return cardView } - func generateCard(frame: CGRect) -> DraggableCardView { + func generateCard(_ frame: CGRect) -> DraggableCardView { let cardView = DraggableCardView(frame: frame) cardView.delegate = self return cardView } - func configureCard(card: DraggableCardView, atIndex index: UInt) { - let contentView = dataSource!.koloda(self, viewForCardAtIndex: index) - card.configure(contentView, overlayView: dataSource?.koloda(self, viewForCardOverlayAtIndex: index)) + func configureCard(_ card: DraggableCardView, at index: Int) { + let contentView = dataSource!.koloda(self, viewForCardAt: index) + card.configure(contentView, overlayView: dataSource?.koloda(self, viewForCardOverlayAt: index)) } -} \ No newline at end of file +} diff --git a/Pod/Classes/KolodaView/KolodaView.swift b/Pod/Classes/KolodaView/KolodaView.swift index 6991cbfb..079d1df1 100644 --- a/Pod/Classes/KolodaView/KolodaView.swift +++ b/Pod/Classes/KolodaView/KolodaView.swift @@ -14,67 +14,68 @@ private let defaultCountOfVisibleCards = 3 private let defaultBackgroundCardsTopMargin: CGFloat = 4.0 private let defaultBackgroundCardsScalePercent: CGFloat = 0.95 private let defaultBackgroundCardsLeftMargin: CGFloat = 8.0 -private let defaultBackgroundCardFrameAnimationDuration: NSTimeInterval = 0.2 +private let defaultBackgroundCardFrameAnimationDuration: TimeInterval = 0.2 //Opacity values private let defaultAlphaValueOpaque: CGFloat = 1.0 private let defaultAlphaValueTransparent: CGFloat = 0.0 private let defaultAlphaValueSemiTransparent: CGFloat = 0.7 -public protocol KolodaViewDataSource:class { +public protocol KolodaViewDataSource: class { - func kolodaNumberOfCards(koloda: KolodaView) -> UInt - func koloda(koloda: KolodaView, viewForCardAtIndex index: UInt) -> UIView - func koloda(koloda: KolodaView, viewForCardOverlayAtIndex index: UInt) -> OverlayView? + func kolodaNumberOfCards(_ koloda: KolodaView) -> Int + func koloda(_ koloda: KolodaView, viewForCardAt index: Int) -> UIView + func koloda(_ koloda: KolodaView, viewForCardOverlayAt index: Int) -> OverlayView? } public extension KolodaViewDataSource { - func koloda(koloda: KolodaView, viewForCardOverlayAtIndex index: UInt) -> OverlayView? { + func koloda(_ koloda: KolodaView, viewForCardOverlayAt index: Int) -> OverlayView? { return nil } } -public protocol KolodaViewDelegate:class { - - func koloda(koloda: KolodaView, allowedDirectionsForIndex index: UInt) -> [SwipeResultDirection] - func koloda(koloda: KolodaView, shouldSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) -> Bool - func koloda(koloda: KolodaView, didSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) - func kolodaDidRunOutOfCards(koloda: KolodaView) - func koloda(koloda: KolodaView, didSelectCardAtIndex index: UInt) - func kolodaShouldApplyAppearAnimation(koloda: KolodaView) -> Bool - func kolodaShouldMoveBackgroundCard(koloda: KolodaView) -> Bool - func kolodaShouldTransparentizeNextCard(koloda: KolodaView) -> Bool - func koloda(koloda: KolodaView, draggedCardWithPercentage finishPercentage: CGFloat, inDirection direction: SwipeResultDirection) - func kolodaDidResetCard(koloda: KolodaView) - func kolodaSwipeThresholdRatioMargin(koloda: KolodaView) -> CGFloat? - func koloda(koloda: KolodaView, didShowCardAtIndex index: UInt) - func koloda(koloda: KolodaView, shouldDragCardAtIndex index: UInt ) -> Bool +public protocol KolodaViewDelegate: class { + + func koloda(_ koloda: KolodaView, allowedDirectionsForIndex index: Int) -> [SwipeResultDirection] + func koloda(_ koloda: KolodaView, shouldSwipeCardAt index: Int, in direction: SwipeResultDirection) -> Bool + func koloda(_ koloda: KolodaView, didSwipeCardAt index: Int, in direction: SwipeResultDirection) + func kolodaDidRunOutOfCards(_ koloda: KolodaView) + func koloda(_ koloda: KolodaView, didSelectCardAt index: Int) + func kolodaShouldApplyAppearAnimation(_ koloda: KolodaView) -> Bool + func kolodaShouldMoveBackgroundCard(_ koloda: KolodaView) -> Bool + func kolodaShouldTransparentizeNextCard(_ koloda: KolodaView) -> Bool + func koloda(_ koloda: KolodaView, draggedCardWithPercentage finishPercentage: CGFloat, in direction: SwipeResultDirection) + func kolodaDidResetCard(_ koloda: KolodaView) + func kolodaSwipeThresholdRatioMargin(_ koloda: KolodaView) -> CGFloat? + func koloda(_ koloda: KolodaView, didShowCardAt index: Int) + func koloda(_ koloda: KolodaView, shouldDragCardAt index: Int ) -> Bool } public extension KolodaViewDelegate { - func koloda(koloda: KolodaView, shouldSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) -> Bool { return true } - - func koloda(koloda: KolodaView, allowedDirectionsForIndex index: UInt) -> [SwipeResultDirection] { return [.Left, .Right] } - func koloda(koloda: KolodaView, didSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) {} - func kolodaDidRunOutOfCards(koloda: KolodaView) {} - func koloda(koloda: KolodaView, didSelectCardAtIndex index: UInt) {} - func kolodaShouldApplyAppearAnimation(koloda: KolodaView) -> Bool { return true } - func kolodaShouldMoveBackgroundCard(koloda: KolodaView) -> Bool { return true } - func kolodaShouldTransparentizeNextCard(koloda: KolodaView) -> Bool { return true } - func koloda(koloda: KolodaView, draggedCardWithPercentage finishPercentage: CGFloat, inDirection direction: SwipeResultDirection) {} - func kolodaDidResetCard(koloda: KolodaView) {} - func kolodaSwipeThresholdRatioMargin(koloda: KolodaView) -> CGFloat? { return nil} - func koloda(koloda: KolodaView, didShowCardAtIndex index: UInt) {} - func koloda(koloda: KolodaView, shouldDragCardAtIndex index: UInt ) -> Bool { return true } + + func koloda(_ koloda: KolodaView, shouldSwipeCardAt index: Int, in direction: SwipeResultDirection) -> Bool { return true } + + func koloda(_ koloda: KolodaView, allowedDirectionsForIndex index: Int) -> [SwipeResultDirection] { return [.left, .right] } + func koloda(_ koloda: KolodaView, didSwipeCardAt index: Int, in direction: SwipeResultDirection) {} + func kolodaDidRunOutOfCards(_ koloda: KolodaView) {} + func koloda(_ koloda: KolodaView, didSelectCardAt index: Int) {} + func kolodaShouldApplyAppearAnimation(_ koloda: KolodaView) -> Bool { return true } + func kolodaShouldMoveBackgroundCard(_ koloda: KolodaView) -> Bool { return true } + func kolodaShouldTransparentizeNextCard(_ koloda: KolodaView) -> Bool { return true } + func koloda(_ koloda: KolodaView, draggedCardWithPercentage finishPercentage: CGFloat, in direction: SwipeResultDirection) {} + func kolodaDidResetCard(_ koloda: KolodaView) {} + func kolodaSwipeThresholdRatioMargin(_ koloda: KolodaView) -> CGFloat? { return nil} + func koloda(_ koloda: KolodaView, didShowCardAt index: Int) {} + func koloda(_ koloda: KolodaView, shouldDragCardAt index: Int ) -> Bool { return true } } -public class KolodaView: UIView, DraggableCardDelegate { - +open class KolodaView: UIView, DraggableCardDelegate { + //Opacity values public var alphaValueOpaque = defaultAlphaValueOpaque public var alphaValueTransparent = defaultAlphaValueTransparent @@ -103,8 +104,8 @@ public class KolodaView: UIView, DraggableCardDelegate { private(set) public var countOfCards = 0 public var countOfVisibleCards = defaultCountOfVisibleCards private var visibleCards = [DraggableCardView]() - - override public func layoutSubviews() { + + override open func layoutSubviews() { super.layoutSubviews() if !animating { @@ -112,20 +113,20 @@ public class KolodaView: UIView, DraggableCardDelegate { } } - //MARK: Configurations + // MARK: Configurations private func setupDeck() { if let dataSource = dataSource { - countOfCards = Int(dataSource.kolodaNumberOfCards(self)) + countOfCards = dataSource.kolodaNumberOfCards(self) if countOfCards - currentCardIndex > 0 { let countOfNeededCards = min(countOfVisibleCards, countOfCards - currentCardIndex) for index in 0.. CGRect { - let bottomOffset:CGFloat = 0 + // MARK: Frames + open func frameForCard(at index: Int) -> CGRect { + let bottomOffset: CGFloat = 0 let topOffset = defaultBackgroundCardsTopMargin * CGFloat(countOfVisibleCards - 1) let scalePercent = defaultBackgroundCardsScalePercent - let width = CGRectGetWidth(self.frame) * pow(scalePercent, CGFloat(index)) - let xOffset = (CGRectGetWidth(self.frame) - width) / 2 - let height = (CGRectGetHeight(self.frame) - bottomOffset - topOffset) * pow(scalePercent, CGFloat(index)) + let width = self.frame.width * pow(scalePercent, CGFloat(index)) + let xOffset = (self.frame.width - width) / 2 + let height = (self.frame.height - bottomOffset - topOffset) * pow(scalePercent, CGFloat(index)) let multiplier: CGFloat = index > 0 ? 1.0 : 0.0 - let previousCardFrame = index > 0 ? frameForCardAtIndex(max(index - 1, 0)) : CGRectZero - let yOffset = (CGRectGetHeight(previousCardFrame) - height + previousCardFrame.origin.y + defaultBackgroundCardsTopMargin) * multiplier + let prevCardFrame = index > 0 ? frameForCard(at: max(index - 1, 0)) : .zero + let yOffset = (prevCardFrame.height - height + prevCardFrame.origin.y + defaultBackgroundCardsTopMargin) * multiplier let frame = CGRect(x: xOffset, y: yOffset, width: width, height: height) return frame } internal func frameForTopCard() -> CGRect { - return frameForCardAtIndex(0) + return frameForCard(at: 0) } - internal func backgroundCardParametersForFrame(initialFrame: CGRect) -> (frame: CGRect, scale: CGSize) { + internal func backgroundCardParametersForFrame(_ initialFrame: CGRect) -> (frame: CGRect, scale: CGSize) { var finalFrame = frameForTopCard() finalFrame.origin = initialFrame.origin @@ -187,85 +188,86 @@ public class KolodaView: UIView, DraggableCardDelegate { return (finalFrame, scale) } - internal func moveOtherCardsWithPercentage(percentage: CGFloat) { - if visibleCards.count > 1 { - for index in 1.. 1 else { + return + } + for index in 1.. Bool { - return delegate?.koloda(self, shouldSwipeCardAtIndex: UInt(self.currentCardIndex), inDirection: direction) ?? true + func card(_ card: DraggableCardView, shouldSwipeIn direction: SwipeResultDirection) -> Bool { + return delegate?.koloda(self, shouldSwipeCardAt: self.currentCardIndex, in: direction) ?? true } func card(cardAllowedDirections card: DraggableCardView) -> [SwipeResultDirection] { - let index = currentCardIndex + visibleCards.indexOf(card)! - return delegate?.koloda(self, allowedDirectionsForIndex: UInt(index)) ?? [.Left, .Right] + let index = currentCardIndex + visibleCards.index(of: card)! + return delegate?.koloda(self, allowedDirectionsForIndex: index) ?? [.left, .right] } - func card(card: DraggableCardView, wasSwipedInDirection direction: SwipeResultDirection) { + func card(_ card: DraggableCardView, wasSwipedIn direction: SwipeResultDirection) { swipedAction(direction) } @@ -294,10 +296,10 @@ public class KolodaView: UIView, DraggableCardDelegate { } func card(cardWasTapped card: DraggableCardView) { - guard let visibleIndex = visibleCards.indexOf(card) else { return } + guard let visibleIndex = visibleCards.index(of: card) else { return } let index = currentCardIndex + visibleIndex - delegate?.koloda(self, didSelectCardAtIndex: UInt(index)) + delegate?.koloda(self, didSelectCardAt: index) } func card(cardSwipeThresholdRatioMargin card: DraggableCardView) -> CGFloat? { @@ -305,13 +307,13 @@ public class KolodaView: UIView, DraggableCardDelegate { } func card(cardShouldDrag card: DraggableCardView) -> Bool { - guard let visibleIndex = visibleCards.indexOf(card) else { return true} + guard let visibleIndex = visibleCards.index(of: card) else { return true} let index = currentCardIndex + visibleIndex - return delegate?.koloda(self, shouldDragCardAtIndex: UInt(index)) ?? true + return delegate?.koloda(self, shouldDragCardAt: index) ?? true } - //MARK: Private + // MARK: Private private func clear() { currentCardIndex = 0 @@ -319,11 +321,11 @@ public class KolodaView: UIView, DraggableCardDelegate { card.removeFromSuperview() } - visibleCards.removeAll(keepCapacity: true) + visibleCards.removeAll(keepingCapacity: true) } - //MARK: Actions - private func swipedAction(direction: SwipeResultDirection) { + // MARK: Actions + private func swipedAction(_ direction: SwipeResultDirection) { animating = true visibleCards.removeFirst() @@ -339,14 +341,14 @@ public class KolodaView: UIView, DraggableCardDelegate { return } - _self.visibleCards.last?.hidden = false + _self.visibleCards.last?.isHidden = false _self.animating = false - _self.delegate?.koloda(_self, didSwipeCardAtIndex: UInt(_self.currentCardIndex - 1), inDirection: direction) - _self.delegate?.koloda(_self, didShowCardAtIndex: UInt(_self.currentCardIndex)) + _self.delegate?.koloda(_self, didSwipeCardAt: _self.currentCardIndex - 1, in: direction) + _self.delegate?.koloda(_self, didShowCardAt: _self.currentCardIndex) } } else { animating = false - delegate?.koloda(self, didSwipeCardAtIndex: UInt(self.currentCardIndex - 1), inDirection: direction) + delegate?.koloda(self, didSwipeCardAt: self.currentCardIndex - 1, in: direction) delegate?.kolodaDidRunOutOfCards(self) } } @@ -356,13 +358,13 @@ public class KolodaView: UIView, DraggableCardDelegate { return } - let cardParameters = backgroundCardParametersForFrame(frameForCardAtIndex(UInt(visibleCards.count))) - let lastCard = createCardAtIndex(UInt(currentCardIndex + countOfVisibleCards - 1), frame: cardParameters.frame) + let cardParameters = backgroundCardParametersForFrame(frameForCard(at: visibleCards.count)) + let lastCard = createCard(at: currentCardIndex + countOfVisibleCards - 1, frame: cardParameters.frame) let scale = cardParameters.scale lastCard.layer.transform = CATransform3DScale(CATransform3DIdentity, scale.width, scale.height, 1) - lastCard.hidden = true - lastCard.userInteractionEnabled = true + lastCard.isHidden = true + lastCard.isUserInteractionEnabled = true if let card = visibleCards.last { insertSubview(lastCard, belowSubview: card) @@ -372,12 +374,12 @@ public class KolodaView: UIView, DraggableCardDelegate { visibleCards.append(lastCard) } - private func animateCardsAfterLoadingWithCompletion(completion: (Void -> Void)? = nil) { - for (index, currentCard) in visibleCards.enumerate() { + private func animateCardsAfterLoadingWithCompletion(_ completion: ((Void) -> Void)? = nil) { + for (index, currentCard) in visibleCards.enumerated() { currentCard.removeAnimations() - currentCard.userInteractionEnabled = index == 0 - let cardParameters = backgroundCardParametersForFrame(frameForCardAtIndex(UInt(index))) + currentCard.isUserInteractionEnabled = index == 0 + let cardParameters = backgroundCardParametersForFrame(frameForCard(at: index)) var animationCompletion: ((Bool) -> Void)? = nil if index != 0 { if shouldTransparentizeNextCard { @@ -406,83 +408,83 @@ public class KolodaView: UIView, DraggableCardDelegate { } public func revertAction() { - if currentCardIndex > 0 && !animating { - - if countOfCards - currentCardIndex >= countOfVisibleCards { - if let lastCard = visibleCards.last { - lastCard.removeFromSuperview() - visibleCards.removeLast() - } + guard currentCardIndex > 0 && !animating else { + return + } + if countOfCards - currentCardIndex >= countOfVisibleCards { + if let lastCard = visibleCards.last { + lastCard.removeFromSuperview() + visibleCards.removeLast() } - currentCardIndex -= 1 + } + currentCardIndex -= 1 + + if dataSource != nil { + let firstCardView = createCard(at: currentCardIndex, frame: frameForTopCard()) - if dataSource != nil { - let firstCardView = createCardAtIndex(UInt(currentCardIndex), frame: frameForTopCard()) - - if shouldTransparentizeNextCard { - firstCardView.alpha = alphaValueTransparent - } - firstCardView.delegate = self - - addSubview(firstCardView) - visibleCards.insert(firstCardView, atIndex: 0) - - animating = true - animator.applyReverseAnimation(firstCardView, completion: { [weak self] _ in - guard let _self = self else { - return - } - - _self.animating = false - _self.delegate?.koloda(_self, didShowCardAtIndex: UInt(_self.currentCardIndex)) - }) + if shouldTransparentizeNextCard { + firstCardView.alpha = alphaValueTransparent } + firstCardView.delegate = self - for (index, card) in visibleCards.dropFirst().enumerate() { - if shouldTransparentizeNextCard { - card.alpha = alphaValueSemiTransparent + addSubview(firstCardView) + visibleCards.insert(firstCardView, at: 0) + + animating = true + animator.applyReverseAnimation(firstCardView, completion: { [weak self] _ in + guard let _self = self else { + return } - card.userInteractionEnabled = false - let cardParameters = backgroundCardParametersForFrame(frameForCardAtIndex(UInt(index + 1))) - animator.applyScaleAnimation( - card, - scale: cardParameters.scale, - frame: cardParameters.frame, - duration: defaultBackgroundCardFrameAnimationDuration, - completion: nil - ) + _self.animating = false + _self.delegate?.koloda(_self, didShowCardAt: _self.currentCardIndex) + }) + } + + for (index, card) in visibleCards.dropFirst().enumerated() { + if shouldTransparentizeNextCard { + card.alpha = alphaValueSemiTransparent } + card.isUserInteractionEnabled = false + + let cardParameters = backgroundCardParametersForFrame(frameForCard(at: index + 1)) + animator.applyScaleAnimation( + card, + scale: cardParameters.scale, + frame: cardParameters.frame, + duration: defaultBackgroundCardFrameAnimationDuration, + completion: nil + ) } } - - private func loadMissingCards(missingCardsCount: Int) { - if missingCardsCount > 0 { - let cardsToAdd = min(missingCardsCount, countOfCards - currentCardIndex) - let startIndex = visibleCards.count - let endIndex = startIndex + cardsToAdd - 1 - - for index in startIndex...endIndex { - let nextCardView = generateCard(frameForTopCard()) - layoutCard(nextCardView, atIndex: UInt(index)) - nextCardView.alpha = shouldTransparentizeNextCard ? alphaValueSemiTransparent : alphaValueOpaque - - visibleCards.append(nextCardView) - configureCard(nextCardView, atIndex: UInt(currentCardIndex + index)) - if index > 0 { - insertSubview(nextCardView, belowSubview: visibleCards[index - 1]) - } else { - insertSubview(nextCardView, atIndex: 0) - } - } + + private func loadMissingCards(_ missingCardsCount: Int) { + guard missingCardsCount > 0 else { return } + + let cardsToAdd = min(missingCardsCount, countOfCards - currentCardIndex) + let startIndex = visibleCards.count + let endIndex = startIndex + cardsToAdd - 1 + + for index in startIndex...endIndex { + let nextCardView = generateCard(frameForTopCard()) + layoutCard(nextCardView, at: index) + nextCardView.alpha = shouldTransparentizeNextCard ? alphaValueSemiTransparent : alphaValueOpaque + + visibleCards.append(nextCardView) + configureCard(nextCardView, at: currentCardIndex + index) + if index > 0 { + insertSubview(nextCardView, belowSubview: visibleCards[index - 1]) + } else { + insertSubview(nextCardView, at: 0) + } } } - + private func reconfigureCards() { if dataSource != nil { - for (index, card) in visibleCards.enumerate() { - let actualIndex = UInt(currentCardIndex + index) - configureCard(card, atIndex: actualIndex) + for (index, card) in visibleCards.enumerated() { + let actualIndex = currentCardIndex + index + configureCard(card, at: actualIndex) } } } @@ -494,7 +496,7 @@ public class KolodaView: UIView, DraggableCardDelegate { // MARK: Public public func reloadData() { - guard let numberOfCards = dataSource?.kolodaNumberOfCards(self) where numberOfCards > 0 else { + guard let numberOfCards = dataSource?.kolodaNumberOfCards(self), numberOfCards > 0 else { clear() return } @@ -517,15 +519,14 @@ public class KolodaView: UIView, DraggableCardDelegate { reconfigureCards() } } - - public func swipe(direction: SwipeResultDirection,force: Bool = true) { - - let shouldSwipe = delegate?.koloda(self, shouldSwipeCardAtIndex: UInt(self.currentCardIndex), inDirection: direction) ?? true + + 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: UInt(currentCardIndex)).contains(direction) ?? true + let validDirection = delegate?.koloda(self, allowedDirectionsForIndex: currentCardIndex).contains(direction) ?? true guard validDirection else { return } if !animating { @@ -547,17 +548,17 @@ public class KolodaView: UIView, DraggableCardDelegate { reloadData() } - public func viewForCardAtIndex(index: Int) -> UIView? { + public func viewForCard(at index: Int) -> UIView? { if visibleCards.count + currentCardIndex > index && index >= currentCardIndex { return visibleCards[index - currentCardIndex].contentView } else { return nil } } - - public override func pointInside(point: CGPoint, withEvent event: UIEvent?) -> Bool { + + override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { if !shouldPassthroughTapsWhenNoVisibleCards { - return super.pointInside(point, withEvent: event) + return super.point(inside: point, with: event) } return visibleCards.count > 0 @@ -565,36 +566,36 @@ public class KolodaView: UIView, DraggableCardDelegate { // MARK: Cards managing - Insertion - private func insertVisibleCardsWithIndexes(visibleIndexes: [Int]) -> [DraggableCardView] { + private func insertVisibleCardsWithIndexes(_ visibleIndexes: [Int]) -> [DraggableCardView] { var insertedCards: [DraggableCardView] = [] visibleIndexes.forEach { insertionIndex in - let card = createCardAtIndex(UInt(insertionIndex)) + let card = createCard(at: insertionIndex) let visibleCardIndex = insertionIndex - currentCardIndex - visibleCards.insert(card, atIndex: visibleCardIndex) + visibleCards.insert(card, at: visibleCardIndex) if visibleCardIndex == 0 { - card.userInteractionEnabled = true + card.isUserInteractionEnabled = true card.alpha = alphaValueOpaque - insertSubview(card, atIndex: visibleCards.count - 1) + insertSubview(card, at: visibleCards.count - 1) } else { - card.userInteractionEnabled = false + card.isUserInteractionEnabled = false card.alpha = shouldTransparentizeNextCard ? alphaValueSemiTransparent : alphaValueOpaque insertSubview(card, belowSubview: visibleCards[visibleCardIndex - 1]) } - layoutCard(card, atIndex: UInt(visibleCardIndex)) + layoutCard(card, at: visibleCardIndex) insertedCards.append(card) } return insertedCards } - private func removeCards(cards: [DraggableCardView]) { + private func removeCards(_ cards: [DraggableCardView]) { cards.forEach { card in card.delegate = nil card.removeFromSuperview() } } - private func removeCards(cards: [DraggableCardView], animated: Bool) { + private func removeCards(_ cards: [DraggableCardView], animated: Bool) { visibleCards.removeLast(cards.count) if animated { animator.applyRemovalAnimation( @@ -608,16 +609,16 @@ public class KolodaView: UIView, DraggableCardDelegate { } } - public func insertCardAtIndexRange(indexRange: Range, animated: Bool = true) { + public func insertCardAtIndexRange(_ indexRange: CountableRange, animated: Bool = true) { guard let dataSource = dataSource else { return } let currentItemsCount = countOfCards - countOfCards = Int(dataSource.kolodaNumberOfCards(self)) + countOfCards = dataSource.kolodaNumberOfCards(self) let visibleIndexes = [Int](indexRange).filter { $0 >= currentCardIndex && $0 < currentCardIndex + countOfVisibleCards } - let insertedCards = insertVisibleCardsWithIndexes(visibleIndexes.sort()) + let insertedCards = insertVisibleCardsWithIndexes(visibleIndexes.sorted()) let cardsToRemove = visibleCards.dropFirst(countOfVisibleCards).map { $0 } removeCards(cardsToRemove, animated: animated) animator.resetBackgroundCardsWithCompletion() @@ -639,25 +640,25 @@ public class KolodaView: UIView, DraggableCardDelegate { // MARK: Cards managing - Deletion - private func proceedDeletionInRange(range: Range) { + private func proceedDeletionInRange(_ range: CountableClosedRange) { let deletionIndexes = [Int](range) - deletionIndexes.sort { $0 > $1 }.forEach { deletionIndex in + deletionIndexes.sorted { $0 > $1 }.forEach { deletionIndex in let visibleCardIndex = deletionIndex - currentCardIndex let card = visibleCards[visibleCardIndex] card.delegate = nil - card.swipe(.Right) - visibleCards.removeAtIndex(visibleCardIndex) + card.swipe(.right) + visibleCards.remove(at: visibleCardIndex) } } - public func removeCardInIndexRange(indexRange: Range, animated: Bool) { + public func removeCardInIndexRange(_ indexRange: CountableRange, animated: Bool) { guard let dataSource = dataSource else { return } animating = true let currentItemsCount = countOfCards - countOfCards = Int(dataSource.kolodaNumberOfCards(self)) + countOfCards = dataSource.kolodaNumberOfCards(self) let visibleIndexes = [Int](indexRange).filter { $0 >= currentCardIndex && $0 < currentCardIndex + countOfVisibleCards } if !visibleIndexes.isEmpty { proceedDeletionInRange(visibleIndexes[0]...visibleIndexes[visibleIndexes.count - 1]) @@ -665,9 +666,9 @@ public class KolodaView: UIView, DraggableCardDelegate { currentCardIndex -= Array(indexRange).filter { $0 < currentCardIndex }.count loadMissingCards(missingCardsCount()) layoutDeck() - for (index, card) in visibleCards.enumerate() { + for (index, card) in visibleCards.enumerated() { card.alpha = shouldTransparentizeNextCard && index != 0 ? alphaValueSemiTransparent : alphaValueOpaque - card.userInteractionEnabled = index == 0 + card.isUserInteractionEnabled = index == 0 } animating = false @@ -679,7 +680,7 @@ public class KolodaView: UIView, DraggableCardDelegate { // MARK: Cards managing - Reloading - public func reloadCardsInIndexRange(indexRange: Range) { + public func reloadCardsInIndexRange(_ indexRange: CountableRange) { guard dataSource != nil else { return } @@ -689,7 +690,7 @@ public class KolodaView: UIView, DraggableCardDelegate { let visibleCardIndex = index - currentCardIndex if visibleCards.count > visibleCardIndex { let card = visibleCards[visibleCardIndex] - configureCard(card, atIndex: UInt(index)) + configureCard(card, at: index) } } } diff --git a/Pod/Classes/KolodaView/KolodaViewAnimatior.swift b/Pod/Classes/KolodaView/KolodaViewAnimatior.swift index 4d97e7ff..5850d426 100644 --- a/Pod/Classes/KolodaView/KolodaViewAnimatior.swift +++ b/Pod/Classes/KolodaView/KolodaViewAnimatior.swift @@ -10,7 +10,7 @@ import Foundation import UIKit import pop -public class KolodaViewAnimator { +open class KolodaViewAnimator { public typealias AnimationCompletionBlock = ((Bool) -> Void)? @@ -20,73 +20,73 @@ public class KolodaViewAnimator { self.koloda = koloda } - public func animateAppearanceWithCompletion(completion: AnimationCompletionBlock = nil) { + open func animateAppearanceWithCompletion(_ completion: AnimationCompletionBlock = nil) { let kolodaAppearScaleAnimation = POPBasicAnimation(propertyNamed: kPOPLayerScaleXY) - kolodaAppearScaleAnimation.beginTime = CACurrentMediaTime() + cardSwipeActionAnimationDuration - kolodaAppearScaleAnimation.duration = 0.8 - 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 + kolodaAppearScaleAnimation?.beginTime = CACurrentMediaTime() + cardSwipeActionAnimationDuration + kolodaAppearScaleAnimation?.duration = 0.8 + 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 completion?(finished) } let kolodaAppearAlphaAnimation = POPBasicAnimation(propertyNamed: kPOPViewAlpha) - kolodaAppearAlphaAnimation.beginTime = CACurrentMediaTime() + cardSwipeActionAnimationDuration - kolodaAppearAlphaAnimation.fromValue = NSNumber(float: 0.0) - kolodaAppearAlphaAnimation.toValue = NSNumber(float: 1.0) - kolodaAppearAlphaAnimation.duration = 0.8 + kolodaAppearAlphaAnimation?.beginTime = CACurrentMediaTime() + cardSwipeActionAnimationDuration + kolodaAppearAlphaAnimation?.fromValue = NSNumber(value: 0.0) + kolodaAppearAlphaAnimation?.toValue = NSNumber(value: 1.0) + kolodaAppearAlphaAnimation?.duration = 0.8 - koloda?.pop_addAnimation(kolodaAppearAlphaAnimation, forKey: "kolodaAppearScaleAnimation") - koloda?.layer.pop_addAnimation(kolodaAppearScaleAnimation, forKey: "kolodaAppearAlphaAnimation") + koloda?.pop_add(kolodaAppearAlphaAnimation, forKey: "kolodaAppearScaleAnimation") + koloda?.layer.pop_add(kolodaAppearScaleAnimation, forKey: "kolodaAppearAlphaAnimation") } - public func applyReverseAnimation(card: DraggableCardView, completion: AnimationCompletionBlock = nil) { + open func applyReverseAnimation(_ card: DraggableCardView, completion: AnimationCompletionBlock = nil) { let firstCardAppearAnimation = POPBasicAnimation(propertyNamed: kPOPViewAlpha) - firstCardAppearAnimation.toValue = NSNumber(float: 1.0) - firstCardAppearAnimation.fromValue = NSNumber(float: 0.0) - firstCardAppearAnimation.duration = 1.0 - firstCardAppearAnimation.completionBlock = { _, finished in + firstCardAppearAnimation?.toValue = NSNumber(value: 1.0) + firstCardAppearAnimation?.fromValue = NSNumber(value: 0.0) + firstCardAppearAnimation?.duration = 1.0 + firstCardAppearAnimation?.completionBlock = { _, finished in completion?(finished) card.alpha = 1.0 } - card.pop_addAnimation(firstCardAppearAnimation, forKey: "reverseCardAlphaAnimation") + card.pop_add(firstCardAppearAnimation, forKey: "reverseCardAlphaAnimation") } - public func applyScaleAnimation(card: DraggableCardView, scale: CGSize, frame: CGRect, duration: NSTimeInterval, completion: AnimationCompletionBlock = nil) { + open func applyScaleAnimation(_ card: DraggableCardView, scale: CGSize, frame: CGRect, duration: TimeInterval, completion: AnimationCompletionBlock = nil) { let scaleAnimation = POPBasicAnimation(propertyNamed: kPOPLayerScaleXY) - scaleAnimation.duration = duration - scaleAnimation.toValue = NSValue(CGSize: scale) - card.layer.pop_addAnimation(scaleAnimation, forKey: "scaleAnimation") + scaleAnimation?.duration = duration + scaleAnimation?.toValue = NSValue(cgSize: scale) + card.layer.pop_add(scaleAnimation, forKey: "scaleAnimation") let frameAnimation = POPBasicAnimation(propertyNamed: kPOPViewFrame) - frameAnimation.duration = duration - frameAnimation.toValue = NSValue(CGRect: frame) + frameAnimation?.duration = duration + frameAnimation?.toValue = NSValue(cgRect: frame) if let completion = completion { - frameAnimation.completionBlock = { _, finished in + frameAnimation?.completionBlock = { _, finished in completion(finished) } } - card.pop_addAnimation(frameAnimation, forKey: "frameAnimation") + card.pop_add(frameAnimation, forKey: "frameAnimation") } - public func applyAlphaAnimation(card: DraggableCardView, alpha: CGFloat, duration: NSTimeInterval = 0.2, completion: AnimationCompletionBlock = nil) { + open func applyAlphaAnimation(_ card: DraggableCardView, alpha: CGFloat, duration: TimeInterval = 0.2, completion: AnimationCompletionBlock = nil) { let alphaAnimation = POPBasicAnimation(propertyNamed: kPOPViewAlpha) - alphaAnimation.toValue = alpha - alphaAnimation.duration = duration - alphaAnimation.completionBlock = { _, finished in + alphaAnimation?.toValue = alpha + alphaAnimation?.duration = duration + alphaAnimation?.completionBlock = { _, finished in completion?(finished) } - card.pop_addAnimation(alphaAnimation, forKey: "alpha") + card.pop_add(alphaAnimation, forKey: "alpha") } - public func applyInsertionAnimation(cards: [DraggableCardView], completion: AnimationCompletionBlock = nil) { + open func applyInsertionAnimation(_ cards: [DraggableCardView], completion: AnimationCompletionBlock = nil) { cards.forEach { $0.alpha = 0.0 } - UIView.animateWithDuration( - 0.2, + UIView.animate( + withDuration: 0.2, animations: { cards.forEach { $0.alpha = 1.0 } }, @@ -96,9 +96,9 @@ public class KolodaViewAnimator { ) } - public func applyRemovalAnimation(cards: [DraggableCardView], completion: AnimationCompletionBlock = nil) { - UIView.animateWithDuration( - 0.05, + open func applyRemovalAnimation(_ cards: [DraggableCardView], completion: AnimationCompletionBlock = nil) { + UIView.animate( + withDuration: 0.05, animations: { cards.forEach { $0.alpha = 0.0 } }, @@ -108,11 +108,11 @@ public class KolodaViewAnimator { ) } - internal func resetBackgroundCardsWithCompletion(completion: AnimationCompletionBlock = nil) { - UIView.animateWithDuration( - 0.2, + internal func resetBackgroundCardsWithCompletion(_ completion: AnimationCompletionBlock = nil) { + UIView.animate( + withDuration: 0.2, delay: 0.0, - options: .CurveLinear, + options: .curveLinear, animations: { self.koloda?.moveOtherCardsWithPercentage(0) }, diff --git a/Pod/Classes/KolodaView/OverlayView/OverlayView.swift b/Pod/Classes/KolodaView/OverlayView/OverlayView.swift index abe6dc38..e4ee7ca6 100644 --- a/Pod/Classes/KolodaView/OverlayView/OverlayView.swift +++ b/Pod/Classes/KolodaView/OverlayView/OverlayView.swift @@ -8,16 +8,12 @@ import UIKit -public class OverlayView: UIView { +open class OverlayView: UIView { - public var overlayState: SwipeResultDirection? + open var overlayState: SwipeResultDirection? - @available(*, unavailable, message="Use updateWithProgress(percentage:) instead") - public var overlayStrength: CGFloat = 0.0 - - @available(*, introduced=3.1.2) - public func updateWithProgress(percentage: CGFloat) { - alpha = percentage + open func update(progress: CGFloat) { + alpha = progress } } diff --git a/Pod/Classes/KolodaView/SwipeResultDirection.swift b/Pod/Classes/KolodaView/SwipeResultDirection.swift index 8b1d73e2..5afcae98 100644 --- a/Pod/Classes/KolodaView/SwipeResultDirection.swift +++ b/Pod/Classes/KolodaView/SwipeResultDirection.swift @@ -10,28 +10,29 @@ import Foundation import CoreGraphics public enum SwipeResultDirection: String { - case Left - case Right - case Up - case Down - case TopLeft - case TopRight - case BottomLeft - case BottomRight + + case left + case right + case up + case down + case topLeft + case topRight + case bottomLeft + case bottomRight } extension SwipeResultDirection { private var swipeDirection: Direction { switch self { - case .Up: return .Up - case .Down: return .Down - case .Left: return .Left - case .Right: return .Right - case .TopLeft: return .TopLeft - case .TopRight: return .TopRight - case .BottomLeft: return .BottomLeft - case .BottomRight: return .BottomRight + case .up: return .up + case .down: return .down + case .left: return .left + case .right: return .right + case .topLeft: return .topLeft + case .topRight: return .topRight + case .bottomLeft: return .bottomLeft + case .bottomRight: return .bottomRight } } @@ -44,27 +45,30 @@ extension SwipeResultDirection { } static var boundsRect: CGRect { - let w = HorizontalPosition.Right.rawValue - HorizontalPosition.Left.rawValue - let h = VerticalPosition.Bottom.rawValue - VerticalPosition.Top.rawValue - return CGRect(x: HorizontalPosition.Left.rawValue, y: VerticalPosition.Top.rawValue, width: w, height: h) + let w = HorizontalPosition.right.rawValue - HorizontalPosition.left.rawValue + let h = VerticalPosition.bottom.rawValue - VerticalPosition.top.rawValue + return CGRect(x: HorizontalPosition.left.rawValue, y: VerticalPosition.top.rawValue, width: w, height: h) } } private enum VerticalPosition: CGFloat { - case Top = -1 - case Middle = 0 - case Bottom = 1 + + case top = -1 + case middle = 0 + case bottom = 1 } private enum HorizontalPosition: CGFloat { - case Left = -1 - case Middle = 0 - case Right = 1 + + case left = -1 + case middle = 0 + case right = 1 } private struct Direction { + let horizontalPosition:HorizontalPosition let verticalPosition:VerticalPosition @@ -73,43 +77,43 @@ private struct Direction { } var bearing: Double { - return self.point.bearingTo(Direction.None.point) + return self.point.bearingTo(Direction.none.point) } - static let None = Direction(horizontalPosition: .Middle, verticalPosition: .Middle) - static let Up = Direction(horizontalPosition: .Middle, verticalPosition: .Top) - static let Down = Direction(horizontalPosition: .Middle, verticalPosition: .Bottom) - static let Left = Direction(horizontalPosition: .Left, verticalPosition: .Middle) - static let Right = Direction(horizontalPosition: .Right, verticalPosition: .Middle) + static let none = Direction(horizontalPosition: .middle, verticalPosition: .middle) + static let up = Direction(horizontalPosition: .middle, verticalPosition: .top) + static let down = Direction(horizontalPosition: .middle, verticalPosition: .bottom) + static let left = Direction(horizontalPosition: .left, verticalPosition: .middle) + static let right = Direction(horizontalPosition: .right, verticalPosition: .middle) - static let TopLeft = Direction(horizontalPosition: .Left, verticalPosition: .Top) - static let TopRight = Direction(horizontalPosition: .Right, verticalPosition: .Top) - static let BottomLeft = Direction(horizontalPosition: .Left, verticalPosition: .Bottom) - static let BottomRight = Direction(horizontalPosition: .Right, verticalPosition: .Bottom) + static let topLeft = Direction(horizontalPosition: .left, verticalPosition: .top) + static let topRight = Direction(horizontalPosition: .right, verticalPosition: .top) + static let bottomLeft = Direction(horizontalPosition: .left, verticalPosition: .bottom) + static let bottomRight = Direction(horizontalPosition: .right, verticalPosition: .bottom) } //MARK: Geometry extension CGPoint { - func distanceTo(point: CGPoint) -> CGFloat { + func distanceTo(_ point: CGPoint) -> CGFloat { return sqrt(pow(point.x - self.x, 2) + pow(point.y - self.y, 2)) } - func bearingTo(point: CGPoint) -> Double { + func bearingTo(_ point: CGPoint) -> Double { return atan2(Double(point.y - self.y), Double(point.x - self.x)) } - func scalarProjectionWith(point: CGPoint) -> CGFloat { + func scalarProjectionWith(_ point: CGPoint) -> CGFloat { return dotProductWith(point) / point.modulo } - func scalarProjectionPointWith(point: CGPoint) -> CGPoint { + func scalarProjectionPointWith(_ point: CGPoint) -> CGPoint { let r = scalarProjectionWith(point) / point.modulo return CGPoint(x: point.x * r, y: point.y * r) } - func dotProductWith(point: CGPoint) -> CGFloat { + func dotProductWith(_ point: CGPoint) -> CGFloat { return (self.x * point.x) + (self.y * point.y) } @@ -117,7 +121,7 @@ extension CGPoint { return sqrt(self.x*self.x + self.y*self.y) } - func distanceToRect(rect: CGRect) -> CGFloat { + func distanceToRect(_ rect: CGRect) -> CGFloat { if rect.contains(self) { return distanceTo(CGPoint(x: rect.midX, y: rect.midY)) } @@ -130,26 +134,26 @@ extension CGPoint { } } - func normalizedDistanceForSize(size: CGSize) -> CGPoint { + func normalizedDistanceForSize(_ size: CGSize) -> CGPoint { // multiplies by 2 because coordinate system is (-1,1) let x = 2 * (self.x / size.width) let y = 2 * (self.y / size.height) return CGPoint(x: x, y: y) } - func normalizedPointForSize(size:CGSize) -> CGPoint { + func normalizedPointForSize(_ size:CGSize) -> CGPoint { let x = (self.x / (size.width * 0.5)) - 1 let y = (self.y / (size.height * 0.5)) - 1 return CGPoint(x: x, y: y) } - func screenPointForSize(screenSize: CGSize) -> CGPoint { + func screenPointForSize(_ screenSize: CGSize) -> CGPoint { let x = 0.5 * (1 + self.x) * screenSize.width let y = 0.5 * (1 + self.y) * screenSize.height return CGPoint(x: x, y: y) } - static func intersectionBetweenLines(line1: CGLine, line2: CGLine) -> CGPoint? { + static func intersectionBetweenLines(_ line1: CGLine, line2: CGLine) -> CGPoint? { let (p1,p2) = line1 let (p3,p4) = line2 @@ -164,27 +168,27 @@ extension CGPoint { return CGPoint(x: p1.x + ua / d * (p2.x - p1.x), y: p1.y + ua / d * (p2.y - p1.y)) } return nil - } } typealias CGLine = (start: CGPoint, end: CGPoint) extension CGRect { + var topLine: CGLine { - return (Direction.TopLeft.point, Direction.TopRight.point) + return (Direction.topLeft.point, Direction.topRight.point) } var leftLine: CGLine { - return (Direction.TopLeft.point, Direction.BottomLeft.point) + return (Direction.topLeft.point, Direction.bottomLeft.point) } var bottomLine: CGLine { - return (Direction.BottomLeft.point, Direction.BottomRight.point) + return (Direction.bottomLeft.point, Direction.bottomRight.point) } var rightLine: CGLine { - return (Direction.TopRight.point, Direction.BottomRight.point) + return (Direction.topRight.point, Direction.bottomRight.point) } var perimeterLines: [CGLine] { return [topLine, leftLine, bottomLine, rightLine] } -} \ No newline at end of file +} diff --git a/Info.plist b/Pod/Info.plist similarity index 100% rename from Info.plist rename to Pod/Info.plist diff --git a/Pod/Koloda.h b/Pod/Koloda.h new file mode 100644 index 00000000..4b3c6a6d --- /dev/null +++ b/Pod/Koloda.h @@ -0,0 +1,19 @@ +// +// Koloda.h +// Koloda +// +// Created by Serhii Butenko on 29/9/16. +// Copyright © 2016 Yalantis. All rights reserved. +// + +#import + +//! Project version number for Koloda. +FOUNDATION_EXPORT double PodVersionNumber; + +//! Project version string for Koloda. +FOUNDATION_EXPORT const unsigned char PodVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/_Pods.xcodeproj b/_Pods.xcodeproj deleted file mode 120000 index 3c5a8e71..00000000 --- a/_Pods.xcodeproj +++ /dev/null @@ -1 +0,0 @@ -Example/Pods/Pods.xcodeproj \ No newline at end of file