{"id":18403146,"url":"https://github.com/aramsemerjyan/ugrid","last_synced_at":"2025-04-07T07:32:36.369Z","repository":{"id":56933494,"uuid":"266903630","full_name":"AramSemerjyan/ugrid","owner":"AramSemerjyan","description":"Custom grid view based on UICollectionView and Swift","archived":false,"fork":false,"pushed_at":"2020-06-09T21:26:15.000Z","size":6333,"stargazers_count":23,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T14:41:23.391Z","etag":null,"topics":["cocoapods","grid","grid-items","gridlayout","gridview","ios","opensource","swift","ugrid","uicollectionview","xcode"],"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/AramSemerjyan.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-05-25T23:57:35.000Z","updated_at":"2024-06-20T18:55:15.000Z","dependencies_parsed_at":"2022-08-21T00:40:24.163Z","dependency_job_id":null,"html_url":"https://github.com/AramSemerjyan/ugrid","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AramSemerjyan%2Fugrid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AramSemerjyan%2Fugrid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AramSemerjyan%2Fugrid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AramSemerjyan%2Fugrid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AramSemerjyan","download_url":"https://codeload.github.com/AramSemerjyan/ugrid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247612459,"owners_count":20966753,"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":["cocoapods","grid","grid-items","gridlayout","gridview","ios","opensource","swift","ugrid","uicollectionview","xcode"],"created_at":"2024-11-06T02:46:02.477Z","updated_at":"2025-04-07T07:32:31.897Z","avatar_url":"https://github.com/AramSemerjyan.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n\u003cp align=\"center\"\u003e\n   \u003cimg src=\"https://github.com/AramSemerjyan/ugrid/blob/master/Resources/logo.png\" width=300 height=90 /\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://cocoapods.org/pods/ugrid\"\u003e\n        \u003cimg src=\"https://img.shields.io/cocoapods/v/ugrid.svg?style=flat\"\n            alt=\"Version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://cocoapods.org/pods/ugrid\"\u003e\n        \u003cimg src=\"https://img.shields.io/cocoapods/l/ugrid.svg?style=flat\"\n            alt=\"License\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://cocoapods.org/pods/ugrid\"\u003e\n        \u003cimg src=\"https://img.shields.io/cocoapods/p/ugrid.svg?style=flat\"\n            alt=\"Platform\"\u003e\n    \u003c/a\u003e\n   \n   \u003ca href=\"https://swift.org/package-manager/\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/SPM-Compatible-brightgreen.svg?style=flat\"\n           alt=\"SPM compatible\"\u003e\n   \u003c/a\u003e\n\u003c/p\u003e\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Features\nUGrid offers three different sizes for cells. Toggle between them and let UGridFlowLayout to hanlde the rest. All empty spaces will be used. UGridView is willing to be like Windows Phone home page grid view :)\n\n\u003cimg src=\"https://github.com/AramSemerjyan/ugrid/blob/master/Resources/grid_view_3.gif\" width=\"300\" height=\"680\"/\u003e\n\n## Implementation\nJust assign instance of `UGridFlowLayout` to your collection view's `collectionViewLayout` property and you're good to go:\n\n```swift\nimport UIKit\nimport ugrid\n\nclass ViewController: UIViewController {\n \n   private var _layout = UGridFlowLayout()\n   private var _layoutType: LayoutType = .less\n \n   override func viewDidLoad() {\n      super.viewDidLoad()\n\n      collectionView.collectionViewLayout = _layout\n   }\n}\n```\n\n#### Toggle between Layout Types\nThere is two Layout Types: `less` or `more`\n\nWith `less` type in one row there will be:\n* 4 small grid items\n* 2 middle grid items\n* 1 big grid item and there won't be any space for any other grid item\n\nWith `more` type in one row there will be:\n* 6 small grid items\n* 3 middle grid items\n* 1 big grid item, but there will be a space for 4 small grid items or 1 middle item in the smae row\n\nLayout Types could be toggled by calling `setType(_:)` and passing spacific `Layout Type`:\n\n```swift\n...\n   override func viewDidLoad() {\n      ...\n      \n      _layoutType.toggle()\n      \n      _layout.setType(_layoutType)\n      \n      ...\n   }\n...\n```\n\n#### Toggle between sizes\nJust call `toggleSize(forIndexPath:)` On `UGridFlowLayout` instance. Layout will automaticall toggle between small, middle and big sizes:\n\n```swift\n...\n    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {\n        _layout.toggleSize(forIndexPath: indexPath)\n    }\n...\n```\n\nIf there isn't any size info in the store for the item yet by default `small` size will be used. You can change default size by calling `setDefaultGridSize(_ size: SizeType)` on `UGridFlowLayout` instance:\n\n```swift\n...\n   override func viewDidLoad() {\n      ...\n      \n      _layout.setDefaultGridSize(.middle)\n      \n      ...\n   }\n...\n```\n\nAfter this every new added item will have `middle` size instead of default `small`.\n\n#### Store changes\nFor simplicity `UserDefaults` is used to save size for each cell index path. If you still want to handle storing yourself You want to check [Change behaviour section](#change-behaviour)\n\nIf you want to clear all saved item sizes call `resetItemsSizes()` on `UGridFlowLayout` instance:\n\n```swift\n...\n   override func viewDidLoad() {\n      ...\n      \n      _layout.resetItemsSizes()\n      \n      ...\n   }\n...\n```\n\n#### Change behaviour\nUGrid is still in development. It do it's best to bring the fastest calculation time for reordering cells, simplest implementation and usability. Though if you have a better calculation idea (which is most likely) you can create your own calculation class by simply adopting to `IGridCalculation` protocol and use `setCalculationLogic(_:)` on `UGridFlowLayout` instance to change calculation logic.\nAlso if you like to store sizes on your own, you can adopt to `IGridSizeRepository` protocol and set new storing mechanism by calling `setSizeRepository(_:)` on on `UGridFlowLayout` instance.\n\nTo change grid items count in one row, simply create a class that comforms to `IGridItemsInRow` and set it to `UGridFlowLayout` instance. For exmaple, to have 3 items in one row for `less` mode instead of default 4, create a new class called `CustomSizeCountInrow`:\n\n```swift\nclass CustomSizeCountInrow: IGridItemsInRow {\n    func itemsInRow(forSizeType size: SizeType, andLayoutType layout: LayoutType) -\u003e CGFloat {\n\n        switch layout {\n        case .less:\n            switch size {\n            case .small:\n                return 3\n            case .middle:\n                return 1.5\n            case .big:\n                return 1\n            }\n        case .more:\n            switch size {\n            case .small:\n                return 6\n            case .middle:\n                return 3\n            case .big:\n                return 1\n            }\n        }\n    }\n}\n```\n\nand set it:\n\n```swift\n...\n   override func viewDidLoad() {\n      ...\n            \n      _layout.setGridItemsInRow(CustomSizeCountInrow())\n      \n      ...\n   }\n...\n```\n\n## What is planned to be done\n* Section support. Currently only one section is supported\n* Drag and Drop support\n\n## Requirements\n* XCode 11+\n* iOS 11+\n\n## Installation\n\nugrid is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'ugrid'\n```\n\n## Author\n\nBug Creator\n\n## License\n\nugrid is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faramsemerjyan%2Fugrid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faramsemerjyan%2Fugrid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faramsemerjyan%2Fugrid/lists"}