{"id":20337581,"url":"https://github.com/k-o-d-e-n/layoutui","last_synced_at":"2025-07-24T17:15:20.685Z","repository":{"id":37510802,"uuid":"500418286","full_name":"k-o-d-e-n/LayoutUI","owner":"k-o-d-e-n","description":"Constraint-based autolayout system written on Swift. Not Autolayout wrapper. Reimplemenation of CGLayout.","archived":false,"fork":false,"pushed_at":"2022-07-08T14:12:26.000Z","size":200,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T08:45:59.476Z","etag":null,"topics":["autolayout","calayer","constraints","layout","layout-engine","linux","macos","nsview","swift","swiftui","tvos","uikit","zero-dependencies"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/k-o-d-e-n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-06T12:09:00.000Z","updated_at":"2025-01-03T19:47:38.000Z","dependencies_parsed_at":"2022-08-19T05:21:29.667Z","dependency_job_id":null,"html_url":"https://github.com/k-o-d-e-n/LayoutUI","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-o-d-e-n%2FLayoutUI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-o-d-e-n%2FLayoutUI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-o-d-e-n%2FLayoutUI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-o-d-e-n%2FLayoutUI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k-o-d-e-n","download_url":"https://codeload.github.com/k-o-d-e-n/LayoutUI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248493022,"owners_count":21113159,"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":["autolayout","calayer","constraints","layout","layout-engine","linux","macos","nsview","swift","swiftui","tvos","uikit","zero-dependencies"],"created_at":"2024-11-14T21:09:31.271Z","updated_at":"2025-04-11T22:42:17.200Z","avatar_url":"https://github.com/k-o-d-e-n.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LayoutUI\n\nReimplemenation of [CGLayout](https://github.com/k-o-d-e-n/CGLayout) in SwiftUI-like style. More powerful than before.\n\n```swift\nvar scheme: some Layout {\n    Rect(subview0, id: 0) {\n        if isLandscape {\n            Height().scaled(0.5)\n            Width().inset(100)\n            Top()\n            CenterX()\n        } else {\n            Width().inset(60)\n            Height().scaled(0.3)\n        }\n    }\n    if isLandscape {\n        Rect(subview1, id: 1) {\n            Height().scaled(0.2)\n            Width().inset(50)\n            Top()\n            CenterX()\n        }.constraints(subview0, viewID: 0) {\n            MaxY.Pull.MinY()\n            if isRTL { MidX.Limit.MinX() } else { MidX.Limit.MaxX() }\n        }\n    } else {\n        Rect(subview1, id: 1) {\n            Height().scaled(0.2)\n            Width().inset(50)\n            Top()\n            CenterX()\n        }.constraints(subview0, viewID: 0) {\n            MaxY.After.Limit()\n        }\n    }\n    FittingRect(label0, cache: sizeCache, id: 2) {\n        Width.Current().inset(-10)\n        CenterY()\n        CenterX()\n    }.constraints(subview0, viewID: 0)\n}\n\n/// ...\nscheme.layout(in: view.bounds)\n```\n\n### Universal layout\n\n```swift\nvar scheme: AnyViewLayout\u003cTableViewCell\u003e {\n    /// ...\n    FittingRect(\\TableViewCell.label0, id: 2) {\n        Width.Current().inset(-10)\n        CenterY()\n        CenterX()\n    }.constraints(\\.subview0.frame, viewID: 0)\n    /// ...\n}\n\n/// ...\nlet cell = TableViewCell()\nscheme.layout(cell, in: cell.contentView.bounds)\n```\n\n### SwiftUI\n\n```swift\nstruct ContentView: View {\n    var body: some View {\n        if #available(iOS 16, *) {\n            Text(\"Hello World\").layout { labelLayout }\n            Text(\"Hello World\").fittingLayout {\n                Bottom()\n                Right().offset(-10)\n            }\n        } else {\n            Text(\"Hello World\").basicLayout { labelLayout }\n        }\n        if #available(iOS 16, *) {\n            (ConstraintBasedLayout()) {\n                Text(\"Text #1+\").constrainedLayout { Left().offset(20) }\n                Text(\"Text #2/\").constrainedLayout {\n                    Constraint(0) { MaxY.Align.MinY().offset(20) }\n                }\n                Text(\"Text #3\\\\\").zIndex(50).constrainedLayout {\n                    Constraint(1) {\n                        MaxY.Align.MinY()\n                        MaxX.Align.MinX().offset(10)\n                    }\n                }\n                Color.red.border(Color.yellow, width: 2).constrainedLayout {\n                    Constraint(2) { Equal() }\n                }\n                Color.brown.constrainedLayout {\n                    Constraint(1) { MaxY.Limit.MinY() }\n                    Constraint(2) { MinX.Limit.MaxX() }\n                }\n            }\n        }\n    }\n    @LayoutBuilder var labelLayout: some RectBasedLayout {\n        Width.Constant(200)\n        CenterX()\n        CenterY()\n    }\n}\n```\n\n## Performance\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"Resources/benchmark_chart.png\"\u003e\n    Performed by \u003ca href=\"https://github.com/lucdion/LayoutFrameworkBenchmark\"\u003eLayoutBenchmarkFramework\u003c/a\u003e\n\u003c/p\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-o-d-e-n%2Flayoutui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk-o-d-e-n%2Flayoutui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-o-d-e-n%2Flayoutui/lists"}