{"id":16853253,"url":"https://github.com/devxoul/ascollectionflexlayout","last_synced_at":"2025-04-11T07:11:41.638Z","repository":{"id":56901033,"uuid":"302727525","full_name":"devxoul/ASCollectionFlexLayout","owner":"devxoul","description":"A custom collection layout that allows to use Texture layout specs in ASCollectionNode.","archived":false,"fork":false,"pushed_at":"2020-10-13T15:42:56.000Z","size":22,"stargazers_count":27,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-17T01:02:30.568Z","etag":null,"topics":["ascollectionnode","asyncdisplaykit","flexbox","texture","uicollectionviewlayout"],"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/devxoul.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":"2020-10-09T18:50:16.000Z","updated_at":"2023-12-26T06:58:56.000Z","dependencies_parsed_at":"2022-08-20T18:50:32.269Z","dependency_job_id":null,"html_url":"https://github.com/devxoul/ASCollectionFlexLayout","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FASCollectionFlexLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FASCollectionFlexLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FASCollectionFlexLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FASCollectionFlexLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devxoul","download_url":"https://codeload.github.com/devxoul/ASCollectionFlexLayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239576555,"owners_count":19662109,"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":["ascollectionnode","asyncdisplaykit","flexbox","texture","uicollectionviewlayout"],"created_at":"2024-10-13T13:50:39.890Z","updated_at":"2025-02-19T00:31:25.649Z","avatar_url":"https://github.com/devxoul.png","language":"Swift","readme":"# ASCollectionFlexLayout\n\nASCollectionFlexLayout is a custom collection layout that allows to use Texture layout specs in ASCollectionNode.\n\n![screenshot](https://user-images.githubusercontent.com/931655/95620861-c3776800-0aab-11eb-81cd-7dd67a71ce4d.png)\n\n## Usage\n\n### Creating a layout\n\n```swift\nlet layout = ASCollectionFlexLayout()\nlayout.layoutProvider = self\n\nlet collectionNode = ASCollectionNode(collectionViewLayout: layout)\n```\n\nIf you don't specify the `layoutProvider`, it will use a `ASStackLayout` as default.\n\n### Implementing ASCollectionFlexLayoutProvider protocol\n\nThere are two kind of layout specs in ASCollectionFlexLayout:\n\n1. A layout for sections\n2. A Layout for items in a section\n\nYou can optionally provide each layout specs by implementing `ASCollectionFlexLayoutProvider` protocol.\n\n```swift\nprotocol ASCollectionFlexLayoutProvider {\n  /// A layout spec for sections. The default layout spec is a stretched stack layout with no spacing.\n  func flexLayout(_ layout: ASCollectionFlexLayout, layoutSpecThatFits constrainedSize: ASSizeRange, sectionElements: [ASLayoutElement]) -\u003e ASLayoutSpec?\n\n  /// A layout spec for items in a section. The default layout spec is a flex-wrapping stack with no spacing.\n  func flexLayout(_ layout: ASCollectionFlexLayout, layoutSpecThatFits constrainedSize: ASSizeRange, forSectionAt section: Int, itemElements: [ASLayoutElement]) -\u003e ASLayoutSpec?\n}\n```\n\nFor example:\n\n```swift\nextension MyViewController: ASCollectionFlexLayoutProvider {\n  func flexLayout(_ layout: ASCollectionFlexLayout, layoutSpecThatFits constrainedSize: ASSizeRange, sectionElements: [ASLayoutElement]) -\u003e ASLayoutSpec? {\n    return ASStackLayoutSpec(\n      direction: .vertical,\n      spacing: 20,\n      justifyContent: .start,\n      alignItems: .start,\n      children: sectionElements\n    )\n  }\n\n  func flexLayout(_ layout: ASCollectionFlexLayout, layoutSpecThatFits constrainedSize: ASSizeRange, forSectionAt section: Int, itemElements: [ASLayoutElement]) -\u003e ASLayoutSpec? {\n    return ASStackLayoutSpec(\n      direction: .horizontal,\n      spacing: 10,\n      justifyContent: .start,\n      alignItems: .start,\n      flexWrap: .wrap,\n      alignContent: .start,\n      lineSpacing: 10,\n      children: itemElements\n    )\n  }\n}\n```\n\n### Using the default layout\n\nYou can modify the default layout to apply layout without implementing `ASCollectionFlexLayoutProvider` protocol.\n\n```swift\nlet layout = ASCollectionFlexLayout()\nlayout.defaultSectionLayout.alignItems = .center\nlayout.defaultItemLayout.direction = .vertical\nlayout.defaultItemLayout.alignItems = .stretch\n```\n\nAlso you can directly refer to the default layout in the `ASCollectionFlexLayoutProvider` protocol implementation.\n\n```swift\nfunc flexLayout(_ layout: ASCollectionFlexLayout, layoutSpecThatFits constrainedSize: ASSizeRange, forSectionAt section: Int, itemElements: [ASLayoutElement]) -\u003e ASLayoutSpec? {\n  let insets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 20)\n  return ASInsetLayoutSpec(insets: insets, child: layout.defaultItemLayout)\n}\n```\n\n## License\n\nASCollectionFlexLayout is under MIT license. See the [LICENSE](LICENSE) for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevxoul%2Fascollectionflexlayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevxoul%2Fascollectionflexlayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevxoul%2Fascollectionflexlayout/lists"}