Skip to content

Commit

Permalink
Migrate to swift 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Pitsko committed Mar 15, 2017
1 parent 7393497 commit fe6a982
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 133 deletions.
4 changes: 2 additions & 2 deletions TisprCardStack.podspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Pod::Spec.new do |s|

s.name = 'TisprCardStack'
s.version = '0.3.2'
s.version = ‘1.0.0
s.summary = 'Library that allows to have cards UI with two stacks'

s.description = 'Library that allows to have cards UI, like Tinder and Potluck. it is based on CollectionView. Works on iOS 8'
s.description = 'Library that allows to have cards UI, like Tinder and Potluck. it is based on CollectionView. Works on iOS 8, Swift3’
s.license = { :type => 'Apache 2.0 License', :file => 'LICENSE.txt' }
Expand Down
16 changes: 13 additions & 3 deletions TisprCardStack/TisprCardStack.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,12 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = "BuddyHopp Inc.";
TargetAttributes = {
88E6A2D91B4D93F300912452 = {
CreatedOnToolsVersion = 6.4;
LastSwiftMigration = 0820;
};
};
};
Expand Down Expand Up @@ -163,8 +164,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";
Expand Down Expand Up @@ -212,8 +215,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";
Expand All @@ -233,6 +238,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -243,36 +249,40 @@
88E6A2F11B4D93F300912452 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_SEARCH_USER_PATHS = NO;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
INFOPLIST_FILE = TisprCardStack/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "tispr.card.stack.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = TisprCardStack;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
88E6A2F21B4D93F300912452 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_SEARCH_USER_PATHS = NO;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
INFOPLIST_FILE = TisprCardStack/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "tispr.card.stack.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = TisprCardStack;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
10 changes: 5 additions & 5 deletions TisprCardStack/TisprCardStack/TisprCardStackViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ limitations under the License.

import UIKit

public class TisprCardStackViewCell: UICollectionViewCell {
open class TisprCardStackViewCell: UICollectionViewCell {

override public func applyLayoutAttributes(layoutAttributes: UICollectionViewLayoutAttributes) {
override open func apply(_ layoutAttributes: UICollectionViewLayoutAttributes) {
let center = layoutAttributes.center
let animation = CABasicAnimation(keyPath: "position.y")
animation.toValue = center.y
animation.duration = 0.3
animation.timingFunction = CAMediaTimingFunction(controlPoints: 0.8, 2.0, 1.0, 1.0)
layer.addAnimation(animation, forKey: "position.y")
layer.add(animation, forKey: "position.y")

super.applyLayoutAttributes(layoutAttributes)
super.apply(layoutAttributes)
}

}
}
36 changes: 18 additions & 18 deletions TisprCardStack/TisprCardStack/TisprCardStackViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,45 @@ limitations under the License.
import UIKit

public protocol TisprCardStackViewControllerDelegate {
func cardDidChangeState(cardIndex: Int)
func cardDidChangeState(_ cardIndex: Int)
}

public class TisprCardStackViewController: UICollectionViewController, UIGestureRecognizerDelegate {
open class TisprCardStackViewController: UICollectionViewController, UIGestureRecognizerDelegate {

/* The speed of animation. */
private let animationSpeedDefault: Float = 0.9
fileprivate let animationSpeedDefault: Float = 0.9

public var cardStackDelegate: TisprCardStackViewControllerDelegate? {
open var cardStackDelegate: TisprCardStackViewControllerDelegate? {
didSet {
layout.delegate = cardStackDelegate
}
}

public var layout: TisprCardStackViewLayout { return collectionViewLayout as! TisprCardStackViewLayout }
open var layout: TisprCardStackViewLayout { return collectionViewLayout as! TisprCardStackViewLayout }

override public func viewDidLoad() {
override open func viewDidLoad() {
super.viewDidLoad()
setAnimationSpeed(animationSpeedDefault)
layout.gesturesEnabled = true
collectionView!.scrollEnabled = false
setCardSize(CGSizeMake(collectionView!.bounds.width - 40, 2*collectionView!.bounds.height/3))
collectionView!.isScrollEnabled = false
setCardSize(CGSize(width: collectionView!.bounds.width - 40, height: 2*collectionView!.bounds.height/3))

}

override public func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
override open func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}

override public func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
override open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return numberOfCards()
}

override public func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
override open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
return card(collectionView, cardForItemAtIndexPath: indexPath)
}

//This method should be called after adding new card
public func newCardWasAdded() {
open func newCardWasAdded() {
if layout.newCardShouldAppearOnTheBottom {
layout.newCardDidAdd(numberOfCards() - 1)
} else {
Expand All @@ -70,34 +70,34 @@ public class TisprCardStackViewController: UICollectionViewController, UIGesture
}

//method to change animation speed
public func setAnimationSpeed(speed: Float) {
open func setAnimationSpeed(_ speed: Float) {
collectionView!.layer.speed = speed
}

//method to set size of cards
public func setCardSize(size: CGSize) {
open func setCardSize(_ size: CGSize) {
layout.cardSize = size
}

//method that should return count of cards
public func numberOfCards() -> Int {
open func numberOfCards() -> Int {
assertionFailure("Should be implemented in subsclass")
return 0
}

//method that should return card by index
public func card(collectionView: UICollectionView, cardForItemAtIndexPath indexPath: NSIndexPath) -> TisprCardStackViewCell {
open func card(_ collectionView: UICollectionView, cardForItemAtIndexPath indexPath: IndexPath) -> TisprCardStackViewCell {
assertionFailure("Should be implemented in subsclass")
return TisprCardStackViewCell()
}

public func moveCardUp() {
open func moveCardUp() {
if layout.index > 0 {
layout.index -= 1
}
}

public func moveCardDown() {
open func moveCardDown() {
if layout.index <= numberOfCards() - 1 {
layout.index += 1
}
Expand Down
Loading

0 comments on commit fe6a982

Please sign in to comment.