Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Multiple direction support #131

Merged
merged 14 commits into from Apr 28, 2016
3 changes: 1 addition & 2 deletions Example/Koloda.xcodeproj/project.pbxproj
Expand Up @@ -7,7 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
191D14781525C400D3E86FEC /* Pods_Koloda_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5243B3EDBF06248559332C86 /* Pods_Koloda_Example.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
191D14781525C400D3E86FEC /* Pods_Koloda_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5243B3EDBF06248559332C86 /* Pods_Koloda_Example.framework */; };
440FB7671B51499A009FC9FC /* CustomKolodaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440FB7661B51499A009FC9FC /* CustomKolodaView.swift */; };
440FB7691B515995009FC9FC /* BackgroundAnimationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440FB7681B515995009FC9FC /* BackgroundAnimationViewController.swift */; };
4420661D1B44577500FD4CAD /* OverlayView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4420661B1B44577500FD4CAD /* OverlayView.xib */; };
Expand Down Expand Up @@ -171,7 +171,6 @@
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = W2JST9RBJ6;
};
};
};
Expand Down
27 changes: 21 additions & 6 deletions Example/Koloda/Base.lproj/Main.storyboard
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="dh2-Wx-deB">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="dh2-Wx-deB">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<scenes>
Expand All @@ -14,7 +15,7 @@
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="64" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Mnc-Dd-Z3X">
Expand Down Expand Up @@ -53,7 +54,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="EMz-lH-olg">
<rect key="frame" x="100" y="408" width="120" height="32"/>
<rect key="frame" x="100" y="408" width="120" height="78"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LAd-kH-OMn">
<rect key="frame" x="88" y="0.0" width="32" height="32"/>
Expand All @@ -75,10 +76,24 @@
<action selector="leftButtonTapped" destination="vXZ-lx-hvc" eventType="touchUpInside" id="nTX-4U-eFk"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qyb-Sb-Kut">
<rect key="frame" x="87" y="40" width="34" height="34"/>
<state key="normal" image="ic_skip"/>
<connections>
<action selector="downButtonTapped:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="Gyd-wi-Ne6"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PGl-FC-v1n">
<rect key="frame" x="-30" y="40" width="92" height="34"/>
<state key="normal" image="ic_like"/>
<connections>
<action selector="upButtonTapped:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="Kbp-MD-xfU"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="32" id="2Fq-xQ-0g6"/>
<constraint firstAttribute="height" constant="78" id="2Fq-xQ-0g6"/>
<constraint firstAttribute="width" constant="120" id="mWp-MS-etc"/>
</constraints>
</view>
Expand Down Expand Up @@ -173,7 +188,7 @@
<action selector="undoButtonTapped" destination="dh2-Wx-deB" eventType="touchUpInside" id="V0e-B4-IqE"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="New in Gallery" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HWg-0g-9Qs">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="New in Gallery" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HWg-0g-9Qs">
<rect key="frame" x="105" y="39" width="112" height="22"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="18"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
Expand Down
5 changes: 3 additions & 2 deletions Example/Koloda/Base.lproj/OverlayView.xib
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
Expand Down
2 changes: 1 addition & 1 deletion Example/Koloda/CustomOverlayView.swift
Expand Up @@ -23,7 +23,7 @@ class CustomOverlayView: OverlayView {
return imageView
}()

override var overlayState:OverlayMode {
override var overlayState: SwipeResultDirection {
didSet {
switch overlayState {
case .Left :
Expand Down
8 changes: 7 additions & 1 deletion Example/Koloda/ExampleOverlayView.swift
Expand Up @@ -11,6 +11,8 @@ import Koloda

private let overlayRightImageName = "yesOverlayImage"
private let overlayLeftImageName = "noOverlayImage"
private let overlayUpImageName = "ic_like"
private let overlayDownImageName = "ic_skip"

class ExampleOverlayView: OverlayView {
@IBOutlet lazy var overlayImageView: UIImageView! = {
Expand All @@ -22,13 +24,17 @@ class ExampleOverlayView: OverlayView {
return imageView
}()

override var overlayState:OverlayMode {
override var overlayState: SwipeResultDirection {
didSet {
switch overlayState {
case .Left :
overlayImageView.image = UIImage(named: overlayLeftImageName)
case .Right :
overlayImageView.image = UIImage(named: overlayRightImageName)
case .Up :
overlayImageView.image = UIImage(named: overlayUpImageName)
case .Down :
overlayImageView.image = UIImage(named: overlayDownImageName)
default:
overlayImageView.image = nil
}
Expand Down
18 changes: 15 additions & 3 deletions Example/Koloda/ViewController.swift
Expand Up @@ -37,15 +37,23 @@ class ViewController: UIViewController {

//MARK: IBActions
@IBAction func leftButtonTapped() {
kolodaView?.swipe(SwipeResultDirection.Left)
kolodaView.swipe(.Left)
}

@IBAction func rightButtonTapped() {
kolodaView?.swipe(SwipeResultDirection.Right)
kolodaView.swipe(.Right)
}

@IBAction func upButtonTapped(sender: AnyObject) {
kolodaView.swipe(.Up)
}

@IBAction func downButtonTapped(sender: AnyObject){
kolodaView.swipe(.Down)
}

@IBAction func undoButtonTapped() {
kolodaView?.revertAction()
kolodaView.revertAction()
}
}

Expand All @@ -61,6 +69,10 @@ extension ViewController: KolodaViewDelegate {
func koloda(koloda: KolodaView, didSelectCardAtIndex index: UInt) {
UIApplication.sharedApplication().openURL(NSURL(string: "http://yalantis.com/")!)
}

func koloda(koloda: KolodaView, allowedDirectionsForIndex index: UInt) -> [SwipeResultDirection] {
return [.Left, .Right, .Up, .Down]
}
}

//MARK: KolodaViewDataSource
Expand Down