{"id":13338698,"url":"https://github.com/jrsaruo/AceLayout","last_synced_at":"2025-03-11T10:31:48.267Z","repository":{"id":38357659,"uuid":"441525888","full_name":"jrsaruo/AceLayout","owner":"jrsaruo","description":"AceLayout provides a Swifty DSL for Auto Layout.","archived":false,"fork":false,"pushed_at":"2024-12-01T09:49:49.000Z","size":265,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T12:11:36.617Z","etag":null,"topics":["appkit","autolayout","constraints","ios","macos","swift","tvos","type-safety","uikit"],"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/jrsaruo.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":"2021-12-24T17:52:27.000Z","updated_at":"2025-02-21T11:12:21.000Z","dependencies_parsed_at":"2024-12-01T10:35:00.962Z","dependency_job_id":null,"html_url":"https://github.com/jrsaruo/AceLayout","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrsaruo%2FAceLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrsaruo%2FAceLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrsaruo%2FAceLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrsaruo%2FAceLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jrsaruo","download_url":"https://codeload.github.com/jrsaruo/AceLayout/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243015440,"owners_count":20222082,"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":["appkit","autolayout","constraints","ios","macos","swift","tvos","type-safety","uikit"],"created_at":"2024-07-29T19:17:08.576Z","updated_at":"2025-03-11T10:31:45.578Z","avatar_url":"https://github.com/jrsaruo.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AceLayout\n\nAceLayout provides a Swifty DSL for Auto Layout.\n\n[![Test](https://github.com/jrsaruo/AceLayout/actions/workflows/test.yml/badge.svg)](https://github.com/jrsaruo/AceLayout/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/jrsaruo/AceLayout/branch/main/graph/badge.svg?token=NN5TRPRC5O)](https://codecov.io/gh/jrsaruo/AceLayout)\n\n## Requirements\n\n- iOS 11.0+ / macOS 10.13+ / tvOS 11.0+\n- Xcode 14.3+\n- Swift 5.8+\n\n## Features\n\n- **Strongly typed.**\n  - The compiler does not accept wrong constraints such as `some.top == another.leading`.\n- **Simple, modern and unmistakable APIs.**\n- **No need to write boilerplates.**\n  - `view.translatesAutoresizingMaskIntoConstraints = false`\n  - `constraint.isActive = true`\n\n## Usage\n\n### Basic\n\n#### Constraints Building\n\nCall the `autoLayout` method of your `UIView`, `UILayoutGuide`, `NSView` or `NSLayoutGuide` with a closure that describes Auto Layout constraints.\n\n```swift\nview.autoLayout { item in\n    item.top.equal(to: anotherView, plus: 16)          // to UIView\n    item.bottom.equalToSuperview()                     // to superview\n    item.leading.equal(to: layoutMarginsGuide)         // to UILayoutGuide\n    item.trailing.equal(to: anotherView.centerXAnchor) // to NSLayoutAnchor\n    item.width.equal(to: 100)                          // to constant\n    item.height.equal(to: item.width)                  // to LayoutAnchor\n}\n```\n\nIn the example, the followings are done automatically:\n\n- Set `view.translatesAutoresizingMaskIntoConstraints` to `false`.\n\n- Activates all constraints.\n\n#### Relations\n\n```swift\nview.autoLayout { item in\n    item.top.greaterThanOrEqual(to: safeAreaLayoutGuide)\n    item.bottom.lessThanOrEqualToSuperview()\n}\n```\n\n#### Priority\n\n`UILayoutPriority` and `NSLayoutConstraint.Priority` are available.\n\n```swift\nview.autoLayout { item in\n    item.center.equalToSuperview().priority(.required)\n    item.size.equal(toSquare: 100).priority(.defaultHigh)\n}\n```\n\n#### Deactivated Constraints\n\nYou can specify an argument `activates` to determine whether to immediately activate constraints.\n\n```swift\nlet constraints = view.autoLayout(activates: false) { item in\n    item.edges.equal(to: anotherView)\n}\n// All constraints are not active.\nassert(constraints.allSatisfy { !$0.isActive })\n\n// You can activate them at any time.\nNSLayoutConstraint.activate(constraints)\n```\n\n### Convenient Anchors\n\n#### Point\n\n```swift\nview.autoLayout { item in\n    item.center.equal(to: anotherView)\n    item.topLeading.equalToSuperview()\n}\n```\n\n#### Size\n\n```swift\nview.autoLayout { item in\n    item.size.equal(to: CGSize(width: 100, height: 200))\n}\n```\n\n#### HorizontalEdges and VerticalEdges\n\n```swift\nview.autoLayout { item in\n    item.leadingTrailing.equal(to: anotherView)\n    item.topBottom.equalToSuperview(insetBy: 16)\n}\n```\n\n#### Edges\n\n```swift\nview.autoLayout { item in\n    item.edges.equalToSuperview(insetBy: 16)\n}\n```\n\n## Available Anchors\n\n### XAxis\n\n- `leading`\n- `trailing`\n- `left`\n- `right`\n- `centerX`\n\n### YAxis\n\n- `top`\n- `bottom`\n- `centerY`\n\n#### Baseline (only `UIView` / `NSView`)\n\n- `firstBaseline`\n- `lastBaseline`\n\n### Dimension\n\n- `width`\n- `height`\n\n### Point\n\n- `center`\n- `topLeading`\n- `topTrailing`\n- `topLeft`\n- `topRight`\n- `bottomLeading`\n- `bottomTrailing`\n- `bottomLeft`\n- `bottomRight`\n\n### Size\n\n- `size`\n\n### HorizontalEdges\n\n- `leadingTrailing`\n- `leftRight`\n\n### VerticalEdges\n\n- `topBottom`\n\n### Edges\n\n- `edges`\n\n## Using AceLayout in your project\n\nTo use the `AceLayout` library in a SwiftPM project, add the following line to the dependencies in your `Package.swift` file:\n\n```swift\n.package(url: \"https://github.com/jrsaruo/AceLayout\", from: \"1.1.3\"),\n```\n\nand add `AceLayout` as a dependency for your target:\n\n```swift\n.target(name: \"\u003ctarget\u003e\", dependencies: [\n    .product(name: \"AceLayout\", package: \"AceLayout\"),\n    // other dependencies\n]),\n```\n\nFinally, add `import AceLayout` in your source code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjrsaruo%2FAceLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjrsaruo%2FAceLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjrsaruo%2FAceLayout/lists"}