Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Example/TinderExample/TinderViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ extension TinderViewController: ButtonStackViewDelegate, SwipeCardStackDataSourc
let card = SwipeCard()
card.footerHeight = 80
card.swipeDirections = [.left, .up, .right]
card.axis = .all
for direction in card.swipeDirections {
card.setOverlay(TinderCardOverlay(direction: direction), forDirection: direction)
}
Comment thread
andre991 marked this conversation as resolved.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ To run the example project, clone the repo and run the `ShuffleExample` target.
func card(fromImage image: UIImage) -> SwipeCard {
let card = SwipeCard()
card.swipeDirections = [.left, .right]
card.axis = .horizontal
card.content = UIImageView(image: image)

let leftOverlay = UIView()
Comment thread
andre991 marked this conversation as resolved.
Expand Down Expand Up @@ -193,4 +194,4 @@ We love to hear about apps that use Shuffle - feel free to submit a pull request
---

<p align="center">
Made with ❤️ by <a href="https://github.com/mac-gallagher">Mac Gallagher</a>
Made with ❤️ by <a href="https://github.com/mac-gallagher">Mac Gallagher</a>
5 changes: 2 additions & 3 deletions Shuffle-iOS.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "Shuffle-iOS"
s.version = "0.2.5"
s.version = "0.3.0"
s.platform = :ios, "9.0"
s.summary = "A multi-directional card swiping library inspired by Tinder"

Comment thread
andre991 marked this conversation as resolved.
Expand All @@ -13,8 +13,7 @@ s.homepage = "https://github.com/mac-gallagher/Shuffle"
s.documentation_url = "https://github.com/mac-gallagher/Shuffle/tree/master/README.md"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "Mac Gallagher" => "jmgallagher36@gmail.com" }
s.source = { :git => "https://github.com/mac-gallagher/Shuffle.git", :tag => "v0.2.5" }

s.source = { :git => "https://github.com/mac-gallagher/Shuffle.git", :tag => "v0.3.0" }
s.swift_version = "5.0"
s.source_files = "Sources/**/*.{h,swift}"

Expand Down
4 changes: 4 additions & 0 deletions Shuffle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/* End PBXAggregateTarget section */

/* Begin PBXBuildFile section */
65AD978A2481B093008D3A79 /* Axis.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65AD97892481B093008D3A79 /* Axis.swift */; };
387D5E42FEF4A017C5407B1F /* Pods_ShuffleTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD73382D22D7142EE1082545 /* Pods_ShuffleTests.framework */; };
881FD28C231B78FB003ACA43 /* CardStackAnimationOptionsSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881FD28B231B78FB003ACA43 /* CardStackAnimationOptionsSpec.swift */; };
904ADE5B4A83DD023287EB73 /* Pods_ShuffleExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91AB74E2E12D2E4C970B6743 /* Pods_ShuffleExample.framework */; };
Expand Down Expand Up @@ -124,6 +125,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
65AD97892481B093008D3A79 /* Axis.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Axis.swift; sourceTree = "<group>"; };
1070E8CB25529479CB067AD3 /* Pods-ShuffleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ShuffleTests.release.xcconfig"; path = "Target Support Files/Pods-ShuffleTests/Pods-ShuffleTests.release.xcconfig"; sourceTree = "<group>"; };
29C7C2F3D3AC996FDD3FFF70 /* Pods-ShuffleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ShuffleTests.debug.xcconfig"; path = "Target Support Files/Pods-ShuffleTests/Pods-ShuffleTests.debug.xcconfig"; sourceTree = "<group>"; };
604684987DE74002FE435206 /* Pods-ShuffleExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ShuffleExample.debug.xcconfig"; path = "Target Support Files/Pods-ShuffleExample/Pods-ShuffleExample.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -318,6 +320,7 @@
AD18F0DE22B9F874007BACE9 /* Shuffle */ = {
isa = PBXGroup;
children = (
65AD97892481B093008D3A79 /* Axis.swift */,
AD72AC6F2270E6380083E735 /* SwipeDirection.swift */,
AD10982222879C42008CB197 /* SwipeCard */,
ADA444D522AC651B00AFAFFE /* SwipeCardStack */,
Expand Down Expand Up @@ -821,6 +824,7 @@
AD52EF8122E5088B0063AE5D /* CardTransformProvider.swift in Sources */,
AD514C5B22A08D5600BD8F3E /* CardLayoutProvider.swift in Sources */,
AD72AC9A2270FCCE0083E735 /* SwipeDirection.swift in Sources */,
65AD978A2481B093008D3A79 /* Axis.swift in Sources */,
ADA444D922AC658E00AFAFFE /* SwipeCardStackDataSource.swift in Sources */,
AD52EF8722E523020063AE5D /* CardStackTransformProvider.swift in Sources */,
ADEE86D722ACE5AA00AAE7A1 /* Array+Extensions.swift in Sources */,
Expand Down
55 changes: 55 additions & 0 deletions Sources/Shuffle/Axis.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
///
/// MIT License
///
/// Copyright (c) 2020 Mac Gallagher
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in all
/// copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
/// SOFTWARE.
///

import UIKit

/// A type representing the axis of a physical drag animation.
@objc public enum Axis: Int, CustomStringConvertible {
Comment thread
andre991 marked this conversation as resolved.
Outdated

case vertical, horizontal, all

/// The `Axis` translation represented as a CGAffineTransform
public func translation(_ point: CGPoint) -> CGAffineTransform {
switch self {
case .vertical:
return CGAffineTransform(translationX: 0, y: point.y)
case .horizontal:
return CGAffineTransform(translationX: point.x, y: 0)
case .all:
return CGAffineTransform(translationX: point.x, y: point.y)
}
}

/// A textual representation of the `Axis`.
public var description: String {
Comment thread
andre991 marked this conversation as resolved.
switch self {
case .vertical:
return "vertical"
case .horizontal:
return "horizontal"
case .all:
return "all"
}
}
}
3 changes: 1 addition & 2 deletions Sources/Shuffle/SwipeCard/CardTransformProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ class CardTransformProvider: CardTransformProvidable {

func transform(for card: SwipeCard) -> CGAffineTransform {
let dragTranslation = card.panGestureRecognizer.translation(in: card)
let translation = CGAffineTransform(translationX: dragTranslation.x,
y: dragTranslation.y)
let translation = card.axis.translation(dragTranslation)
let rotation = CGAffineTransform(rotationAngle: rotationAngle(for: card))
return translation.concatenating(rotation)
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/Shuffle/SwipeCard/SwipeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ open class SwipeView: UIView {
/// Defaults to `SwipeDirection.allDirections`.
open var swipeDirections = SwipeDirection.allDirections

/// The axis to be animate card in all axis. Set this variable to ignore certain axis.
/// Defaults to `Axis.all`.
open var axis = Axis.all

/// The pan gesture recognizer attached to the view.
public var panGestureRecognizer: UIPanGestureRecognizer {
return internalPanGestureRecognizer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CardStackTransformProvider: CardStackTransformProvidable {

let scaleX = (1 - percentage) * currentScale.x + percentage * nextScale.x
let scaleY = (1 - percentage) * currentScale.y + percentage * nextScale.y

return CGAffineTransform(scaleX: scaleX, y: scaleY)
}

Expand Down