├── .gitignore ├── .jazzy.yml ├── .travis.yml ├── LICENSE ├── README.md ├── SPTinderView.podspec ├── SPTinderView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── SPTinderView.xcscheme ├── SPTinderView ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── MyCustomTinderCell.swift ├── MyCustomTinderCell.xib ├── Source │ ├── SPTinderView.swift │ └── SPTinderViewCell.swift ├── TinderGirls │ ├── tg1.jpg │ ├── tg2.jpg │ ├── tg3.jpg │ ├── tg4.jpg │ ├── tg5.jpg │ └── tg6.jpg ├── TinderModel.swift ├── TinderViewController.swift └── ViewController.swift ├── SPTinderViewTests ├── Info.plist └── SPTinderViewTests.swift ├── SPTinderViewUITests ├── Info.plist └── SPTinderViewUITests.swift ├── _config.yml └── assets └── screenshot.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # Swift Package Manager 31 | # 32 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 33 | # Packages/ 34 | .build/ 35 | 36 | # CocoaPods 37 | # 38 | # We recommend against adding the Pods directory to your .gitignore. However 39 | # you should judge for yourself, the pros and cons are mentioned at: 40 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 41 | # 42 | Pods/ 43 | 44 | # Carthage 45 | # 46 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 47 | # Carthage/Checkouts 48 | 49 | Carthage/Build 50 | 51 | # fastlane 52 | # 53 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 54 | # screenshots whenever they are needed. 55 | # For more information about the recommended setup visit: 56 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 57 | 58 | fastlane/report.xml 59 | fastlane/screenshots 60 | screenshots/ 61 | 62 | # fastlane scan 63 | test_output/ 64 | 65 | # iPA or zip 66 | *.zip 67 | *.ipa 68 | *.html 69 | *.p12 70 | *.certSigningRequest 71 | *.cer 72 | *.mobileprovision 73 | docs/ 74 | 75 | -------------------------------------------------------------------------------- /.jazzy.yml: -------------------------------------------------------------------------------- 1 | clean 2 | author Suraj Pathak 3 | author_url https://freesuraj.github.io 4 | github_url https://github.com/freesuraj/SPTinderView 5 | github-file-prefix https://github.com/freesuraj/SPTinderView 6 | module-version 0.1.0 7 | xcodebuild-arguments -scheme,SPTinderView 8 | module SPTinderView 9 | output docs/swift_output 10 | template-directory docs/templates 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode8 3 | before_install: 4 | - gem install cocoapods --pre --no-rdoc --no-ri --no-document --quiet 5 | script: 6 | - set -o pipefail 7 | - xcodebuild -version 8 | - xcodebuild -project SPTinderView.xcodeproj -scheme SPTinderView -destination 'platform=iOS Simulator,name=iPhone 7' build | xcpretty; 9 | 10 | branches: 11 | only: 12 | - master -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) <2016> 3 | 4 | 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: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | 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. 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### SPTinderView 2 | [![build-status](https://travis-ci.org/freesuraj/SPTinderView.svg?branch=master)](https://travis-ci.org/freesuraj/SPTinderView) 3 | [![Twitter](https://img.shields.io/badge/twitter-@iosCook-blue.svg?style=flat)](http://twitter.com/iosCook) 4 | [![CocoaPods](https://img.shields.io/cocoapods/v/SPTinderView.svg)]() 5 | 6 | A clone of standard Tinder app's swipe left swipe right view 7 | 8 | ![screenshot](https://github.com/freesuraj/SPTinderView/blob/master/assets/screenshot.gif?raw=true) 9 | 10 | #### Installation 11 | ###### CocoaPods 12 | pod SPTinderView 13 | ###### Manual: 14 | Copy the swift files in `Source` directory 15 | 16 | #### Usage 17 | There are two main classes: 18 | `SPTinderView` is a subclass of `UIView` which acts as the container for all the _cards_ (aka Cells) in the tinder view. The _card_ is represented by `SPTinderViewCell` class which is also a subclass of `UIView`. 19 | 20 | It can be used similar to how a `UITableView` is used with `SPTinderView` being equivalent to `UITableView` and `SPTinderViewCell` being equivalent to `UITableViewCell` 21 | 22 | - Add `SPTinderView` to your view, set the `delegate` and `dataSource` 23 | - Set your custom cell by subclassing `SPTinderViewCell` 24 | - Register this class or nib to the `SPTinderView` using the method `registerClass: forIdentifier: ` or `registerNib: forIdentifier:` 25 | - Implement the `dataSource` and `delegate` methods. 26 | 27 | #### Example 28 | This example can be found in the project as well. 29 | 30 | 1. Define Custom `SPTinderViewCell` 31 | 32 | ```objective-c 33 | class MyTinderCell: SPTinderViewCell { 34 | let titleLabel: UILabel = UILabel(frame: CGRectZero) 35 | let imageView: UIImageView = UIImageView(frame: CGRectZero) 36 | 37 | override init(frame: CGRect) { 38 | super.init(frame: frame) 39 | } 40 | 41 | required init?(coder aDecoder: NSCoder) { 42 | super.init(coder: aDecoder) 43 | } 44 | 45 | required init(reuseIdentifier: String) { 46 | super.init(reuseIdentifier: reuseIdentifier) 47 | self.frame = CGRect(origin: CGPointZero, size: CGSize(width: 300, height: 400)) 48 | titleLabel.frame = CGRectMake(0, self.frame.height - 50, self.frame.width, 50) 49 | imageView.frame = CGRectMake(0, 0, self.frame.width, self.frame.height - 50) 50 | imageView.clipsToBounds = true 51 | imageView.contentMode = .ScaleAspectFill 52 | titleLabel.textAlignment = .Center 53 | self.addSubview(imageView) 54 | self.addSubview(titleLabel) 55 | } 56 | } 57 | ``` 58 | 59 | 2. Set `SPTinderView` and set `dataSoruce` and `delegate` 60 | ```objective-c 61 | class ViewController: UIViewController { 62 | @IBOutlet var tinderView: SPTinderView! 63 | let cellIdentifier = "MyTinderCell" 64 | 65 | override func viewDidLoad() { 66 | super.viewDidLoad() 67 | tinderView.frame = self.view.frame 68 | tinderView.registerClass(MyTinderCell.self, forCellReuseIdentifier: cellIdentifier) 69 | tinderView.dataSource = self 70 | tinderView.delegate = self 71 | tinderView.backgroundColor = UIColor.whiteColor() 72 | } 73 | 74 | override func didReceiveMemoryWarning() { 75 | super.didReceiveMemoryWarning() 76 | } 77 | } 78 | ``` 79 | 3. Implement the `dataSource` and `delegate` methods 80 | ```objective-c 81 | extension ViewController: SPTinderViewDataSource, SPTinderViewDelegate { 82 | func numberOfItemsInTinderView(view: SPTinderView) -> Int { 83 | return 20 84 | } 85 | 86 | func tinderView(view: SPTinderView, cellAt index: Int) -> SPTinderViewCell? { 87 | if let cell = tinderView.dequeueReusableCellWithIdentifier(cellIdentifier) as? MyTinderCell { 88 | cell.titleLabel.text = "Model No: \(index+1)" 89 | cell.imageView.image = TinderModel.randomImage() 90 | return cell 91 | } 92 | return nil 93 | } 94 | 95 | func tinderView(view: SPTinderView, didMoveCellAt index: Int, towards direction: SPTinderViewCellMovement) { 96 | print("\(direction)") 97 | } 98 | } 99 | ``` 100 | 101 | #### Contribution 102 | 103 | All the contributions are welcome ! Fork, change and send a pull request. 104 | -------------------------------------------------------------------------------- /SPTinderView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'SPTinderView' 3 | s.version = '0.5.1' 4 | s.license = 'MIT' 5 | s.summary = 'Tinder View written in Swift' 6 | s.homepage = 'https://github.com/freesuraj/SPTinderView' 7 | s.social_media_url = 'http://twitter.com/iosCook' 8 | s.authors = { 'Suraj Pathak' => 'freesuraj@gmail.com' } 9 | s.source = { :git => 'https://github.com/freesuraj/SPTinderView.git', :tag => s.version } 10 | s.ios.deployment_target = '8.0' 11 | s.source_files = 'SPTinderView/Source/*.swift' 12 | s.requires_arc = true 13 | s.screenshot = "https://github.com/freesuraj/SPTinderView/blob/master/assets/screenshot.gif?raw=true" 14 | end 15 | -------------------------------------------------------------------------------- /SPTinderView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | ED1F2A161C61D44B0084DD77 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED1F2A151C61D44B0084DD77 /* AppDelegate.swift */; }; 11 | ED1F2A181C61D44B0084DD77 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED1F2A171C61D44B0084DD77 /* ViewController.swift */; }; 12 | ED1F2A1B1C61D44B0084DD77 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ED1F2A191C61D44B0084DD77 /* Main.storyboard */; }; 13 | ED1F2A1D1C61D44B0084DD77 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ED1F2A1C1C61D44B0084DD77 /* Assets.xcassets */; }; 14 | ED1F2A201C61D44B0084DD77 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ED1F2A1E1C61D44B0084DD77 /* LaunchScreen.storyboard */; }; 15 | ED1F2A2B1C61D44B0084DD77 /* SPTinderViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED1F2A2A1C61D44B0084DD77 /* SPTinderViewTests.swift */; }; 16 | ED1F2A361C61D44B0084DD77 /* SPTinderViewUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED1F2A351C61D44B0084DD77 /* SPTinderViewUITests.swift */; }; 17 | ED1F2A451C61D74C0084DD77 /* SPTinderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED1F2A441C61D74C0084DD77 /* SPTinderView.swift */; }; 18 | ED1F2A491C61E00D0084DD77 /* SPTinderViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED1F2A481C61E00D0084DD77 /* SPTinderViewCell.swift */; }; 19 | ED1F2AB91C6B08850084DD77 /* TinderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED1F2AB81C6B08850084DD77 /* TinderViewController.swift */; }; 20 | ED1F2ABB1C6B09500084DD77 /* TinderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED1F2ABA1C6B09500084DD77 /* TinderModel.swift */; }; 21 | EDDCDF1C1C674B8B00E27361 /* MyCustomTinderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDDCDF1B1C674B8B00E27361 /* MyCustomTinderCell.swift */; }; 22 | EDDCDF1E1C674B9E00E27361 /* MyCustomTinderCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = EDDCDF1D1C674B9E00E27361 /* MyCustomTinderCell.xib */; }; 23 | EDDCDF261C674D9800E27361 /* tg1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = EDDCDF201C674D9800E27361 /* tg1.jpg */; }; 24 | EDDCDF271C674D9800E27361 /* tg2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = EDDCDF211C674D9800E27361 /* tg2.jpg */; }; 25 | EDDCDF281C674D9800E27361 /* tg3.jpg in Resources */ = {isa = PBXBuildFile; fileRef = EDDCDF221C674D9800E27361 /* tg3.jpg */; }; 26 | EDDCDF291C674D9800E27361 /* tg4.jpg in Resources */ = {isa = PBXBuildFile; fileRef = EDDCDF231C674D9800E27361 /* tg4.jpg */; }; 27 | EDDCDF2A1C674D9800E27361 /* tg5.jpg in Resources */ = {isa = PBXBuildFile; fileRef = EDDCDF241C674D9800E27361 /* tg5.jpg */; }; 28 | EDDCDF2B1C674D9800E27361 /* tg6.jpg in Resources */ = {isa = PBXBuildFile; fileRef = EDDCDF251C674D9800E27361 /* tg6.jpg */; }; 29 | /* End PBXBuildFile section */ 30 | 31 | /* Begin PBXContainerItemProxy section */ 32 | ED1F2A271C61D44B0084DD77 /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = ED1F2A0A1C61D44B0084DD77 /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = ED1F2A111C61D44B0084DD77; 37 | remoteInfo = SPTinderView; 38 | }; 39 | ED1F2A321C61D44B0084DD77 /* PBXContainerItemProxy */ = { 40 | isa = PBXContainerItemProxy; 41 | containerPortal = ED1F2A0A1C61D44B0084DD77 /* Project object */; 42 | proxyType = 1; 43 | remoteGlobalIDString = ED1F2A111C61D44B0084DD77; 44 | remoteInfo = SPTinderView; 45 | }; 46 | /* End PBXContainerItemProxy section */ 47 | 48 | /* Begin PBXFileReference section */ 49 | ED1F2A121C61D44B0084DD77 /* SPTinderView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SPTinderView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | ED1F2A151C61D44B0084DD77 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 51 | ED1F2A171C61D44B0084DD77 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 52 | ED1F2A1A1C61D44B0084DD77 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 53 | ED1F2A1C1C61D44B0084DD77 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 54 | ED1F2A1F1C61D44B0084DD77 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 55 | ED1F2A211C61D44B0084DD77 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | ED1F2A261C61D44B0084DD77 /* SPTinderViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SPTinderViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | ED1F2A2A1C61D44B0084DD77 /* SPTinderViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPTinderViewTests.swift; sourceTree = ""; }; 58 | ED1F2A2C1C61D44B0084DD77 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | ED1F2A311C61D44B0084DD77 /* SPTinderViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SPTinderViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 60 | ED1F2A351C61D44B0084DD77 /* SPTinderViewUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPTinderViewUITests.swift; sourceTree = ""; }; 61 | ED1F2A371C61D44B0084DD77 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 62 | ED1F2A441C61D74C0084DD77 /* SPTinderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPTinderView.swift; sourceTree = ""; }; 63 | ED1F2A481C61E00D0084DD77 /* SPTinderViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPTinderViewCell.swift; sourceTree = ""; }; 64 | ED1F2AB81C6B08850084DD77 /* TinderViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TinderViewController.swift; sourceTree = ""; }; 65 | ED1F2ABA1C6B09500084DD77 /* TinderModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TinderModel.swift; sourceTree = ""; }; 66 | EDDCDF1B1C674B8B00E27361 /* MyCustomTinderCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MyCustomTinderCell.swift; sourceTree = ""; }; 67 | EDDCDF1D1C674B9E00E27361 /* MyCustomTinderCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MyCustomTinderCell.xib; sourceTree = ""; }; 68 | EDDCDF201C674D9800E27361 /* tg1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = tg1.jpg; sourceTree = ""; }; 69 | EDDCDF211C674D9800E27361 /* tg2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = tg2.jpg; sourceTree = ""; }; 70 | EDDCDF221C674D9800E27361 /* tg3.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = tg3.jpg; sourceTree = ""; }; 71 | EDDCDF231C674D9800E27361 /* tg4.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = tg4.jpg; sourceTree = ""; }; 72 | EDDCDF241C674D9800E27361 /* tg5.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = tg5.jpg; sourceTree = ""; }; 73 | EDDCDF251C674D9800E27361 /* tg6.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = tg6.jpg; sourceTree = ""; }; 74 | /* End PBXFileReference section */ 75 | 76 | /* Begin PBXFrameworksBuildPhase section */ 77 | ED1F2A0F1C61D44B0084DD77 /* Frameworks */ = { 78 | isa = PBXFrameworksBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | ); 82 | runOnlyForDeploymentPostprocessing = 0; 83 | }; 84 | ED1F2A231C61D44B0084DD77 /* Frameworks */ = { 85 | isa = PBXFrameworksBuildPhase; 86 | buildActionMask = 2147483647; 87 | files = ( 88 | ); 89 | runOnlyForDeploymentPostprocessing = 0; 90 | }; 91 | ED1F2A2E1C61D44B0084DD77 /* Frameworks */ = { 92 | isa = PBXFrameworksBuildPhase; 93 | buildActionMask = 2147483647; 94 | files = ( 95 | ); 96 | runOnlyForDeploymentPostprocessing = 0; 97 | }; 98 | /* End PBXFrameworksBuildPhase section */ 99 | 100 | /* Begin PBXGroup section */ 101 | ED1F2A091C61D44B0084DD77 = { 102 | isa = PBXGroup; 103 | children = ( 104 | ED1F2A141C61D44B0084DD77 /* SPTinderView */, 105 | ED1F2A291C61D44B0084DD77 /* SPTinderViewTests */, 106 | ED1F2A341C61D44B0084DD77 /* SPTinderViewUITests */, 107 | ED1F2A131C61D44B0084DD77 /* Products */, 108 | ); 109 | sourceTree = ""; 110 | }; 111 | ED1F2A131C61D44B0084DD77 /* Products */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | ED1F2A121C61D44B0084DD77 /* SPTinderView.app */, 115 | ED1F2A261C61D44B0084DD77 /* SPTinderViewTests.xctest */, 116 | ED1F2A311C61D44B0084DD77 /* SPTinderViewUITests.xctest */, 117 | ); 118 | name = Products; 119 | sourceTree = ""; 120 | }; 121 | ED1F2A141C61D44B0084DD77 /* SPTinderView */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | ED1F2A431C61D72E0084DD77 /* Source */, 125 | EDDCDF1F1C674D9800E27361 /* TinderGirls */, 126 | ED1F2A151C61D44B0084DD77 /* AppDelegate.swift */, 127 | ED1F2A171C61D44B0084DD77 /* ViewController.swift */, 128 | ED1F2AB81C6B08850084DD77 /* TinderViewController.swift */, 129 | ED1F2ABA1C6B09500084DD77 /* TinderModel.swift */, 130 | ED1F2A191C61D44B0084DD77 /* Main.storyboard */, 131 | EDDCDF1B1C674B8B00E27361 /* MyCustomTinderCell.swift */, 132 | EDDCDF1D1C674B9E00E27361 /* MyCustomTinderCell.xib */, 133 | ED1F2A1C1C61D44B0084DD77 /* Assets.xcassets */, 134 | ED1F2A1E1C61D44B0084DD77 /* LaunchScreen.storyboard */, 135 | ED1F2A211C61D44B0084DD77 /* Info.plist */, 136 | ); 137 | path = SPTinderView; 138 | sourceTree = ""; 139 | }; 140 | ED1F2A291C61D44B0084DD77 /* SPTinderViewTests */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | ED1F2A2A1C61D44B0084DD77 /* SPTinderViewTests.swift */, 144 | ED1F2A2C1C61D44B0084DD77 /* Info.plist */, 145 | ); 146 | path = SPTinderViewTests; 147 | sourceTree = ""; 148 | }; 149 | ED1F2A341C61D44B0084DD77 /* SPTinderViewUITests */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | ED1F2A351C61D44B0084DD77 /* SPTinderViewUITests.swift */, 153 | ED1F2A371C61D44B0084DD77 /* Info.plist */, 154 | ); 155 | path = SPTinderViewUITests; 156 | sourceTree = ""; 157 | }; 158 | ED1F2A431C61D72E0084DD77 /* Source */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | ED1F2A441C61D74C0084DD77 /* SPTinderView.swift */, 162 | ED1F2A481C61E00D0084DD77 /* SPTinderViewCell.swift */, 163 | ); 164 | path = Source; 165 | sourceTree = ""; 166 | }; 167 | EDDCDF1F1C674D9800E27361 /* TinderGirls */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | EDDCDF201C674D9800E27361 /* tg1.jpg */, 171 | EDDCDF211C674D9800E27361 /* tg2.jpg */, 172 | EDDCDF221C674D9800E27361 /* tg3.jpg */, 173 | EDDCDF231C674D9800E27361 /* tg4.jpg */, 174 | EDDCDF241C674D9800E27361 /* tg5.jpg */, 175 | EDDCDF251C674D9800E27361 /* tg6.jpg */, 176 | ); 177 | path = TinderGirls; 178 | sourceTree = ""; 179 | }; 180 | /* End PBXGroup section */ 181 | 182 | /* Begin PBXNativeTarget section */ 183 | ED1F2A111C61D44B0084DD77 /* SPTinderView */ = { 184 | isa = PBXNativeTarget; 185 | buildConfigurationList = ED1F2A3A1C61D44B0084DD77 /* Build configuration list for PBXNativeTarget "SPTinderView" */; 186 | buildPhases = ( 187 | ED1F2A0E1C61D44B0084DD77 /* Sources */, 188 | ED1F2A0F1C61D44B0084DD77 /* Frameworks */, 189 | ED1F2A101C61D44B0084DD77 /* Resources */, 190 | ); 191 | buildRules = ( 192 | ); 193 | dependencies = ( 194 | ); 195 | name = SPTinderView; 196 | productName = SPTinderView; 197 | productReference = ED1F2A121C61D44B0084DD77 /* SPTinderView.app */; 198 | productType = "com.apple.product-type.application"; 199 | }; 200 | ED1F2A251C61D44B0084DD77 /* SPTinderViewTests */ = { 201 | isa = PBXNativeTarget; 202 | buildConfigurationList = ED1F2A3D1C61D44B0084DD77 /* Build configuration list for PBXNativeTarget "SPTinderViewTests" */; 203 | buildPhases = ( 204 | ED1F2A221C61D44B0084DD77 /* Sources */, 205 | ED1F2A231C61D44B0084DD77 /* Frameworks */, 206 | ED1F2A241C61D44B0084DD77 /* Resources */, 207 | ); 208 | buildRules = ( 209 | ); 210 | dependencies = ( 211 | ED1F2A281C61D44B0084DD77 /* PBXTargetDependency */, 212 | ); 213 | name = SPTinderViewTests; 214 | productName = SPTinderViewTests; 215 | productReference = ED1F2A261C61D44B0084DD77 /* SPTinderViewTests.xctest */; 216 | productType = "com.apple.product-type.bundle.unit-test"; 217 | }; 218 | ED1F2A301C61D44B0084DD77 /* SPTinderViewUITests */ = { 219 | isa = PBXNativeTarget; 220 | buildConfigurationList = ED1F2A401C61D44B0084DD77 /* Build configuration list for PBXNativeTarget "SPTinderViewUITests" */; 221 | buildPhases = ( 222 | ED1F2A2D1C61D44B0084DD77 /* Sources */, 223 | ED1F2A2E1C61D44B0084DD77 /* Frameworks */, 224 | ED1F2A2F1C61D44B0084DD77 /* Resources */, 225 | ); 226 | buildRules = ( 227 | ); 228 | dependencies = ( 229 | ED1F2A331C61D44B0084DD77 /* PBXTargetDependency */, 230 | ); 231 | name = SPTinderViewUITests; 232 | productName = SPTinderViewUITests; 233 | productReference = ED1F2A311C61D44B0084DD77 /* SPTinderViewUITests.xctest */; 234 | productType = "com.apple.product-type.bundle.ui-testing"; 235 | }; 236 | /* End PBXNativeTarget section */ 237 | 238 | /* Begin PBXProject section */ 239 | ED1F2A0A1C61D44B0084DD77 /* Project object */ = { 240 | isa = PBXProject; 241 | attributes = { 242 | LastSwiftUpdateCheck = 0720; 243 | LastUpgradeCheck = 0800; 244 | ORGANIZATIONNAME = "Suraj Pathak"; 245 | TargetAttributes = { 246 | ED1F2A111C61D44B0084DD77 = { 247 | CreatedOnToolsVersion = 7.2; 248 | DevelopmentTeam = 3PU2FX2MA5; 249 | LastSwiftMigration = 0800; 250 | }; 251 | ED1F2A251C61D44B0084DD77 = { 252 | CreatedOnToolsVersion = 7.2; 253 | LastSwiftMigration = 0800; 254 | TestTargetID = ED1F2A111C61D44B0084DD77; 255 | }; 256 | ED1F2A301C61D44B0084DD77 = { 257 | CreatedOnToolsVersion = 7.2; 258 | TestTargetID = ED1F2A111C61D44B0084DD77; 259 | }; 260 | }; 261 | }; 262 | buildConfigurationList = ED1F2A0D1C61D44B0084DD77 /* Build configuration list for PBXProject "SPTinderView" */; 263 | compatibilityVersion = "Xcode 3.2"; 264 | developmentRegion = English; 265 | hasScannedForEncodings = 0; 266 | knownRegions = ( 267 | en, 268 | Base, 269 | ); 270 | mainGroup = ED1F2A091C61D44B0084DD77; 271 | productRefGroup = ED1F2A131C61D44B0084DD77 /* Products */; 272 | projectDirPath = ""; 273 | projectRoot = ""; 274 | targets = ( 275 | ED1F2A111C61D44B0084DD77 /* SPTinderView */, 276 | ED1F2A251C61D44B0084DD77 /* SPTinderViewTests */, 277 | ED1F2A301C61D44B0084DD77 /* SPTinderViewUITests */, 278 | ); 279 | }; 280 | /* End PBXProject section */ 281 | 282 | /* Begin PBXResourcesBuildPhase section */ 283 | ED1F2A101C61D44B0084DD77 /* Resources */ = { 284 | isa = PBXResourcesBuildPhase; 285 | buildActionMask = 2147483647; 286 | files = ( 287 | EDDCDF2A1C674D9800E27361 /* tg5.jpg in Resources */, 288 | EDDCDF281C674D9800E27361 /* tg3.jpg in Resources */, 289 | ED1F2A201C61D44B0084DD77 /* LaunchScreen.storyboard in Resources */, 290 | ED1F2A1D1C61D44B0084DD77 /* Assets.xcassets in Resources */, 291 | EDDCDF261C674D9800E27361 /* tg1.jpg in Resources */, 292 | EDDCDF2B1C674D9800E27361 /* tg6.jpg in Resources */, 293 | EDDCDF271C674D9800E27361 /* tg2.jpg in Resources */, 294 | EDDCDF291C674D9800E27361 /* tg4.jpg in Resources */, 295 | EDDCDF1E1C674B9E00E27361 /* MyCustomTinderCell.xib in Resources */, 296 | ED1F2A1B1C61D44B0084DD77 /* Main.storyboard in Resources */, 297 | ); 298 | runOnlyForDeploymentPostprocessing = 0; 299 | }; 300 | ED1F2A241C61D44B0084DD77 /* Resources */ = { 301 | isa = PBXResourcesBuildPhase; 302 | buildActionMask = 2147483647; 303 | files = ( 304 | ); 305 | runOnlyForDeploymentPostprocessing = 0; 306 | }; 307 | ED1F2A2F1C61D44B0084DD77 /* Resources */ = { 308 | isa = PBXResourcesBuildPhase; 309 | buildActionMask = 2147483647; 310 | files = ( 311 | ); 312 | runOnlyForDeploymentPostprocessing = 0; 313 | }; 314 | /* End PBXResourcesBuildPhase section */ 315 | 316 | /* Begin PBXSourcesBuildPhase section */ 317 | ED1F2A0E1C61D44B0084DD77 /* Sources */ = { 318 | isa = PBXSourcesBuildPhase; 319 | buildActionMask = 2147483647; 320 | files = ( 321 | ED1F2A181C61D44B0084DD77 /* ViewController.swift in Sources */, 322 | ED1F2A491C61E00D0084DD77 /* SPTinderViewCell.swift in Sources */, 323 | ED1F2AB91C6B08850084DD77 /* TinderViewController.swift in Sources */, 324 | ED1F2A161C61D44B0084DD77 /* AppDelegate.swift in Sources */, 325 | ED1F2ABB1C6B09500084DD77 /* TinderModel.swift in Sources */, 326 | EDDCDF1C1C674B8B00E27361 /* MyCustomTinderCell.swift in Sources */, 327 | ED1F2A451C61D74C0084DD77 /* SPTinderView.swift in Sources */, 328 | ); 329 | runOnlyForDeploymentPostprocessing = 0; 330 | }; 331 | ED1F2A221C61D44B0084DD77 /* Sources */ = { 332 | isa = PBXSourcesBuildPhase; 333 | buildActionMask = 2147483647; 334 | files = ( 335 | ED1F2A2B1C61D44B0084DD77 /* SPTinderViewTests.swift in Sources */, 336 | ); 337 | runOnlyForDeploymentPostprocessing = 0; 338 | }; 339 | ED1F2A2D1C61D44B0084DD77 /* Sources */ = { 340 | isa = PBXSourcesBuildPhase; 341 | buildActionMask = 2147483647; 342 | files = ( 343 | ED1F2A361C61D44B0084DD77 /* SPTinderViewUITests.swift in Sources */, 344 | ); 345 | runOnlyForDeploymentPostprocessing = 0; 346 | }; 347 | /* End PBXSourcesBuildPhase section */ 348 | 349 | /* Begin PBXTargetDependency section */ 350 | ED1F2A281C61D44B0084DD77 /* PBXTargetDependency */ = { 351 | isa = PBXTargetDependency; 352 | target = ED1F2A111C61D44B0084DD77 /* SPTinderView */; 353 | targetProxy = ED1F2A271C61D44B0084DD77 /* PBXContainerItemProxy */; 354 | }; 355 | ED1F2A331C61D44B0084DD77 /* PBXTargetDependency */ = { 356 | isa = PBXTargetDependency; 357 | target = ED1F2A111C61D44B0084DD77 /* SPTinderView */; 358 | targetProxy = ED1F2A321C61D44B0084DD77 /* PBXContainerItemProxy */; 359 | }; 360 | /* End PBXTargetDependency section */ 361 | 362 | /* Begin PBXVariantGroup section */ 363 | ED1F2A191C61D44B0084DD77 /* Main.storyboard */ = { 364 | isa = PBXVariantGroup; 365 | children = ( 366 | ED1F2A1A1C61D44B0084DD77 /* Base */, 367 | ); 368 | name = Main.storyboard; 369 | sourceTree = ""; 370 | }; 371 | ED1F2A1E1C61D44B0084DD77 /* LaunchScreen.storyboard */ = { 372 | isa = PBXVariantGroup; 373 | children = ( 374 | ED1F2A1F1C61D44B0084DD77 /* Base */, 375 | ); 376 | name = LaunchScreen.storyboard; 377 | sourceTree = ""; 378 | }; 379 | /* End PBXVariantGroup section */ 380 | 381 | /* Begin XCBuildConfiguration section */ 382 | ED1F2A381C61D44B0084DD77 /* Debug */ = { 383 | isa = XCBuildConfiguration; 384 | buildSettings = { 385 | ALWAYS_SEARCH_USER_PATHS = NO; 386 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 387 | CLANG_CXX_LIBRARY = "libc++"; 388 | CLANG_ENABLE_MODULES = YES; 389 | CLANG_ENABLE_OBJC_ARC = YES; 390 | CLANG_WARN_BOOL_CONVERSION = YES; 391 | CLANG_WARN_CONSTANT_CONVERSION = YES; 392 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 393 | CLANG_WARN_EMPTY_BODY = YES; 394 | CLANG_WARN_ENUM_CONVERSION = YES; 395 | CLANG_WARN_INFINITE_RECURSION = YES; 396 | CLANG_WARN_INT_CONVERSION = YES; 397 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 398 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 399 | CLANG_WARN_UNREACHABLE_CODE = YES; 400 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 401 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 402 | COPY_PHASE_STRIP = NO; 403 | DEBUG_INFORMATION_FORMAT = dwarf; 404 | ENABLE_STRICT_OBJC_MSGSEND = YES; 405 | ENABLE_TESTABILITY = YES; 406 | GCC_C_LANGUAGE_STANDARD = gnu99; 407 | GCC_DYNAMIC_NO_PIC = NO; 408 | GCC_NO_COMMON_BLOCKS = YES; 409 | GCC_OPTIMIZATION_LEVEL = 0; 410 | GCC_PREPROCESSOR_DEFINITIONS = ( 411 | "DEBUG=1", 412 | "$(inherited)", 413 | ); 414 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 415 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 416 | GCC_WARN_UNDECLARED_SELECTOR = YES; 417 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 418 | GCC_WARN_UNUSED_FUNCTION = YES; 419 | GCC_WARN_UNUSED_VARIABLE = YES; 420 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 421 | MTL_ENABLE_DEBUG_INFO = YES; 422 | ONLY_ACTIVE_ARCH = YES; 423 | SDKROOT = iphoneos; 424 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 425 | TARGETED_DEVICE_FAMILY = "1,2"; 426 | }; 427 | name = Debug; 428 | }; 429 | ED1F2A391C61D44B0084DD77 /* Release */ = { 430 | isa = XCBuildConfiguration; 431 | buildSettings = { 432 | ALWAYS_SEARCH_USER_PATHS = NO; 433 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 434 | CLANG_CXX_LIBRARY = "libc++"; 435 | CLANG_ENABLE_MODULES = YES; 436 | CLANG_ENABLE_OBJC_ARC = YES; 437 | CLANG_WARN_BOOL_CONVERSION = YES; 438 | CLANG_WARN_CONSTANT_CONVERSION = YES; 439 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 440 | CLANG_WARN_EMPTY_BODY = YES; 441 | CLANG_WARN_ENUM_CONVERSION = YES; 442 | CLANG_WARN_INFINITE_RECURSION = YES; 443 | CLANG_WARN_INT_CONVERSION = YES; 444 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 445 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 446 | CLANG_WARN_UNREACHABLE_CODE = YES; 447 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 448 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 449 | COPY_PHASE_STRIP = NO; 450 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 451 | ENABLE_NS_ASSERTIONS = NO; 452 | ENABLE_STRICT_OBJC_MSGSEND = YES; 453 | GCC_C_LANGUAGE_STANDARD = gnu99; 454 | GCC_NO_COMMON_BLOCKS = YES; 455 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 456 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 457 | GCC_WARN_UNDECLARED_SELECTOR = YES; 458 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 459 | GCC_WARN_UNUSED_FUNCTION = YES; 460 | GCC_WARN_UNUSED_VARIABLE = YES; 461 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 462 | MTL_ENABLE_DEBUG_INFO = NO; 463 | SDKROOT = iphoneos; 464 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 465 | TARGETED_DEVICE_FAMILY = "1,2"; 466 | VALIDATE_PRODUCT = YES; 467 | }; 468 | name = Release; 469 | }; 470 | ED1F2A3B1C61D44B0084DD77 /* Debug */ = { 471 | isa = XCBuildConfiguration; 472 | buildSettings = { 473 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 474 | CODE_SIGN_IDENTITY = "iPhone Developer"; 475 | DEVELOPMENT_TEAM = 3PU2FX2MA5; 476 | INFOPLIST_FILE = SPTinderView/Info.plist; 477 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 478 | PRODUCT_BUNDLE_IDENTIFIER = com.suraj.SPTinderView; 479 | PRODUCT_NAME = "$(TARGET_NAME)"; 480 | SWIFT_VERSION = 3.0; 481 | }; 482 | name = Debug; 483 | }; 484 | ED1F2A3C1C61D44B0084DD77 /* Release */ = { 485 | isa = XCBuildConfiguration; 486 | buildSettings = { 487 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 488 | CODE_SIGN_IDENTITY = "iPhone Developer"; 489 | DEVELOPMENT_TEAM = 3PU2FX2MA5; 490 | INFOPLIST_FILE = SPTinderView/Info.plist; 491 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 492 | PRODUCT_BUNDLE_IDENTIFIER = com.suraj.SPTinderView; 493 | PRODUCT_NAME = "$(TARGET_NAME)"; 494 | SWIFT_VERSION = 3.0; 495 | }; 496 | name = Release; 497 | }; 498 | ED1F2A3E1C61D44B0084DD77 /* Debug */ = { 499 | isa = XCBuildConfiguration; 500 | buildSettings = { 501 | BUNDLE_LOADER = "$(TEST_HOST)"; 502 | INFOPLIST_FILE = SPTinderViewTests/Info.plist; 503 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 504 | PRODUCT_BUNDLE_IDENTIFIER = sg.com.propertyguru.SPTinderViewTests; 505 | PRODUCT_NAME = "$(TARGET_NAME)"; 506 | SWIFT_VERSION = 3.0; 507 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SPTinderView.app/SPTinderView"; 508 | }; 509 | name = Debug; 510 | }; 511 | ED1F2A3F1C61D44B0084DD77 /* Release */ = { 512 | isa = XCBuildConfiguration; 513 | buildSettings = { 514 | BUNDLE_LOADER = "$(TEST_HOST)"; 515 | INFOPLIST_FILE = SPTinderViewTests/Info.plist; 516 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 517 | PRODUCT_BUNDLE_IDENTIFIER = sg.com.propertyguru.SPTinderViewTests; 518 | PRODUCT_NAME = "$(TARGET_NAME)"; 519 | SWIFT_VERSION = 3.0; 520 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SPTinderView.app/SPTinderView"; 521 | }; 522 | name = Release; 523 | }; 524 | ED1F2A411C61D44B0084DD77 /* Debug */ = { 525 | isa = XCBuildConfiguration; 526 | buildSettings = { 527 | INFOPLIST_FILE = SPTinderViewUITests/Info.plist; 528 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 529 | PRODUCT_BUNDLE_IDENTIFIER = sg.com.propertyguru.SPTinderViewUITests; 530 | PRODUCT_NAME = "$(TARGET_NAME)"; 531 | TEST_TARGET_NAME = SPTinderView; 532 | USES_XCTRUNNER = YES; 533 | }; 534 | name = Debug; 535 | }; 536 | ED1F2A421C61D44B0084DD77 /* Release */ = { 537 | isa = XCBuildConfiguration; 538 | buildSettings = { 539 | INFOPLIST_FILE = SPTinderViewUITests/Info.plist; 540 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 541 | PRODUCT_BUNDLE_IDENTIFIER = sg.com.propertyguru.SPTinderViewUITests; 542 | PRODUCT_NAME = "$(TARGET_NAME)"; 543 | TEST_TARGET_NAME = SPTinderView; 544 | USES_XCTRUNNER = YES; 545 | }; 546 | name = Release; 547 | }; 548 | /* End XCBuildConfiguration section */ 549 | 550 | /* Begin XCConfigurationList section */ 551 | ED1F2A0D1C61D44B0084DD77 /* Build configuration list for PBXProject "SPTinderView" */ = { 552 | isa = XCConfigurationList; 553 | buildConfigurations = ( 554 | ED1F2A381C61D44B0084DD77 /* Debug */, 555 | ED1F2A391C61D44B0084DD77 /* Release */, 556 | ); 557 | defaultConfigurationIsVisible = 0; 558 | defaultConfigurationName = Release; 559 | }; 560 | ED1F2A3A1C61D44B0084DD77 /* Build configuration list for PBXNativeTarget "SPTinderView" */ = { 561 | isa = XCConfigurationList; 562 | buildConfigurations = ( 563 | ED1F2A3B1C61D44B0084DD77 /* Debug */, 564 | ED1F2A3C1C61D44B0084DD77 /* Release */, 565 | ); 566 | defaultConfigurationIsVisible = 0; 567 | defaultConfigurationName = Release; 568 | }; 569 | ED1F2A3D1C61D44B0084DD77 /* Build configuration list for PBXNativeTarget "SPTinderViewTests" */ = { 570 | isa = XCConfigurationList; 571 | buildConfigurations = ( 572 | ED1F2A3E1C61D44B0084DD77 /* Debug */, 573 | ED1F2A3F1C61D44B0084DD77 /* Release */, 574 | ); 575 | defaultConfigurationIsVisible = 0; 576 | defaultConfigurationName = Release; 577 | }; 578 | ED1F2A401C61D44B0084DD77 /* Build configuration list for PBXNativeTarget "SPTinderViewUITests" */ = { 579 | isa = XCConfigurationList; 580 | buildConfigurations = ( 581 | ED1F2A411C61D44B0084DD77 /* Debug */, 582 | ED1F2A421C61D44B0084DD77 /* Release */, 583 | ); 584 | defaultConfigurationIsVisible = 0; 585 | defaultConfigurationName = Release; 586 | }; 587 | /* End XCConfigurationList section */ 588 | }; 589 | rootObject = ED1F2A0A1C61D44B0084DD77 /* Project object */; 590 | } 591 | -------------------------------------------------------------------------------- /SPTinderView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SPTinderView.xcodeproj/xcshareddata/xcschemes/SPTinderView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 68 | 78 | 80 | 86 | 87 | 88 | 89 | 90 | 91 | 97 | 99 | 105 | 106 | 107 | 108 | 110 | 111 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /SPTinderView/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SPTinderView 4 | // 5 | // Created by Suraj Pathak on 3/2/16. 6 | // Copyright © 2016 Suraj Pathak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | return true 19 | } 20 | 21 | } 22 | 23 | -------------------------------------------------------------------------------- /SPTinderView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /SPTinderView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /SPTinderView/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /SPTinderView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewEdgeAntialiasing 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /SPTinderView/MyCustomTinderCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MyCustomTinderCell.swift 3 | // SPTinderView 4 | // 5 | // Created by Suraj Pathak on 7/2/16. 6 | // Copyright © 2016 Suraj Pathak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MyCustomTinderCell: SPTinderViewCell { 12 | @IBOutlet var imageView: UIImageView! 13 | @IBOutlet var titleLabel: UILabel! 14 | 15 | override func awakeFromNib() { 16 | super.awakeFromNib() 17 | self.frame = CGRect(x: 0, y: 0, width: 300, height: 400) 18 | imageView.clipsToBounds = true 19 | imageView.contentMode = .scaleAspectFill 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /SPTinderView/MyCustomTinderCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /SPTinderView/Source/SPTinderView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SPTinderView.swift 3 | // SPTinderView 4 | // 5 | // Created by Suraj Pathak on 3/2/16. 6 | // Copyright © 2016 Suraj Pathak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | /// Protocol that feeds the necessary data for SPTinderView 13 | @objc public protocol SPTinderViewDataSource: NSObjectProtocol { 14 | func numberOfItemsInTinderView(_ view: SPTinderView) -> Int 15 | func tinderView(_ view: SPTinderView, cellAt index: Int) -> SPTinderViewCell? 16 | } 17 | 18 | ///`SPTinderViewDelegate` tells the object conforming it about the actions about the cells in `SPTinderView` 19 | @objc public protocol SPTinderViewDelegate: NSObjectProtocol { 20 | func tinderView(_ view: SPTinderView, didMoveCellAt index: Int, towards direction: SPTinderViewCellMovement) 21 | func tinderView(_ view: SPTinderView, didSelectCellAt index: Int) 22 | } 23 | 24 | /// `SPTinderView` is view that mimics the behavior of shuffling cards of a deck left or right, as seen in the popular dating app *Tinder*. 25 | open class SPTinderView: UIView { 26 | 27 | // Cache 28 | fileprivate var caches: [SPCache] = [] 29 | 30 | @IBOutlet open var dataSource: SPTinderViewDataSource? { 31 | didSet { 32 | self.reloadData() 33 | } 34 | } 35 | 36 | @IBOutlet open var delegate: SPTinderViewDelegate? 37 | open var currentIndex: Int = 0 38 | fileprivate let visibleCount = 3 39 | fileprivate var numberOfCells = 0 40 | 41 | // MARK: Initialization 42 | public override init(frame: CGRect) { 43 | super.init(frame: frame) 44 | reloadData() 45 | } 46 | 47 | public required init?(coder aDecoder: NSCoder) { 48 | super.init(coder: aDecoder) 49 | reloadData() 50 | } 51 | 52 | open override func awakeFromNib() { 53 | reloadData() 54 | } 55 | 56 | open override func layoutSubviews() { 57 | super.layoutSubviews() 58 | adjustVisibleCellPosition() 59 | } 60 | 61 | fileprivate func setUpFirstSetOfCells() { 62 | guard let _dataSource = dataSource else { return } 63 | numberOfCells = _dataSource.numberOfItemsInTinderView(self) 64 | for index in currentIndex ..< min(visibleCount, numberOfCells - currentIndex) { 65 | insertCell(at: index) 66 | } 67 | adjustVisibleCellPosition() 68 | } 69 | 70 | fileprivate func cleanTinderView() { 71 | for cell in visibleCells() { 72 | cell.removeFromSuperview() 73 | recycleACell(cell) 74 | } 75 | currentIndex = 0 76 | } 77 | 78 | fileprivate func visibleCells() -> [SPTinderViewCell] { 79 | var cells: [SPTinderViewCell] = [] 80 | for aView in self.subviews { 81 | if let cell = aView as? SPTinderViewCell { 82 | cells.append(cell) 83 | } 84 | } 85 | return cells 86 | } 87 | 88 | fileprivate func insertCell(at index: Int) { 89 | guard let _dataSource = dataSource , index < numberOfCells else { return } 90 | if let cell = _dataSource.tinderView(self, cellAt: index) { 91 | cell.onCellDidMove = { [weak self] direction in 92 | guard let weakSelf = self else { return } 93 | if direction == .tapped { 94 | weakSelf.delegate?.tinderView(weakSelf, didSelectCellAt: index) 95 | } 96 | else if direction != .none { 97 | weakSelf.animateRemovalForCell(cell, towards: direction, completion: { 98 | weakSelf.delegate?.tinderView(weakSelf, didMoveCellAt: index, towards: direction) 99 | }) 100 | } 101 | } 102 | self.insertSubview(cell, at: 0) 103 | self.sendSubview(toBack: cell) 104 | cell.frame = self.bounds 105 | cell.center = self.center 106 | } 107 | } 108 | 109 | fileprivate func adjustVisibleCellPosition() { 110 | UIView.animate(withDuration: 0.3, animations: { 111 | for (position, cell) in self.visibleCells().enumerated() { 112 | cell.frame = self.bounds 113 | cell.center.y = self.center.y - CGFloat(position * 5) 114 | } 115 | }) 116 | } 117 | 118 | fileprivate func animateRemovalForCell(_ cell: SPTinderViewCell, towards direction: SPTinderViewCellMovement, completion:@escaping ()->()) { 119 | var newPosition = CGPoint.zero 120 | switch direction { 121 | case .none, .tapped: return 122 | case .left: newPosition = CGPoint(x: -2*cell.frame.width, y: cell.center.y) 123 | case .right: newPosition = CGPoint(x: 2*cell.frame.width, y: cell.center.y) 124 | case .top: newPosition = CGPoint(x: cell.center.x, y: -2*cell.frame.height) 125 | case .bottom: newPosition = CGPoint(x: cell.center.x, y: 2*cell.frame.height) 126 | } 127 | UIView.animate(withDuration: 0.3, animations: { 128 | cell.center = newPosition 129 | }, completion: { finished in 130 | cell.removeFromSuperview() 131 | self.recycleACell(cell) 132 | self.insertCell(at: self.currentIndex + self.visibleCount) 133 | self.currentIndex += 1 134 | self.adjustVisibleCellPosition() 135 | completion() 136 | }) 137 | } 138 | 139 | // MARK: open Method 140 | /** 141 | Register the Cell class from the provided nib file. The registered cells will be cached which can be retrieved usign ``dequeueReusableCellWithIdentifier: `` method 142 | 143 | @see dequeueReusableCellWithIdentifier: 144 | 145 | - parameter nib: UINib of the cell class of type `SPTinderViewCell` 146 | - parameter identifier: Identifier that ties the cellClass onto SPTinderView 147 | */ 148 | open func registerNib(_ nib: UINib?, forCellReuseIdentifier identifier: String) { 149 | guard let _nib = nib else { return } 150 | for _ in 0...visibleCount { 151 | if let cell = _nib.instantiate(withOwner: nil, options: nil).first as? SPTinderViewCell { 152 | for aView in cell.subviews { 153 | aView.translatesAutoresizingMaskIntoConstraints = false 154 | } 155 | registerACell(cell, forIdentifier: identifier) 156 | } 157 | } 158 | } 159 | /** 160 | Register a new cell class for a given identifier. The cell must conform to `SPTinderViewCell` to be a valid cell. The registered cells will be cached which can be retrieved usign ``dequeueReusableCellWithIdentifier: `` method 161 | 162 | @see dequeueReusableCellWithIdentifier: 163 | 164 | - parameter cellClass: Cell class that conforms to `SPTinderViewCell` 165 | - parameter identifier: Identifier that ties the cellClass onto SPTinderView 166 | */ 167 | open func registerClass(_ cellClass: AnyClass?, forCellReuseIdentifier identifier: String) { 168 | if let cell = cellClass as? SPTinderViewCell.Type { 169 | for _ in 0...visibleCount { 170 | registerACell(cell.init(reuseIdentifier: identifier), forIdentifier: identifier) 171 | } 172 | } 173 | } 174 | 175 | /** 176 | Returns a cached copy of a cell from the cache pool if a cell of given identifier exists. The `SPTinderView` must first register such cell using ``registerClass:forCellReuseIdentifier`` method 177 | 178 | - parameter identifier: identifier to look up 179 | 180 | - returns: `SPTinderViewCell` if cell exists in cache or a nil 181 | */ 182 | open func dequeueReusableCellWithIdentifier(_ identifier: String) -> SPTinderViewCell? { 183 | let cell = self.getAFreeCellForIdentifier(identifier) 184 | return cell 185 | } 186 | 187 | open func reloadData() { 188 | cleanTinderView() 189 | setUpFirstSetOfCells() 190 | } 191 | 192 | // MARK: Cache Management 193 | fileprivate func getAFreeCellForIdentifier(_ identifier: String) -> SPTinderViewCell? { 194 | for cache in caches { 195 | if cache.identifier == identifier { 196 | return cache.getAFreeCell() 197 | } 198 | } 199 | return nil 200 | } 201 | 202 | fileprivate func registerACell(_ cell: SPTinderViewCell, forIdentifier identifier: String) { 203 | for cache in caches { 204 | if cache.identifier == identifier { 205 | cache.recycleACell(cell) 206 | return 207 | } 208 | } 209 | let cache = SPCache(_identifier: identifier) 210 | cache.recycleACell(cell) 211 | caches.append(cache) 212 | } 213 | 214 | fileprivate func recycleACell(_ cell: SPTinderViewCell) { 215 | for cache in caches { 216 | if cache.identifier == cell.reuseIdentifier { 217 | cache.recycleACell(cell) 218 | return 219 | } 220 | } 221 | } 222 | } 223 | 224 | /// SPCache class manages the cell cache for SPTinderView 225 | private class SPCache { 226 | var identifier: String 227 | var cachedCells: [CachedCell] = [] 228 | 229 | required init(_identifier: String) { 230 | identifier = _identifier 231 | } 232 | 233 | func recycleACell(_ cell: SPTinderViewCell) { 234 | for cachedCell in cachedCells { 235 | if cachedCell.cell == cell { 236 | cachedCell.isFree = true 237 | break 238 | } 239 | } 240 | let cachedCell = CachedCell(_cell: cell) 241 | cachedCells.append(cachedCell) 242 | } 243 | 244 | func getAFreeCell() -> SPTinderViewCell? { 245 | for cachedCell in cachedCells { 246 | if cachedCell.isFree { 247 | cachedCell.isFree = false 248 | cachedCell.cell.alpha = 1.0 249 | cachedCell.cell.transform = CGAffineTransform.identity 250 | return cachedCell.cell 251 | } 252 | } 253 | return nil 254 | } 255 | } 256 | 257 | private class CachedCell { 258 | var cell: SPTinderViewCell 259 | var isFree: Bool = true 260 | 261 | required init(_cell: SPTinderViewCell) { 262 | cell = _cell 263 | isFree = true 264 | } 265 | } 266 | -------------------------------------------------------------------------------- /SPTinderView/Source/SPTinderViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SPTinderViewCell.swift 3 | // SPTinderView 4 | // 5 | // Created by Suraj Pathak on 3/2/16. 6 | // Copyright © 2016 Suraj Pathak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /// The SPTinderViewCell defines the attributes and behavior of the cells that appear in SPTinderView objects. This class includes properties and methods for setting and managing cell content and background. 12 | 13 | @IBDesignable 14 | open class SPTinderViewCell: UIView, UIGestureRecognizerDelegate { 15 | @IBInspectable var reuseIdentifier: String? 16 | @IBInspectable var cornerRadius: CGFloat = 0 { 17 | didSet { 18 | self.layer.cornerRadius = cornerRadius 19 | } 20 | } 21 | 22 | var cellMovement: SPTinderViewCellMovement = .none 23 | 24 | typealias cellMovementChange = (SPTinderViewCellMovement) -> () 25 | var onCellDidMove: cellMovementChange? 26 | 27 | fileprivate var originalCenter = CGPoint(x: 0, y: 0) 28 | fileprivate var scaleToRemoveCell: CGFloat = 0.3 29 | open override func awakeFromNib() { 30 | super.awakeFromNib() 31 | self.layer.shadowOffset = CGSize(width: 0.0, height: 5.0) 32 | } 33 | 34 | public required init(reuseIdentifier: String) { 35 | self.init() 36 | self.reuseIdentifier = reuseIdentifier 37 | } 38 | 39 | public override init(frame: CGRect) { 40 | super.init(frame: frame) 41 | setupLayerAttributes() 42 | } 43 | 44 | public required init?(coder aDecoder: NSCoder) { 45 | super.init(coder: aDecoder) 46 | setupLayerAttributes() 47 | } 48 | 49 | fileprivate func setupLayerAttributes() { 50 | self.layer.shouldRasterize = false 51 | self.layer.borderWidth = 2.0 52 | self.layer.borderColor = UIColor.clear.cgColor 53 | self.layer.shadowColor = UIColor.darkGray.cgColor 54 | self.layer.shadowOffset = CGSize(width: 0.0, height: 5.0) 55 | self.layer.shadowOpacity = 0.5 56 | self.layer.masksToBounds = false 57 | } 58 | 59 | open override func touchesBegan(_ touches: Set, with event: UIEvent?) { 60 | guard let _ = touches.first else { return } 61 | originalCenter = self.center 62 | } 63 | 64 | open override func touchesMoved(_ touches: Set, with event: UIEvent?) { 65 | if let touch = touches.first { 66 | let prevLoc = touch.previousLocation(in: self) 67 | let thisLoc = touch.location(in: self) 68 | 69 | let deltaX = thisLoc.x - prevLoc.x 70 | let deltaY = thisLoc.y - prevLoc.y 71 | // There's also a little bit of transformation. When the cell is being dragged, it should feel the angle of drag as well 72 | let xDrift = self.center.x + deltaX - originalCenter.x 73 | let rotationAngle = xDrift * -0.05 * CGFloat(Double.pi / 90) 74 | // Note: Must set the animation option to `AllowUserInteraction` to prevent the main thread being blocked while animation is ongoin 75 | let rotatedTransfer = CGAffineTransform(rotationAngle: rotationAngle) 76 | UIView.animate(withDuration: 0.0, delay: 0.0, options: [.allowUserInteraction], animations: { 77 | self.transform = rotatedTransfer 78 | self.center.x += deltaX 79 | self.center.y += deltaY 80 | }, completion: { finished in 81 | 82 | }) 83 | } 84 | } 85 | 86 | open override func touchesEnded(_ touches: Set, with event: UIEvent?) { 87 | let xDrift = self.center.x - originalCenter.x 88 | let yDrift = self.center.y - originalCenter.y 89 | self.setCellMovementDirectionFromDrift(xDrift, yDrift: yDrift) 90 | } 91 | 92 | open override func touchesCancelled(_ touches: Set, with event: UIEvent?) { 93 | UIView.animate(withDuration: 0.2, delay: 0.1, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.1, options: [.allowUserInteraction], animations: { 94 | self.center = self.originalCenter 95 | self.transform = CGAffineTransform.identity 96 | }, completion: { finished in 97 | }) 98 | } 99 | 100 | open override func touchesEstimatedPropertiesUpdated(_ touches: Set) { 101 | // 102 | } 103 | 104 | func setCellMovementDirectionFromDrift(_ xDrift: CGFloat, yDrift: CGFloat){ 105 | if xDrift == 0, yDrift == 0 { 106 | onCellDidMove?(.tapped) 107 | return 108 | } 109 | var movement: SPTinderViewCellMovement = .none 110 | if(xDrift > self.frame.width * scaleToRemoveCell) { movement = .right } 111 | else if(-xDrift > self.frame.width * scaleToRemoveCell) { movement = .left } 112 | else if(-yDrift > self.frame.height * scaleToRemoveCell) { movement = .top } 113 | else if(yDrift > self.frame.height * scaleToRemoveCell) { movement = .bottom } 114 | else { movement = .none } 115 | if movement != .none { 116 | self.cellMovement = movement 117 | if let cellMoveBlock = onCellDidMove { 118 | cellMoveBlock(movement) 119 | } 120 | } else { 121 | UIView.animate(withDuration: 0.5, delay: 0.1, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.5, options: [.allowUserInteraction], animations: { 122 | self.center = self.originalCenter 123 | self.transform = CGAffineTransform.identity 124 | }, completion: nil) 125 | } 126 | } 127 | } 128 | 129 | /** 130 | `SPTinderViewCellMovement` defines the four types of movement when the cell is dragged around. 131 | 132 | - None: When the cell has not moved or not been moved enough to be considered one of the other 4 movements 133 | - Top: When the cell has moved towards top 134 | - Left: When the cell has moved towards left 135 | - Bottom: When the cell has moved towards bottom 136 | - Right: When the cell has moved towards right 137 | */ 138 | @objc public enum SPTinderViewCellMovement: Int { 139 | case none 140 | case top 141 | case left 142 | case bottom 143 | case right 144 | case tapped 145 | } 146 | 147 | -------------------------------------------------------------------------------- /SPTinderView/TinderGirls/tg1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freesuraj/SPTinderView/674f74636b1c9b5da45b19afb2587c954b354f63/SPTinderView/TinderGirls/tg1.jpg -------------------------------------------------------------------------------- /SPTinderView/TinderGirls/tg2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freesuraj/SPTinderView/674f74636b1c9b5da45b19afb2587c954b354f63/SPTinderView/TinderGirls/tg2.jpg -------------------------------------------------------------------------------- /SPTinderView/TinderGirls/tg3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freesuraj/SPTinderView/674f74636b1c9b5da45b19afb2587c954b354f63/SPTinderView/TinderGirls/tg3.jpg -------------------------------------------------------------------------------- /SPTinderView/TinderGirls/tg4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freesuraj/SPTinderView/674f74636b1c9b5da45b19afb2587c954b354f63/SPTinderView/TinderGirls/tg4.jpg -------------------------------------------------------------------------------- /SPTinderView/TinderGirls/tg5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freesuraj/SPTinderView/674f74636b1c9b5da45b19afb2587c954b354f63/SPTinderView/TinderGirls/tg5.jpg -------------------------------------------------------------------------------- /SPTinderView/TinderGirls/tg6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freesuraj/SPTinderView/674f74636b1c9b5da45b19afb2587c954b354f63/SPTinderView/TinderGirls/tg6.jpg -------------------------------------------------------------------------------- /SPTinderView/TinderModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TinderModel.swift 3 | // SPTinderView 4 | // 5 | // Created by Suraj Pathak on 10/2/16. 6 | // Copyright © 2016 Suraj Pathak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | // MARK: UIColor 12 | extension UIColor { 13 | /** 14 | Returns a random UIColor with full opacity 15 | */ 16 | static func getRandomColor() -> UIColor { 17 | 18 | let randomRed:CGFloat = CGFloat(drand48()) 19 | let randomGreen:CGFloat = CGFloat(drand48()) 20 | let randomBlue:CGFloat = CGFloat(drand48()) 21 | 22 | return UIColor(red: randomRed, green: randomGreen, blue: randomBlue, alpha: 1.0) 23 | } 24 | } 25 | 26 | struct TinderModel { 27 | static func randomImage() -> UIImage? { 28 | let number = Int(arc4random_uniform(6) + 1) 29 | return UIImage(named: "tg\(number).jpg") 30 | } 31 | } -------------------------------------------------------------------------------- /SPTinderView/TinderViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TinderViewController.swift 3 | // SPTinderView 4 | // 5 | // Created by Suraj Pathak on 10/2/16. 6 | // Copyright © 2016 Suraj Pathak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class TinderViewController: UIViewController { 12 | let cellIdentifier = "MyCustomTinderCell" 13 | @IBOutlet var tinderView: SPTinderView! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | tinderView.frame = self.view.frame 18 | tinderView.registerNib(UINib(nibName: "MyCustomTinderCell", bundle: nil), forCellReuseIdentifier: cellIdentifier) 19 | tinderView.dataSource = self 20 | tinderView.delegate = self 21 | tinderView.backgroundColor = UIColor.white 22 | } 23 | 24 | override func didReceiveMemoryWarning() { 25 | super.didReceiveMemoryWarning() 26 | // Dispose of any resources that can be recreated. 27 | } 28 | } 29 | 30 | extension TinderViewController: SPTinderViewDataSource, SPTinderViewDelegate { 31 | func tinderView(_ view: SPTinderView, didSelectCellAt index: Int) { 32 | title = "Did select at \(index)" 33 | } 34 | 35 | func numberOfItemsInTinderView(_ view: SPTinderView) -> Int { 36 | return 100 37 | } 38 | 39 | func tinderView(_ view: SPTinderView, cellAt index: Int) -> SPTinderViewCell? { 40 | if let cell = tinderView.dequeueReusableCellWithIdentifier(cellIdentifier) as? MyCustomTinderCell { 41 | cell.imageView.image = TinderModel.randomImage() 42 | cell.titleLabel.text = "Model No: \(index+1)" 43 | return cell 44 | } 45 | return nil 46 | } 47 | 48 | func tinderView(_ view: SPTinderView, didMoveCellAt index: Int, towards direction: SPTinderViewCellMovement) { 49 | print("\(direction)") 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /SPTinderView/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SPTinderView 4 | // 5 | // Created by Suraj Pathak on 3/2/16. 6 | // Copyright © 2016 Suraj Pathak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | class MyTinderCell: SPTinderViewCell { 13 | let titleLabel: UILabel = UILabel(frame: CGRect.zero) 14 | let imageView: UIImageView = UIImageView(frame: CGRect.zero) 15 | 16 | override init(frame: CGRect) { 17 | super.init(frame: frame) 18 | } 19 | 20 | required init?(coder aDecoder: NSCoder) { 21 | super.init(coder: aDecoder) 22 | } 23 | 24 | required init(reuseIdentifier: String) { 25 | super.init(reuseIdentifier: reuseIdentifier) 26 | self.frame = CGRect(origin: CGPoint.zero, size: CGSize(width: 300, height: 400)) 27 | self.backgroundColor = UIColor.getRandomColor() 28 | titleLabel.frame = CGRect(x: 0, y: self.frame.height - 50, width: self.frame.width, height: 50) 29 | imageView.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height - 50) 30 | imageView.clipsToBounds = true 31 | imageView.contentMode = .scaleAspectFill 32 | titleLabel.textAlignment = .center 33 | titleLabel.backgroundColor = UIColor.green 34 | self.addSubview(imageView) 35 | self.addSubview(titleLabel) 36 | self.cornerRadius = 6.0 37 | } 38 | } 39 | 40 | class ViewController: UIViewController { 41 | @IBOutlet var tinderView: SPTinderView! 42 | let cellIdentifier = "MyTinderCell" 43 | var cellCount = 5 44 | 45 | override func viewDidLoad() { 46 | super.viewDidLoad() 47 | tinderView.frame = self.view.frame 48 | tinderView.registerClass(MyTinderCell.self, forCellReuseIdentifier: cellIdentifier) 49 | tinderView.dataSource = self 50 | tinderView.delegate = self 51 | tinderView.backgroundColor = UIColor.white 52 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "RELOAD", style: .plain, target: self, action: #selector(ViewController.onReload)) 53 | } 54 | 55 | override func didReceiveMemoryWarning() { 56 | super.didReceiveMemoryWarning() 57 | } 58 | 59 | func onReload() { 60 | cellCount += 1 61 | tinderView.reloadData() 62 | } 63 | } 64 | 65 | extension ViewController: SPTinderViewDataSource, SPTinderViewDelegate { 66 | func tinderView(_ view: SPTinderView, didSelectCellAt index: Int) { 67 | title = "Did select at \(index)" 68 | } 69 | 70 | func numberOfItemsInTinderView(_ view: SPTinderView) -> Int { 71 | return cellCount 72 | } 73 | 74 | func tinderView(_ view: SPTinderView, cellAt index: Int) -> SPTinderViewCell? { 75 | if let cell = tinderView.dequeueReusableCellWithIdentifier(cellIdentifier) as? MyTinderCell { 76 | cell.titleLabel.text = "Model No: \(index+1)" 77 | cell.imageView.image = TinderModel.randomImage() 78 | return cell 79 | } 80 | return nil 81 | } 82 | 83 | func tinderView(_ view: SPTinderView, didMoveCellAt index: Int, towards direction: SPTinderViewCellMovement) { 84 | print("\(direction)") 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /SPTinderViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SPTinderViewTests/SPTinderViewTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SPTinderViewTests.swift 3 | // SPTinderViewTests 4 | // 5 | // Created by Suraj Pathak on 3/2/16. 6 | // Copyright © 2016 Suraj Pathak. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class SPTinderViewTests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | } 16 | 17 | override func tearDown() { 18 | // Put teardown code here. This method is called after the invocation of each test method in the class. 19 | super.tearDown() 20 | } 21 | 22 | func testExample() { 23 | XCTAssertEqual(4, 2+2) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SPTinderViewUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SPTinderViewUITests/SPTinderViewUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SPTinderViewUITests.swift 3 | // SPTinderViewUITests 4 | // 5 | // Created by Suraj Pathak on 3/2/16. 6 | // Copyright © 2016 Suraj Pathak. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class SPTinderViewUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /assets/screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freesuraj/SPTinderView/674f74636b1c9b5da45b19afb2587c954b354f63/assets/screenshot.gif --------------------------------------------------------------------------------