{"id":13461794,"url":"https://github.com/paololeonardi/WaterfallGrid","last_synced_at":"2025-03-24T22:35:04.456Z","repository":{"id":35478649,"uuid":"217918975","full_name":"paololeonardi/WaterfallGrid","owner":"paololeonardi","description":"A waterfall grid layout view for SwiftUI.","archived":false,"fork":false,"pushed_at":"2024-07-26T00:09:26.000Z","size":3585,"stargazers_count":2499,"open_issues_count":12,"forks_count":126,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-03-20T06:08:57.575Z","etag":null,"topics":["ios","macos","swift","swift-package-manager","swiftui","swiftui-grid","tvos","visionos","watchos","waterfall-layout"],"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/paololeonardi.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}},"created_at":"2019-10-27T21:28:16.000Z","updated_at":"2025-03-20T03:38:56.000Z","dependencies_parsed_at":"2024-06-18T20:12:49.841Z","dependency_job_id":"fb5909dd-2684-491a-a723-5ba868f1170c","html_url":"https://github.com/paololeonardi/WaterfallGrid","commit_stats":{"total_commits":25,"total_committers":5,"mean_commits":5.0,"dds":"0.19999999999999996","last_synced_commit":"85eeaa9efda928a218c430a8807256b9a56d4905"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paololeonardi%2FWaterfallGrid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paololeonardi%2FWaterfallGrid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paololeonardi%2FWaterfallGrid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paololeonardi%2FWaterfallGrid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paololeonardi","download_url":"https://codeload.github.com/paololeonardi/WaterfallGrid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245366204,"owners_count":20603438,"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":["ios","macos","swift","swift-package-manager","swiftui","swiftui-grid","tvos","visionos","watchos","waterfall-layout"],"created_at":"2024-07-31T11:00:57.754Z","updated_at":"2025-03-24T22:34:59.436Z","avatar_url":"https://github.com/paololeonardi.png","language":"Swift","funding_links":[],"categories":["Swift","Grid","四、开源库精选（解决80%开发场景，附核心优势）","UI","🌎 by the community"],"sub_categories":["Content","5. 布局增强","Grid"],"readme":"# WaterfallGrid\n\nA waterfall grid layout view for SwiftUI.\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://paololeonardi.github.io/waterfallgrid/resources/demo1.png\" alt=\"Image Demo 1\"/\u003e\n\u003c/p\u003e\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpaololeonardi%2FWaterfallGrid%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/paololeonardi/WaterfallGrid)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpaololeonardi%2FWaterfallGrid%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/paololeonardi/WaterfallGrid)\n\n## Features\n\n- [x] Irregular grid of content.\n- [x] Columns number different per device orientation.\n- [x] Spacing and grid padding customizable.\n- [x] Horizontal or vertical scroll direction.\n- [x] Items update can be animated.\n\n## Usage\n\n### Initialization\n\nYou can create a grid that displays the elements of collection by passing your collection of data and a closure that provides a view for each element in the collection. The grid transforms each element in the collection into a child view by using the supplied closure.\n\nWaterfallGrid works with identifiable data (like SwiftUI.List). You can make your data identifiable in one of two ways: by passing along with your data a key path to a property that uniquely identifies each element, or by making your data type conform to the Identifiable protocol.\n\n**Example 1**\n\nA grid of views of type `Image` from a collection of data identified by a key path.\n\n```swift\nWaterfallGrid((0..\u003c10), id: \\.self) { index in\n  Image(\"image\\(index)\")\n    .resizable()\n    .aspectRatio(contentMode: .fit)\n}\n```\n\n**Example 2**\n\nA grid of views of type `RectangleView` from a collection of `Identifiable` data.\n\n```swift\nWaterfallGrid(rectangles) { rectangle in\n  RectangleView(rectangle: rectangle)\n}\n```\nor, for simple cases like this, just:\n\n```swift\nWaterfallGrid(rectangles, content: RectangleView.init)\n```\n\n### Grid Style \n\nTo customise the appearance of the grid call the `gridStyle` function and pass the parameters you want to customise.\n\n**Columns**\n\n```swift\nWaterfallGrid(cards) { card in\n  CardView(card: card)\n}\n.gridStyle(columns: 2)\n```\n\n```swift\nWaterfallGrid(cards, content: CardView.init)\n.gridStyle(\n  columnsInPortrait: 2,\n  columnsInLandscape: 3\n)\n```\n\n**Spacing and Padding**\n\n```swift\nWaterfallGrid(rectangles, content: RectangleView.init)\n.gridStyle(spacing: 8)\n.padding(EdgeInsets(top: 16, leading: 8, bottom: 16, trailing: 8))\n```\n\n**Animation**\n\n```swift\nWaterfallGrid(rectangles, content: RectangleView.init)\n.gridStyle(animation: .easeInOut(duration: 0.5))\n```\n\n### Scroll Behaviour\n\n**Embed in ScrollView \u0026 Indicators option**\n\n```swift\nScrollView(showsIndicators: true) {\n  WaterfallGrid(rectangles, content: RectangleView.init)\n}\n```\n\n**Horizontal Scroll Direction**\n\n```swift\nScrollView(.horizontal) {\n  WaterfallGrid(rectangles, content: RectangleView.init)\n  .scrollOptions(direction: .horizontal)\n}\n```\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://paololeonardi.github.io/waterfallgrid/resources/animation4.gif\" alt=\"Animation Demo 4\"/\u003e\n\t\u003cimg src=\"https://paololeonardi.github.io/waterfallgrid/resources/animation5.gif\" alt=\"Animation Demo 5\"/\u003e\n\u003c/p\u003e\n\n### A Complete Example\n\n```swift\nScrollView(.horizontal, showsIndicators: false) {\n  WaterfallGrid(cards) { card in\n    CardView(card: card)\n  }\n  .gridStyle(\n    columnsInPortrait: 2,\n    columnsInLandscape: 3,\n    spacing: 8,\n    animation: .easeInOut(duration: 0.5)\n  )\n  .scrollOptions(direction: .horizontal)\n  .padding(EdgeInsets(top: 16, leading: 8, bottom: 16, trailing: 8))\n}\n```\n\n\n## Sample App\nExplore the `WaterfallGridSample` app for some more detailed and interactive examples.\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://paololeonardi.github.io/waterfallgrid/resources/animation1.gif\" alt=\"Animation Demo 1\" width=\"250\"/\u003e\u0026nbsp;\n\t\u003cimg src=\"https://paololeonardi.github.io/waterfallgrid/resources/animation2.gif\" alt=\"Animation Demo 2\" width=\"250\"/\u003e\u0026nbsp;\n\t\u003cimg src=\"https://paololeonardi.github.io/waterfallgrid/resources/animation3.gif\" alt=\"Animation Demo 3\" width=\"250\"/\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://paololeonardi.github.io/waterfallgrid/resources/demo3.png\" alt=\"Image Demo 3\"/\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://paololeonardi.github.io/waterfallgrid/resources/demo2.png\" alt=\"Image Demo 2\"/\u003e\n\u003c/p\u003e\n\n## Installation\n\n### Swift Package Manager\n\n**App dependency**\n\nselect File \u003e Swift Packages \u003e Add Package Dependency and enter the repository URL ([Adding Package Dependencies to Your App](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app))\n\n**Package dependency**\n\nAdd it as a dependency within your `Package.swift` manifest:\n\n```swift\ndependencies: [\n  .package(url: \"https://github.com/paololeonardi/WaterfallGrid.git\", from: \"1.1.0\")\n]\n```\n\n### CocoaPods\n\nYou can install `WaterfallGrid` via CocoaPods by adding the following line to your `Podfile`:\n\n```ruby\npod 'WaterfallGrid', '~\u003e 1.1.0'\n```\n\nRun the `pod install` command to download the library\nand integrate it into your Xcode project.\n\n## Migration Guides\n\n- [WaterfallGrid 1.0.0 Migration Guide](https://github.com/paololeonardi/WaterfallGrid/wiki/WaterfallGrid-1.0.0-Migration-Guide)\n\n## Versioning\n\nFor the versions available, see the [releases on this repository](https://github.com/paololeonardi/WaterfallGrid/releases). \n\n## Contributing\n\nContributions are more than welcome. Please create a GitHub issue before submitting a pull request to plan and discuss implementation.\n\n## Author\n* [Paolo Leonardi](https://github.com/paololeonardi) ([@paololeonardi](https://twitter.com/paololeonardi))\n\n## Credits\nWaterfallGrid was inspired by the following projects:\n\n* QGrid - https://github.com/Q-Mobile/QGrid\n* Grid - https://github.com/SwiftUIExtensions/Grid\n* The SwiftUI Lab - https://swiftui-lab.com\n\n## License\n\nWaterfallGrid is available under the MIT license. See the [LICENSE](LICENSE) file for more info.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaololeonardi%2FWaterfallGrid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaololeonardi%2FWaterfallGrid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaololeonardi%2FWaterfallGrid/lists"}