{"id":13685990,"url":"https://github.com/mmick66/KDRearrangeableCollectionViewFlowLayout","last_synced_at":"2025-05-01T05:31:24.949Z","repository":{"id":79029068,"uuid":"41438898","full_name":"mmick66/KDRearrangeableCollectionViewFlowLayout","owner":"mmick66","description":"A Drag and Rearrange UICollectionView through its layout","archived":false,"fork":false,"pushed_at":"2018-10-19T07:14:39.000Z","size":68,"stargazers_count":75,"open_issues_count":0,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-09T23:37:51.156Z","etag":null,"topics":["drag","drag-and-drop","drop","rearrengment","storyboard","swift","swift-3","uicollectionview"],"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/mmick66.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2015-08-26T17:15:20.000Z","updated_at":"2023-06-27T13:17:22.000Z","dependencies_parsed_at":"2023-03-30T12:34:02.843Z","dependency_job_id":null,"html_url":"https://github.com/mmick66/KDRearrangeableCollectionViewFlowLayout","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/mmick66%2FKDRearrangeableCollectionViewFlowLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmick66%2FKDRearrangeableCollectionViewFlowLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmick66%2FKDRearrangeableCollectionViewFlowLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmick66%2FKDRearrangeableCollectionViewFlowLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmick66","download_url":"https://codeload.github.com/mmick66/KDRearrangeableCollectionViewFlowLayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251830449,"owners_count":21650802,"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":["drag","drag-and-drop","drop","rearrengment","storyboard","swift","swift-3","uicollectionview"],"created_at":"2024-08-02T14:01:00.581Z","updated_at":"2025-05-01T05:31:24.648Z","avatar_url":"https://github.com/mmick66.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"## KDRearrangeableCollectionViewFlowLayout ##\r\n\r\nThis is a simple implementation of a drag and rearrange collection view through its layout. It works for UICollectionViews with multiple sections.\r\n\r\nVideo Demo: [Here](https://v.usetapes.com/U5UrT2ePsO)\r\n\r\nTip: For drag and drop **between** multiple collection views look at the project [here](https://github.com/mmick66/KDDragAndDropCollectionView).\r\n\r\n### Quick Guide ###\r\n\r\n1. Add the *KDRearrangeableCollectionViewFlowLayout.swift* file to your project (it is the only file you need).\r\n2. Set the layout of your UICollectionView to be the one in the file above. This can be done either programmatically or through the Storyboard.\r\n\r\n3. Make the data source of your UICollectionView to be *KDRearrangeableCollectionViewDelegate* subclass and implement the one mandatory method there.\r\n\r\n```Swift\r\nfunc moveDataItem(fromIndexPath : NSIndexPath, toIndexPath: NSIndexPath) -\u003e Void\r\n```\r\n\r\nAn example implementation for a multisectioned UICollectionView is here:\r\n\r\n```Swift\r\nfunc moveDataItem(fromIndexPath : NSIndexPath, toIndexPath: NSIndexPath) -\u003e Void {\r\n    let name = self.data[fromIndexPath.section][fromIndexPath.item]\r\n    self.data[fromIndexPath.section].removeAtIndex(fromIndexPath.item)\r\n    self.data[toIndexPath.section].insert(name, atIndex: toIndexPath.item)\r\n}\r\n```\r\n\r\n#### You can stop the dragging behaviour by setting the property\r\n\r\n```Swift\r\nself.collectionViewRearrangeableLayout.draggable = true\r\n```\r\n\r\n#### You can constraint the axist of the drag through an enum\r\n\r\n```Swift\r\nself.collectionViewRearrangeableLayout.axis = .Free\r\nself.collectionViewRearrangeableLayout.axis = .X\r\nself.collectionViewRearrangeableLayout.axis = .Y\r\n```\r\n\r\n#### You can prevent the of any cell by implementing:\r\n\r\n```Swift\r\nfunc canMoveItem(at indexPath : IndexPath) -\u003e Bool\r\n```\r\n\r\n### KDRearrangeableCollectionViewCell\r\n\r\nAnother class that comes with this package is KDRearrangeableCollectionViewCell. It is a subclass of UICollectionViewCell and it implements a boolean property called 'dragging'. If you choose to make the cells of your collection view a subclass of KDRearrangeableCollectionViewCell this property will be set upon the start and end of the dragging and by overriding it you can set the style of the snapshot image that will be dragged around.\r\n\r\nThis method will be called before the visual swap happens.\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmick66%2FKDRearrangeableCollectionViewFlowLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmick66%2FKDRearrangeableCollectionViewFlowLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmick66%2FKDRearrangeableCollectionViewFlowLayout/lists"}