{"id":18465920,"url":"https://github.com/edonv/compositionallayoutbuilder","last_synced_at":"2025-10-08T19:16:12.446Z","repository":{"id":224273894,"uuid":"762876295","full_name":"edonv/CompositionalLayoutBuilder","owner":"edonv","description":"A Result Builder for CollectionView CompositionLayouts!","archived":false,"fork":false,"pushed_at":"2024-06-14T19:18:31.000Z","size":44,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-11T07:31:59.750Z","etag":null,"topics":["collectionview","compositional-layouts","resultbuilder","swift"],"latest_commit_sha":null,"homepage":"https://swiftpackageindex.com/edonv/CompositionalLayoutBuilder//documentation/compositionallayoutbuilder","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/edonv.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"edonv","buy_me_a_coffee":"edonv","thanks_dev":"u/gh/edonv"}},"created_at":"2024-02-24T23:41:16.000Z","updated_at":"2025-01-14T17:50:58.000Z","dependencies_parsed_at":"2024-02-25T00:29:43.705Z","dependency_job_id":"88feb6bd-947b-45dd-9e22-82fcbe0b4960","html_url":"https://github.com/edonv/CompositionalLayoutBuilder","commit_stats":null,"previous_names":["edonv/compositionallayoutbuilder"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/edonv/CompositionalLayoutBuilder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edonv%2FCompositionalLayoutBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edonv%2FCompositionalLayoutBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edonv%2FCompositionalLayoutBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edonv%2FCompositionalLayoutBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edonv","download_url":"https://codeload.github.com/edonv/CompositionalLayoutBuilder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edonv%2FCompositionalLayoutBuilder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000707,"owners_count":26082805,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["collectionview","compositional-layouts","resultbuilder","swift"],"created_at":"2024-11-06T09:14:30.011Z","updated_at":"2025-10-08T19:16:12.427Z","avatar_url":"https://github.com/edonv.png","language":"Swift","funding_links":["https://github.com/sponsors/edonv","https://buymeacoffee.com/edonv","https://thanks.dev/u/gh/edonv"],"categories":[],"sub_categories":[],"readme":"# CompositionalLayoutBuilder\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fedonv%2FCompositionalLayoutBuilder%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/edonv/CompositionalLayoutBuilder)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fedonv%2FCompositionalLayoutBuilder%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/edonv/CompositionalLayoutBuilder)\n\n`CompositionalLayoutBuilder` gives you the ability to \"compose\" a `UICollectionViewCompositionalLayout`/`NSCollectionViewCompositionalLayout` via result builders syntax.\n\nIt can be used in any context you might use a `UICollectionView`/`NSCollectionView`, including another package of mine: [`CollectionView`](https://github.com/edonv/CollectionView) (which will come pre-packaged with initializers that use the layout builders).\n\n## Install\n\nTo add `CompositionalLayoutBuilder` to an Xcode project, go to `File` \u003e `Add Package Dependencies...`, and paste `https://github.com/edonv/CompositionalLayoutBuilder` into the Search field.\n\nTo add it manually to a Swift Package, add the following to the `dependencies` property in the `Package.swift` file:\n\n```swift\n.package(\n    url: \"https://github.com/edonv/CompositionalLayoutBuilder\",\n    upToNextMajor(from: \"0.0.0\")\n)\n```\n\n## Comparison\n\nWith `CompositionalLayoutBuilder`:\n\n```swift\nlet layout: CompositionalLayout = {\n    CompositionalLayout {\n        CompositionalSection {\n            CompositionalGroup(.horizontal, width: .fractionalWidth(1), height: .absolute(200)) {\n                LayoutGroup(.vertical, width: .fractionalWidth(0.75), height: .fractionalHeight(1)) {\n                    LayoutItem(width: .fractionalWidth(1), height: .fractionalHeight(0.5))\n                        .repeating(count: 2)\n                }\n                .interItemSpacing(.fixed(8))\n                \n                CompositionalItem(width: .fractionalWidth(0.25), height: .fractionalHeight(1))\n            }\n            .interItemSpacing(.fixed(16))\n        }\n\n        CompositionalSection {\n            CompositionalGroup(.horizontal, width: .fractionalWidth(1), height: .absolute(100)) {\n                CompositionalItem(width: .fractionalWidth(0.5), height: .fractionalHeight(1))\n            }\n        }\n        .orthogonalScrollingBehavior(.continuous)\n    }\n    .scrollDirection(.vertical)\n}()\n```\n\nWith vanilla `UICollectionViewCompositionalLayout`:\n\n```swift\nlet layout: UICollectionViewCompositionalLayout = {\n    UICollectionViewCompositionalLayout { section, _ in\n        switch section {\n        case 0:\n            let innerItem = NSCollectionLayoutItem(layoutSize: .init(\n                widthDimension: .fractionalWidth(1),\n                heightDimension: .fractionalHeight(0.5)\n            ))\n            \n            let innerGroup = NSCollectionLayoutGroup.vertical(\n                layoutSize: .init(\n                    widthDimension: .fractionalWidth(0.75),\n                    heightDimension: .fractionalHeight(1)\n                ),\n                subitem: innerItem,\n                count: 2\n            )\n            \n            innerGroup.interItemSpacing = .fixed(8)\n            \n            let outerItem = NSCollectionLayoutItem(layoutSize: .init(\n                widthDimension: .fractionalWidth(0.25),\n                heightDimension: .fractionalHeight(1)\n            ))\n            \n            let mainGroup = NSCollectionLayoutGroup.horizontal(\n                layoutSize: .init(\n                    widthDimension: .fractionalWidth(1),\n                    heightDimension: .absolute(200)\n                ),\n                subitems: [innerGroup, outerItem]\n            )\n            \n            return .init(group: mainGroup)\n            \n        case 1:\n            let innerItem = NSCollectionLayoutItem(layoutSize: .init(\n                widthDimension: .fractionalWidth(0.5),\n                heightDimension: .fractionalHeight(1)\n            ))\n            \n            let mainGroup = NSCollectionLayoutGroup.horizontal(\n                layoutSize: .init(\n                    widthDimension: .fractionalWidth(1),\n                    heightDimension: .absolute(100)\n                ),\n                subitems: [innerItem]\n            )\n            \n            let section = NSCollectionLayoutSection(group: mainGroup)\n            section.orthogonalScrollingBehavior = .continuous\n            return section\n            \n        default:\n            return nil\n        }\n    }\n}()\n```\n\n## Documentation\n\nDocumentation can be found [here, hosted on Swift Package Index](https://swiftpackageindex.com/edonv/CompositionalLayoutBuilder//documentation/compositionallayoutbuilder).\n\n## To-Do's\n\n- [x] Add equivalent UIKit code to README for comparison.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedonv%2Fcompositionallayoutbuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedonv%2Fcompositionallayoutbuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedonv%2Fcompositionallayoutbuilder/lists"}