{"id":15037792,"url":"https://github.com/nunogoncalves/ios-multiselectiontable","last_synced_at":"2025-04-09T23:33:06.747Z","repository":{"id":13838219,"uuid":"75091771","full_name":"nunogoncalves/iOS-MultiSelectionTable","owner":"nunogoncalves","description":"Beautiful way of having a multi-selection table on iOS written in Swift","archived":false,"fork":false,"pushed_at":"2022-07-22T04:46:52.000Z","size":20855,"stargazers_count":158,"open_issues_count":10,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-24T01:23:00.800Z","etag":null,"topics":["dribbble","ios","ios-demo","ios-dribbble","ios-lib","ios-multiselection","multiselect","swift","swift-3","tableview","ui"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nunogoncalves.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-29T14:57:46.000Z","updated_at":"2024-02-04T02:37:57.000Z","dependencies_parsed_at":"2022-08-07T07:15:47.923Z","dependency_job_id":null,"html_url":"https://github.com/nunogoncalves/iOS-MultiSelectionTable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunogoncalves%2FiOS-MultiSelectionTable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunogoncalves%2FiOS-MultiSelectionTable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunogoncalves%2FiOS-MultiSelectionTable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunogoncalves%2FiOS-MultiSelectionTable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nunogoncalves","download_url":"https://codeload.github.com/nunogoncalves/iOS-MultiSelectionTable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248129975,"owners_count":21052671,"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":["dribbble","ios","ios-demo","ios-dribbble","ios-lib","ios-multiselection","multiselect","swift","swift-3","tableview","ui"],"created_at":"2024-09-24T20:35:44.489Z","updated_at":"2025-04-09T23:33:06.713Z","avatar_url":"https://github.com/nunogoncalves.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iOS-MultiSelectionTable\nBeautifull way of having a multi-selection table on iOS\n\n[![Swift 5.1](https://img.shields.io/badge/Swift-5.1-orange.svg?style=flat)](https://developer.apple.com/swift/)\n[![Xcode 11.2.1+](https://img.shields.io/badge/Xcode-11.2+-blue.svg?style=flat)](https://developer.apple.com/swift/)\n[![Platforms iOS](https://img.shields.io/badge/Platforms-iOS%2013+-blue.svg?style=flat)](https://developer.apple.com/swift/)\n[![Licence MIT](https://img.shields.io/packagist/l/doctrine/orm.svg)](https://opensource.org/licenses/MIT)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"Resources/MultiSelectionTableView1.gif\" width=\"200px\" /\u003e\n  \u003cimg src=\"Resources/MultiselectionSupermanAnimation.gif\" width=\"200px\" /\u003e\n  \u003cimg src=\"Resources/StyleBlack.png\" width=\"200px\" /\u003e\n  \u003cimg src=\"Resources/StyleRed.png\" width=\"200px\" /\u003e\n\u003c/p\u003e\n\nBased on [this](https://dribbble.com/shots/2904577-Multi-Selection-Experiment) dribbble by [Vitaly Rubtsov](https://dribbble.com/Vitwai)\n\n## How it works:\n```MultiSelectionTable``` underneath is composed of a view and a data source, much like the ```UITableView```'s ```UITableViewDataSource/Delegate```. They both know each other and communicate between themselves.\nThe view is is composed by two configurable ```UITableView``` and a line seperating them. The DataSource keeps the data the ```UITableView```s display.\n\n## Considerations:\n(before Usage, pay attention to the following considerations)\n- In order to achieve a nice effect when transitioning, cells on the right (selected cells) must be equal to the cells on the left (all items cells).\n- The item object you are displaying, must conform with the ```Equatable``` protocol so the control can know where to move the items when unselecting items.\n-You can also paginate and use search on your items list. The table keeps a reference to the selected items.\n- The Marvel developers API has a 3000 requests limit per day. If this is reached and you can't try the Marvel example, you need to create a developers account to get credentials. Then replace them in ```Heroes.Fetcher.swift``` file\n\n## Usage:\n\n### Most basic usage:\n\nConsidering you are using MultiSelectionTableView in ViewController:\n\n```swift\n\nvar multiSelectionDataSource: MultiSelectionDataSource\u003cMyItem\u003e! //MyItems must be Equatable\nvar multiSelectionTableView: MultiSelectionTableView!\n\nvar allItems: [MyItem] = [] //MyItem must be Equatable\n\noverride func viewDidLoad() {\n     super.viewDidLoad()\n\n     multiSelectionTableView = MultiSelectionTableView()\n     view.addSubview(multiSelectionTableView)\n\n     multiSelectionDataSource = MultiSelectionDataSource(multiSelectionTableView: multiSelectionTableView)\n     multiSelectionDataSource.delegate = self\n     let cellReuseIdentifier = \"MyCell\"\n     multiSelectionDataSource.register(nib: UINib(nibName: \"MyCustomCellNibName\", bundle: nil), for: cellReuseIdentifier)\n\n     multiSelectionDataSource.allItems = allItems\n\n     multiSelectionTableView.dataSource = multiSelectionDataSource\n }\n\nextension ViewController : MultiSelectionTableDelegate {\n\n    func paint(_ cell: UITableViewCell, for indexPath: IndexPath, with item: Any) {\n        if let cell = cell as? MyCustomCell,\n            let myItem = item as? MyItem {\n            //configureCellWithMyItem\n        }\n    }\n\n}\n```\n\n### Costumization\n#### Colors style\n```swift\nmultiSelectionTableView.controlBackgroundColor = .black\nmultiSelectionTableView.allItemsTableBackgroundColor = .black\nmultiSelectionTableView.selectedItemsTableBackgroundColor = .black\n```\n#### Horizontal movement width:\nDepending on your cell, you might want to set the horizontal width the line moves. This value is based on the center X anchor.\n```swift\nmultiSelectionTableView.seperatorWidthOffset = 100 //will move 100 point on both directions from the center\n```\n#### Animations\nThere are two animation types. The selection and the transition. You can customize your animations for both types.\nThe default selection animation is a pulse starting on the tap point on the cell.\nThe default transition animation moves a snapshot view of the selected cell to the corresponding side (depending on selection or unselection events)\n```swift\n\nmultiSelectionTableView.cellAnimator = CellSelectionPulseAnimator(pulseColor: .black) // Must conform to CellSelectionAnimator\nmultiSelectionTableView.cellTransitioner = CellFlyerAnimator() // Must conform to CellTransitionAnimator\n\n```\nYou can check out the animator examples.\n\n### Pagination\nIf you want MultiSelectionTableView to handle pagination you need to set:\n```swift\nmultiSelectionTableView.supportsPagination = true\n```\nand you can add a target action to the control.\n\n```swift\nmultiSelectionTableView.addTarget(self, action: #selector(loadMoreData(sender:)), for: .scrollReachingEnd)\n```\n\nAditionally, you can have some control of when to get more data setting \n```swift \nmultiSelectionTableView.paginationNotificationRowIndex = 5\n```\nthis will call .scrollReachingEnd action 5 rows before reaching the end of the table, so you can pre fetch next page data.\n\n### Empty State View\nIt's common for results to come from the web, take some time loading, and/or be empty, and/or display an error. `MultiSelectionTable` has got you covered.\nIf you want to display a custom empty view, just set the `stateView` with your view. For example a loading indicator:\n\n```swift\nlet loadingView = UIActivityIndicatorView(\nloadingView.transform = CGAffineTransform.init(scaleX: 2, y: 2)\nloadingView.startAnimating()\nmultiSelectionTableView.stateView = loadingView\n```\n\n### Target Actions\n```swift```\n    ...\nmultiSelectionTableView.addTarget(self, action: #selector(selectedItem(sender:)), for: .itemSelected)\nmultiSelectionTableView.addTarget(self, action: #selector(unselectedItem(sender:)), for: .itemUnselected)\n\n//only called if supportsPagination is set to true\nmultiSelectionTableView.addTarget(self, action: #selector(loadMoreData(sender:)), for: .scrollReachingEnd) \n    ...\n\n@objc private func selectedItem(sender: MultiSelectionTableView) {\n    print(\"selected item\")\n}\n\n@objc private func unselectedItem(sender: MultiSelectionTableView) {\n    print(\"unselected item\")\n}\n    ...\n```\n## Requirements\n\n- iOS 9.0+\n- Xcode 8.0+\n\n## Installation\n\n\u003cdetails\u003e\n\u003csummary\u003eCocoapods\u003c/summary\u003e\n\nMultiSelectionTable is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\nplatform :ios, '9.0'\nuse_frameworks!\n\npod 'MultiSelectionTable', git: 'https://github.com/nunogoncalves/iOS-MultiSelectionTable'\n```\n(Currently **MultiSelectionTable** is still not yet published to Cocoapods, so for now you need to add ```swift git: 'https://github.com/nunogoncalves/iOS-MultiSelectionTable'```.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eManually\u003c/summary\u003e\nCopy the contents of [Source](https://github.com/nunogoncalves/iOS-MultiSelectionTable/tree/master/Source) folder into your project and you're ready to go.\n\u003c/details\u003e\n\n## TODOs\nMissing features and/or bugs can be found in the [Issues](https://github.com/nunogoncalves/iOS-MultiSelectionTable/issues) section.\n\n## Author\n\nNuno Gonçalves\n\n|\u003cimg src=\"https://cdn0.iconfinder.com/data/icons/octicons/1024/mark-github-128.png\" height=\"20px\"\u003e|\u003cimg src=\"https://cdn1.iconfinder.com/data/icons/logotypes/32/twitter-128.png\" height=\"20px\"\u003e\n|:-------------:|:-------------:|\n| nunogoncalves | @goncalvescmnuno |\n\n## Contribute\nFeel free to contribute to **MultiSelectionTable**.\nCheck [Issues](https://github.com/nunogoncalves/iOS-MultiSelectionTable/issues) before asking something or adding some contribuition that's already being done.\n\n## Licence\n\n**iOS-MultiSelectionTable** is available under the MIT license. See the [LICENSE](https://github.com/nunogoncalves/iOS-MultiSelectionTable/blob/master/LICENSE.md) file for more info.\n\n## Final note\nIf you use `MultiSelectionTable` in a production app, let me know. I'll be very flattered and pleased and sure want to be aware of it. :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnunogoncalves%2Fios-multiselectiontable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnunogoncalves%2Fios-multiselectiontable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnunogoncalves%2Fios-multiselectiontable/lists"}