{"id":18428703,"url":"https://github.com/sncf-connect-tech/vscollectionviewcellinsetflowlayout","last_synced_at":"2025-04-07T17:32:07.962Z","repository":{"id":56925780,"uuid":"87829998","full_name":"sncf-connect-tech/VSCollectionViewCellInsetFlowLayout","owner":"sncf-connect-tech","description":"Apply margins to UICollectionViewCells","archived":false,"fork":false,"pushed_at":"2017-08-04T09:24:18.000Z","size":223,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-09-20T02:02:09.703Z","etag":null,"topics":["inset","margin","swift","uicollectionview","uicollectionviewcell","uicollectionviewflowlayout"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/sncf-connect-tech.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":"2017-04-10T15:55:13.000Z","updated_at":"2024-07-19T12:54:16.000Z","dependencies_parsed_at":"2022-08-21T05:21:00.720Z","dependency_job_id":null,"html_url":"https://github.com/sncf-connect-tech/VSCollectionViewCellInsetFlowLayout","commit_stats":null,"previous_names":["voyages-sncf-technologies/vscollectionviewcellinsetflowlayout"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sncf-connect-tech%2FVSCollectionViewCellInsetFlowLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sncf-connect-tech%2FVSCollectionViewCellInsetFlowLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sncf-connect-tech%2FVSCollectionViewCellInsetFlowLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sncf-connect-tech%2FVSCollectionViewCellInsetFlowLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sncf-connect-tech","download_url":"https://codeload.github.com/sncf-connect-tech/VSCollectionViewCellInsetFlowLayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247697802,"owners_count":20981252,"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":["inset","margin","swift","uicollectionview","uicollectionviewcell","uicollectionviewflowlayout"],"created_at":"2024-11-06T05:14:25.393Z","updated_at":"2025-04-07T17:32:07.682Z","avatar_url":"https://github.com/sncf-connect-tech.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VSCollectionViewCellInsetFlowLayout\n\nVSCollectionViewCellInsetFlowLayout, based on UICollectionViewFlowLayout, enables to add margins on cells\n\n\u003cp align=\"center\" \u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/voyages-sncf-technologies/VSCollectionViewCellInsetFlowLayout/master/assets/screenshot.png\" alt=\"VSCollectionViewCellInsetFlowLayout\" title=\"VSCollectionViewCellInsetFlowLayout\"\u003e\n\u003c/p\u003e\n\n## Get Started\n\nBased on the same principle of ```collectionView(_:layout:insetForSectionAt:)```, VSCollectionViewCellInsetFlowLayout provides a delegate method to define margins on ```UICollectionViewCell```\n\n### Setup\n\nInstanciate a VSCollectionViewCellInsetFlowLayout then set it as the layout of the collectionView:\n```swift\ncollectionView.collectionViewLayout = VSCollectionViewCellInsetFlowLayout()\n```\n\nVSCollectionViewCellInsetFlowLayout is using the collectionview delegate if this one conforms to ```VSCollectionViewDelegateCellInsetFlowLayout```.\nImplement ```collectionView(_:layout:insetForItemAt:)```:\n```swift\nextension ViewController : VSCollectionViewDelegateCellInsetFlowLayout {\n    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForItemAt indexPath: IndexPath) -\u003e UIEdgeInsets {\n        if indexPath.item == 0 {\n            return UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0)\n        }\n        return UIEdgeInsets.zero\n    }\n}\n```\n\nEt voilà !\n\n## Notes\n\nIf flowLayout scrollDirection is **vertical**:\n  - **inset.top** offsets the item vertically, **inset.bottom** offsets the next item vertically or offsets contentSize if no more cell. All next items and contentSize are also offset vertically by the specified margins.\n  - **inset.left** offset the item horizontally and subtracts the value from the cell width, **inset.right** updates the width of the cell without offsets its origin. Others cells and contentSize are **not** impacted by the specified margins.\n\nIf flowLayout scrollDirection is **horizontal**:\n  - **inset.left** offsets the item horizontally, **inset.right** offsets the next item horizontally or offsets contentSize if no more cell. All next items and contentSize are also offset horizontally by the specified margins.\n  - **inset.top** offset the item vertically and subtracts the value from the cell height, **inset.bottom** updates the height of the item without offsets its origin. Others items and contentSize are **not** impacted by the specified margins.\n\n## Installation\n\n### Installation with CocoaPods\n\nCopy and paste the following lines to your PodFile file:  \n    \n    source 'https://github.com/CocoaPods/Specs.git'\n    pod 'VSCollectionViewCellInsetFlowLayout'\n\n### Manual installation\n\n- [Download](https://github.com/voyages-sncf-technologies/VSCollectionViewCellInsetFlowLayout/releases) the last release of VSCollectionViewCellInsetFlowLayout.\n- Import the folder *VSCollectionViewCellInsetFlowLayout* into your project.\n\n### Sample\n\nYou may download the project to have a look at the integrated sample.\n\n\n## Credits\n\nVSCollectionViewCellInsetFlowLayout is owned and maintained by [Voyages-sncf.com](http://www.voyages-sncf.com/).\n\nVSCollectionViewCellInsetFlowLayout was originally created by [Gwenn Guihal](https://github.com/myrddinus).\n\n\n## License\n\nVSCollectionViewCellInsetFlowLayout is released under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsncf-connect-tech%2Fvscollectionviewcellinsetflowlayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsncf-connect-tech%2Fvscollectionviewcellinsetflowlayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsncf-connect-tech%2Fvscollectionviewcellinsetflowlayout/lists"}