{"id":13990680,"url":"https://github.com/Antondomashnev/ADMozaicCollectionViewLayout","last_synced_at":"2025-07-22T13:31:13.347Z","repository":{"id":56900222,"uuid":"60381231","full_name":"Antondomashnev/ADMozaicCollectionViewLayout","owner":"Antondomashnev","description":"ADMozaicCollectionViewLayout is yet another UICollectionViewLayout subclass that implements \"brick\", \"mozaic\" or Pinterest style layout.","archived":false,"fork":false,"pushed_at":"2018-10-29T13:22:52.000Z","size":25926,"stargazers_count":224,"open_issues_count":7,"forks_count":35,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-04-24T14:29:16.354Z","etag":null,"topics":["carthage","cocoapods","mozaic","uicollectionview","uicollectionviewlayout","waterfall"],"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/Antondomashnev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.yml","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":"2016-06-03T22:24:42.000Z","updated_at":"2024-01-19T11:24:25.000Z","dependencies_parsed_at":"2022-08-20T18:20:34.873Z","dependency_job_id":null,"html_url":"https://github.com/Antondomashnev/ADMozaicCollectionViewLayout","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Antondomashnev%2FADMozaicCollectionViewLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Antondomashnev%2FADMozaicCollectionViewLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Antondomashnev%2FADMozaicCollectionViewLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Antondomashnev%2FADMozaicCollectionViewLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Antondomashnev","download_url":"https://codeload.github.com/Antondomashnev/ADMozaicCollectionViewLayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227098953,"owners_count":17730681,"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":["carthage","cocoapods","mozaic","uicollectionview","uicollectionviewlayout","waterfall"],"created_at":"2024-08-09T13:03:05.961Z","updated_at":"2024-11-29T10:31:29.673Z","avatar_url":"https://github.com/Antondomashnev.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# ADMozaicCollectionViewLayout\n\n![](https://travis-ci.org/Antondomashnev/ADMozaicCollectionViewLayout.svg?branch=master)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/ADMozaicCollectionViewLayout.svg)](https://img.shields.io/cocoapods/v/ADMozaicCollectionViewLayout.svg)\n[![codebeat badge](https://codebeat.co/badges/17a86057-b1be-497d-886a-c9cfdb17da10)](https://codebeat.co/projects/github-com-antondomashnev-admozaiccollectionviewlayout)\n\n## What is it\n`ADMozaicCollectionViewLayout` is yet another `UICollectionViewLayout` subclass that implements \"brick\" or \"mozaic\"\n layout.\n\n![example](https://api.monosnap.com/rpc/file/download?id=CYs5aVmUdljqghadNwyYd1aVVSBh6d)\n\n## Why do anybody need yet another one?\nBecause there are plenty of kind of the same layouts already:\n* [CHTCollectionViewWaterfallLayout](https://github.com/chiahsien/CHTCollectionViewWaterfallLayout)\n* [FMMosaicLayout](https://github.com/fmitech/FMMosaicLayout)\n* [Greedo Layout](https://github.com/500px/greedo-layout-for-ios)\n\nBut this project is pure `swift` implementation, so if you don't want to mess up `objective-c` code and `swift` you are on the right page. Also, as an advantage compares to another \"mozaic\" layout - you're not limited to predefined sizes of cells.\n\n## Usage\n\nThe idea behind this layout is to split `UICollectionView` bounds into some kind of \"matrix\".\nTo do this `ADMozaikCollectionViewLayout` requires `height` for rows and `width` for columns in specific section.\n```swift\n/// Designated initializer for `ADMozaikLayout`\n///\n/// - Parameter delegate: delegate/datasource for the layout\npublic init(delegate: ADMozaikLayoutDelegate)\n```\n\nIt requires the delegate object conforms to protocol `ADMozaikLayoutDelegate`.\nThe first required method is to return the size of each item in layout:\n```swift\n/// Method should return `ADMozaikLayoutSize` for specific indexPath\n///\n/// - Parameter collectionView: collection view is using layout\n/// - Parameter layout:         layout itself\n/// - Parameter indexPath:      indexPath of item for the size it asks for\n///\n/// - Returns: `ADMozaikLayoutSize` struct object describes the size\nfunc collectionView(_ collectionView: UICollectionView, mozaik layout: ADMozaikLayout, mozaikSizeForItemAt indexPath: IndexPath) -\u003e ADMozaikLayoutSize\n```\n\nWhere `ADMozaikLayoutSize` describes the size of each cell in terms of `ADMozaikCollectionViewLayout`\n```swift\n/**\n *  Defines the size of the layout item\n */\npublic struct ADMozaikLayoutSize {\n  /// Columns number that item requires\n  let columns: Int\n  /// Rows number that item requires\n  let rows: Int\n}\n```\n\nThe second method is to get the geometry information for each specific section of layout:\n```swift\n/// Method should return `ADMozaikLayoutSectionGeometryInfo` to describe specific section's geometry\n///\n/// - Parameters:\n///   - collectionView: collection view is using layout\n///   - layoyt:         layout itself\n///   - section:        section to calculate geometry info for\n///\n/// - Returns: `ADMozaikLayoutSectionGeometryInfo` struct object describes the section's geometry\nfunc collectonView(_ collectionView: UICollectionView, mozaik layoyt: ADMozaikLayout, geometryInfoFor section: ADMozaikLayoutSection) -\u003e ADMozaikLayoutSectionGeometryInfo\n```\n\nWhere `ADMozaikLayoutSectionGeometryInfo` describes the all geometry parameters of the section\n```swift\n/**\n *  Defines the layout's information\n */\npublic struct ADMozaikLayoutSectionGeometryInfo {\n  /// array of `ADMozaikLayoutColumn` for the layout\n  let columns: [ADMozaikLayoutColumn]\n\n  /// height for each row in points\n  let rowHeight: CGFloat\n\n  /// minimum space between items\n  let minimumInteritemSpacing: CGFloat\n\n  /// minimum space between each row\n  let minimumLineSpacing: CGFloat\n\n  /// Insets for the section from top, left, right, bottom\n  let sectionInset: UIEdgeInsets\n\n  /// Height for header in section\n  /// Width is currently limited to the collection view width\n  let headerHeight: CGFloat\n\n  /// Height for footer in section\n  /// Width is currently limited to the collection view width\n  let footerHeight: CGFloat\n}\n```\n\n### Content mode options\n\n```\n/// Method should return `ADMozaikLayoutSectionContentMode` to describe specific section's geometry\n///\n/// - Parameters:\n///   - collectionView: collection view is using layout\n///   - layout:         layout itself\n///   - section:        section to return content mode for\n///\n/// - Returns: `ADMozaikLayoutSectionContentMode` enum describes the section's content mode and how to position cells\nfunc collectonView(_ collectionView: UICollectionView, mozaik layout: ADMozaikLayout, contentModeFor section: ADMozaikLayoutSection) -\u003e ADMozaikLayoutSectionContentMode\n```\n\nThe `contentMode` option controls the way how the Mozaik layout is filled with items:\n1. `fill` - tries to fill vacant spaces with item;\n2. `ordered` - keeps order of the provided items, so empty space can appear in the collection view.\n\nFor the complete example please check the example project. Note that current example project is supposed to be run on iPhone 8 screen's size.\n\n## Install\n\n### CocoaPods\n\nTo integrate ADMozaicCollectionViewLayout into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '8.0'\nuse_frameworks!\n\npod 'ADMozaicCollectionViewLayout', '~\u003e 4.0'\n```\n### Carthage\n\nTo integrate ADMozaicCollectionViewLayout into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ruby\ngithub \"Antondomashnev/ADMozaicCollectionViewLayout\" ~\u003e 4.0\n```\n\nRun `carthage update` to build the framework and drag the built `ADMozaikCollectionViewLayout.framework` into your Xcode project.\n\n## Migration guide\n\n* [From 3.x to 4.x](./Docs/4_Migration_guide.md)\n\n## License\n\nADMozaicCollectionViewLayout is available under the MIT license. See [LICENSE](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAntondomashnev%2FADMozaicCollectionViewLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAntondomashnev%2FADMozaicCollectionViewLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAntondomashnev%2FADMozaicCollectionViewLayout/lists"}