{"id":19773923,"url":"https://github.com/badoo/bmacollectionviewlayouts","last_synced_at":"2025-04-30T18:32:28.053Z","repository":{"id":28270491,"uuid":"31780867","full_name":"badoo/BMACollectionViewLayouts","owner":"badoo","description":"A set of UICollectionView layouts","archived":false,"fork":false,"pushed_at":"2018-04-30T14:45:18.000Z","size":88,"stargazers_count":20,"open_issues_count":1,"forks_count":6,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-04-20T06:35:06.076Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","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/badoo.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}},"created_at":"2015-03-06T17:35:50.000Z","updated_at":"2020-06-19T22:38:00.000Z","dependencies_parsed_at":"2022-08-27T15:23:12.413Z","dependency_job_id":null,"html_url":"https://github.com/badoo/BMACollectionViewLayouts","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badoo%2FBMACollectionViewLayouts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badoo%2FBMACollectionViewLayouts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badoo%2FBMACollectionViewLayouts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badoo%2FBMACollectionViewLayouts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/badoo","download_url":"https://codeload.github.com/badoo/BMACollectionViewLayouts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251761256,"owners_count":21639578,"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":[],"created_at":"2024-11-12T05:11:32.280Z","updated_at":"2025-04-30T18:32:27.743Z","avatar_url":"https://github.com/badoo.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/badoo/BMACollectionViewLayouts.svg?branch=master)](https://travis-ci.org/badoo/BMACollectionViewLayouts)\n\n# BMACollectionViewLayouts\n\nA set of UICollectionView subclasses for all your layouting needs.\n\n##Installing\nYou can use cocoapods, importing BMACollectionViewLayouts:\n```ruby\npod 'BMACollectionViewLayouts'\n```\n\nYou can also import this repository as a submodule and use the classes under 'Source' subdirectory.\n\n##The Layouts\nThere is only one layout at the moment, but more are coming :rocket:\n\n##BMAReorderableFlowLayout\nThis is a flow layout subclass, and allows user to drag and drop the elements inside the collection view.\n\nThe layout gives callbacks for all events in time during this interaction, and lets you control if the whole reordering is available for a single or all cells.\n\n```objectivec\n/// Return YES if the item can be dragged. Default assumed NO.\n- (BOOL)collectionView:(UICollectionView *)collectionView canDragItemAtIndexPath:(NSIndexPath *)indexPath;\n\n/// Return YES if the item can be moved from the position to the position. Default assumed NO.\n- (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemFromIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)toIndexPath;\n\n/// Reported if item can be moved, after animation happened\n- (void)collectionView:(UICollectionView *)collectionView didMoveItemFromIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)toIndexPath;\n\n/// Notifies that a cell has been selected and will begin dragging it\n- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout willBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath;\n\n/// Notifies that a cell has been selected and did begin dragging it. Called after animations before dragging\n- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout didBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath;\n\n/// Notifies that a cell previously being dragged will end dragging\n- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout willEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath;\n\n/// Notifies that a cell previously dragged has been dropped to it's destination. Called after all animations.\n- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout didEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath;\n\n```\n\nA useful feature is the ability to hook in the animation of the actual cell being dragged. It is generally necessary to indicate visually that the collection view is letting the user to drag the cell, but the design should be up to you. So there are two callbacks you can implement for that effect:\n\n```objectivec\n/// Gives possibility to customise the animation of the cell when it's selected for dragging\n- (BMAReorderingAnimationBlock)animationForDragBeganInCollectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout;\n\n/// Gives possibility to customise the animation of the cell when it's dropped after dragging\n- (BMAReorderingAnimationBlock)animationForDragEndedInCollectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout;\n\n```\n\nAn example of a simple pop-out animation:\n```objectivec\n- (BMAReorderingAnimationBlock)animationForDragBeganInCollectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout {\n    return ^(UICollectionViewCell *draggedView){\n        draggedView.transform = CGAffineTransformMakeScale(1.3, 1.3);\n    };\n}\n\n- (BMAReorderingAnimationBlock)animationForDragEndedInCollectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout {\n    return ^(UICollectionViewCell *draggedView){\n        draggedView.transform = CGAffineTransformIdentity;\n    };\n}\n```\n\nAnd how it looks like:\n\n![image](demoimages/popinreorder.gif)\n\n###Important\n\nThe layout needs to copy the cell in order to create a view it can move around. It does this instead of creating the snapshot, as you may want to reconfigure your cell for dragging before it actually moves. So you need to implement NSCopying in your cell and return a valid copy.\n\n##Blog\nRead more on our [tech blog](http://techblog.badoo.com/) or explore our other [open source projects](https://github.com/badoo)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadoo%2Fbmacollectionviewlayouts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadoo%2Fbmacollectionviewlayouts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadoo%2Fbmacollectionviewlayouts/lists"}