{"id":13465755,"url":"https://github.com/moritzsternemann/SwipyCell","last_synced_at":"2025-03-25T16:32:41.642Z","repository":{"id":56573147,"uuid":"50125524","full_name":"moritzsternemann/SwipyCell","owner":"moritzsternemann","description":"Easy to use UITableViewCell implementing swiping to trigger actions.","archived":false,"fork":false,"pushed_at":"2023-08-30T17:36:41.000Z","size":1457,"stargazers_count":259,"open_issues_count":4,"forks_count":31,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-21T18:01:37.471Z","etag":null,"topics":["awesome","carthage","cocoapods","gesture","ios","mailbox","swift","swift-library","swift-package","swift-package-manager","swiftpm","swipe","trigger","uitableviewcell"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moritzsternemann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-01-21T17:49:53.000Z","updated_at":"2024-12-22T04:47:28.000Z","dependencies_parsed_at":"2024-01-02T23:55:50.629Z","dependency_job_id":null,"html_url":"https://github.com/moritzsternemann/SwipyCell","commit_stats":{"total_commits":73,"total_committers":7,"mean_commits":"10.428571428571429","dds":0.4657534246575342,"last_synced_commit":"b352081ad17069a42a9e267c4029036bf515a88e"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moritzsternemann%2FSwipyCell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moritzsternemann%2FSwipyCell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moritzsternemann%2FSwipyCell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moritzsternemann%2FSwipyCell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moritzsternemann","download_url":"https://codeload.github.com/moritzsternemann/SwipyCell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245500452,"owners_count":20625582,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["awesome","carthage","cocoapods","gesture","ios","mailbox","swift","swift-library","swift-package","swift-package-manager","swiftpm","swipe","trigger","uitableviewcell"],"created_at":"2024-07-31T15:00:34.915Z","updated_at":"2025-03-25T16:32:41.315Z","avatar_url":"https://github.com/moritzsternemann.png","language":"Swift","funding_links":[],"categories":["Libs","TableView","Gesture [🔝](#readme)"],"sub_categories":["Gesture"],"readme":"SwipyCell\n---------\n[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)\n[![Build Status](https://travis-ci.org/moritzsternemann/SwipyCell.svg)](https://travis-ci.org/moritzsternemann/SwipyCell)\n[![Swift Copatibility](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fmoritzsternemann%2FSwipyCell%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/moritzsternemann/SwipyCell)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/SwipyCell.svg)](https://github.com/moritzsternemann/SwipyCell)\n[![Platform](https://img.shields.io/cocoapods/p/SwipyCell.svg)](https://github.com/moritzsternemann/SwipyCell)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/moritzsternemann/SwipyCell/master/LICENSE)\n[![Twitter](https://img.shields.io/badge/twitter-@strnmn-blue.svg?style=flat)](https://twitter.com/strnmn)\n\n*Swipeable UITableViewCell inspired by the popular [Mailbox App](http://mailboxapp.com), implemented in [Swift](https://github.com/apple/swift).*\n\n\u003cp align=\"center\"\u003e\u003cimg src=\".github/images/swipycell-hero.jpg\" width=\"50%\"/\u003e\u003c/p\u003e\n\n## Preview\n\n### Exit Mode\n\nThe `.exit` mode is the original behavior, known from the Mailbox app.\n\u003cp align=\"center\"\u003e\u003cimg src=\".github/images/swipycell-exit.gif\" width=\"50%\"/\u003e\u003c/p\u003e\n\n### Toggle Mode\n\nThe `.toggle` is another behavior where the cell will bounce back after swiping it.\n\u003cp align=\"center\"\u003e\u003cimg src=\".github/images/swipycell-switch.gif\" width=\"50%\"/\u003e\u003c/p\u003e\n\n## Installation\n\n### Swift Package Manager (recommended)\n[Swift Package Manger](https://github.com/apple/swift-package-manager) is Apples first party tool for managing distribution of source code, aimed at making it easy to share your code and reuse others’ code.\n\nTo use the `SwipyCell` library in a SwiftPM project, add the following line to the dependencies in your `Package.swift` file:\n\n```swift\n.package(url: \"https://github.com/moritzsternemann/SwipyCell\", .upToNextMinor(from: \"4.1.0\")),\n```\n\n### CocoaPods\n[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects.\n\nTo integrate SwipyCell into your project using CocoaPods, add it to your `Podfile`:\n```\npod 'SwipyCell', '~\u003e 4.1'\n```\n\n### Carthage\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.\n\nTo integrate SwipyCell into your project using Carthage, add it to your `Cartfile`:\n```\ngithub \"moritzsternemann/SwipyCell\" \u003e= 4.1\n```\n\n## Usage\n### Example\nA complete example is available in the [Example](https://github.com/moritzsternemann/SwipyCell/tree/master/Example) directory.\nThe following code is a very basic example:\n```swift\noverride func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -\u003e UITableViewCell {\n    let cell = tableView.dequeueReusableCell(withIdentifier: \"cell\", for: indexPath) as! SwipyCell\n    cell.selectionStyle = .gray\n    cell.contentView.backgroundColor = UIColor.white\n\n    let checkView = viewWithImageName(\"check\")\n    let greenColor = UIColor(red: 85.0 / 255.0, green: 213.0 / 255.0, blue: 80.0 / 255.0, alpha: 1.0)\n\n    let crossView = viewWithImageName(\"cross\")\n    let redColor = UIColor(red: 232.0 / 255.0, green: 61.0 / 255.0, blue: 14.0 / 255.0, alpha: 1.0)\n\n    let clockView = viewWithImageName(\"clock\")\n    let yellowColor = UIColor(red: 254.0 / 255.0, green: 217.0 / 255.0, blue: 56.0 / 255.0, alpha: 1.0)\n\n    let listView = viewWithImageName(\"list\")\n    let brownColor = UIColor(red: 206.0 / 255.0, green: 149.0 / 255.0, blue: 98.0 / 255.0, alpha: 1.0)\n\n    cell.defaultColor = tableView.backgroundView?.backgroundColor\n    cell.delegate = self\n\n    cell.textLabel?.text = \"Switch Mode Cell\"\n    cell.detailTextLabel?.text = \"Swipe to switch\"\n\n    cell.addSwipeTrigger(forState: .state(0, .left), withMode: .toggle, swipeView: checkView, swipeColor: greenColor, completion: { cell, trigger, state, mode in\n        print(\"Did swipe \\\"Checkmark\\\" cell\")\n    })\n\n    cell.addSwipeTrigger(forState: .state(1, .left), withMode: .toggle, swipeView: crossView, swipeColor: redColor, completion: { cell, trigger, state, mode in\n        print(\"Did swipe \\\"Cross\\\" cell\")\n    })\n\n    cell.addSwipeTrigger(forState: .state(0, .right), withMode: .toggle, swipeView: clockView, swipeColor: yellowColor, completion: { cell, trigger, state, mode in\n        print(\"Did swipe \\\"Clock\\\" cell\")\n    })\n\n    cell.addSwipeTrigger(forState: .state(1, .right), withMode: .toggle, swipeView: listView, swipeColor: brownColor, completion: { cell, trigger, state, mode in\n        print(\"Did swipe \\\"List\\\" cell\")\n    })\n\n    return cell\n}\n```\n\n### SwipyCellState\nSwipyCellState represents a sliding state, for example the first state to the left of the cell.\u003cbr\u003e\nThe possible values are\n - `.none` - center position of the cell\n - `.state(index, side)` - *index* of the state from near to far and *side* of the state, each relative to the cell\n\n### SwipyCellMode\nSwipyCellMode as shown above.\n\n### SwipyCellTriggerBlock\nSwipyCellTriggerBlock is a typealias for\n```\n(SwipyCell, SwipyCellTrigger, SwipyCellState, SwipyCellMode) -\u003e Void\n```\n\n### Add swipe triggers to cells\nAdding swipe triggers to cells is easy using this method:\n```swift\nfunc addSwipeTrigger(forState: SwipyCellState, withMode: SwipyCellMode, swipeView: UIView, swipeColor: UIColor, completion: SwipyCellTriggerBlock)\n```\n- `forState` at which the trigger should activate\n- `withMode` for the trigger\n- `swipeView`: e.g. display an icon\n- `swipeColor`: backgroundColor of the swipeView\n- `completion`: called after the swipe gesture has ended, only if the trigger point was reached\n\n### Delegate\nSwipyCell provides three delegate methods in order to track the users behaviors.\n```swift\n// When the user starts swiping the cell this method is called\nfunc swipyCellDidStartSwiping(_ cell: SwipyCell)\n\n// When the user ends swiping the cell this method is called\nfunc swipyCellDidFinishSwiping(_ cell: SwipyCell, atState state: SwipyCellState, triggerActivated activated: Bool)\n\n// When the user is dragging, this method is called with the percentage from the border\nfunc swipyCell(_ cell: SwipyCell, didSwipeWithPercentage percentage: CGFloat, currentState state: SwipyCellState, triggerActivated activated: Bool)\n```\n\n\n### Configuration\nAll configurable options are defined in the `SwipyCellConfig.shared` singleton object. Every new cell has these options set as defaults. To alter the defaults simply change the variables of the `SwipyCellConfig` singleton object.\n\n\n#### Trigger Points\nTrigger points are defined in the `triggerPoints\u003cCGFloat, SwipyCellState\u003e` dictionary in either the configuration singleton or each cell individually.\u003cbr\u003e\nEach key marks the swiping percentage for a trigger point; the corresponding value is an identifier to reference the trigger point later. A negative key marks a point on the right side of the cell (slide to the left), a positive key marks a point on the left side of the cell (slide to the right).\u003cbr\u003e\nTo modify the trigger points there are a couple of methods available on every cell as well as the configuration singleton:\n```swift\n// Set a new trigger point for the given state\nfunc setTriggerPoint(forState state: SwipyCellState, at point: CGFloat)\n\n// Set a new trigger point for the given index on BOTH sides of the cell\nfunc setTriggerPoint(forIndex index: Int, at point: CGFloat)\n\n// Overwrite all existing trigger points with the given new ones\nfunc setTriggerPoints(_ points: [CGFloat: SwipyCellState])\n// The Integer parameter is the index for BOTH sides of the cell\nfunc setTriggerPoints(_ points: [CGFloat: Int])\n\n// Overwrite all existing trigger points with new ones in order of the array on BOTH sides\nfunc setTriggerPoints(points: [CGFloat])\n\n// Get all existing trigger points\nfunc getTriggerPoints() -\u003e [CGFloat: SwipyCellState]\n\n// Clear all existing trigger points\nfunc clearTriggerPoints()\n```\n*Defaults: 25% and 75% on each side*\n\n#### swipeViewPadding\n```swift\nvar swipeViewPadding: CGFloat\n```\nswipeViewPadding is the padding between the swipe view and and the outer edge of the cell.\n\n*Default: `24.0`*\n\n#### shouldAnimateSwipeViews\n```swift\nvar shouldAnimateSwipeViews: Bool\n```\n`shouldAnimateSwipeViews` sets if the swipeView should move with the cell while sliding or stay at the outer edge.\n\n*Default: `true`*\n\n#### defaultSwipeViewColor\n```swift\nvar defaultSwipeViewColor: UIColor\n```\n`defaultSwipeViewColor` is the color of the swipe when the current state is `.none`.\n\n*Default: `UIColor.white`*\n\n### Resetting the cell position\nYou can animate the cell back to it's default position when using `.exit` mode using the `swipeToOrigin(_:)` method. This could be useful if your app asks the user for confirmation and the user want's to cancel the action.\n```swift\ncell.swipeToOrigin {\n    print(\"Swiped back\")\n}\n```\n\n## Author\nI'm [Moritz Sternemann](https://github.com/moritzsternemann), a computer-science student at [Technical University of Munich](https://www.tum.de/en/).\n- Email: [opensource@moritzsternemann.de](mailto:opensource@moritzsternemann.de)\n- Twitter: [@strnmn](https://twitter.com/strnmn)\n- LinkedIn: [/in/moritzsternemann](https://www.linkedin.com/in/moritzsternemann)\n\n## License\nSwipyCell is available under the MIT license. See LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoritzsternemann%2FSwipyCell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoritzsternemann%2FSwipyCell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoritzsternemann%2FSwipyCell/lists"}