{"id":19773975,"url":"https://github.com/bibinjacobpulickal/autolayoutproxy","last_synced_at":"2025-04-30T18:32:40.911Z","repository":{"id":49202823,"uuid":"157310004","full_name":"bibinjacobpulickal/AutoLayoutProxy","owner":"bibinjacobpulickal","description":"A simple and lightweight Auto-Layout-Kit that makes you feel like playing a fun game laying out views. AutoLayout supports UIKit on iOS \u0026 tvOS and AppKit on macOS so you wouldn't have to worry about using different solutions on different platforms. AutoLayoutProxy is compiled on Xcode 14.2 using Swift 5.7 and will be updated for all future releases","archived":false,"fork":false,"pushed_at":"2024-02-15T12:38:19.000Z","size":229,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-16T18:17:45.373Z","etag":null,"topics":["autolayout","autolayout-constraints","cocoapods","constraints","ios","snapkit","spm","subview","swift","swift-package-manager","uikit","xcode"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bibinjacobpulickal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2018-11-13T02:44:43.000Z","updated_at":"2024-02-15T12:36:19.000Z","dependencies_parsed_at":"2024-11-12T06:15:14.605Z","dependency_job_id":"a6a7986c-76b8-47cc-883e-e9651229d884","html_url":"https://github.com/bibinjacobpulickal/AutoLayoutProxy","commit_stats":{"total_commits":185,"total_committers":4,"mean_commits":46.25,"dds":"0.021621621621621623","last_synced_commit":"300fa55f9131279a3352c89515f88bb7099c2f90"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibinjacobpulickal%2FAutoLayoutProxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibinjacobpulickal%2FAutoLayoutProxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibinjacobpulickal%2FAutoLayoutProxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibinjacobpulickal%2FAutoLayoutProxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bibinjacobpulickal","download_url":"https://codeload.github.com/bibinjacobpulickal/AutoLayoutProxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251761364,"owners_count":21639598,"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","autolayout-constraints","cocoapods","constraints","ios","snapkit","spm","subview","swift","swift-package-manager","uikit","xcode"],"created_at":"2024-11-12T05:11:39.974Z","updated_at":"2025-04-30T18:32:40.633Z","avatar_url":"https://github.com/bibinjacobpulickal.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AutoLayoutProxy\n\nA simple and lightweight Auto-Layout Kit that makes you feels laying out views as a fun game. AutoLayoutProxy supports UIKit on iOS \u0026 tvOS and AppKit on MacOS so you wouldn't have to worry about using different solutions on different platforms. AutoLayoutProxy is compiled on Xcode 12.0 using Swift 5.7 and will be updated for all future releases.\n\n[![Platform](http://img.shields.io/badge/platform-iOS-blue.svg?style=flat)](https://developer.apple.com/iphone/index.action)\n[![Platform](https://img.shields.io/badge/platform-macOS-purple.svg?style=flat)](https://developer.apple.com/iphone/index.action)\n[![Language](http://img.shields.io/badge/language-swift-brightgreen.svg?style=flat)](https://developer.apple.com/swift)\n![Swift version](https://img.shields.io/badge/swift-5.7-orange.svg)\n[![Swift](https://github.com/bibinjacobpulickal/AutoLayoutProxy/actions/workflows/swift.yml/badge.svg)](https://github.com/bibinjacobpulickal/AutoLayoutProxy/actions/workflows/swift.yml)\n[![License](http://img.shields.io/badge/license-MIT-lightgray.svg?style=flat)](https://github.com/bibinjacobpulickal/AutoLayoutProxy/blob/master/LICENSE)\n\n## Why use AutoLayoutProxy?\n\nHave you ever had to write lines and lines of code to add subviews and anchor them like the following:\n```swift\nview.addSubview(subview)\nsubview.translatesAutoresizingMaskIntoConstraints = false\n\nsubview.topAnchor.constraint(equalTo: view.bottomAnchor).isActive = true\n...\nsubview.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true\n```\n\n## AutoLayoutProxy v4 introduces declarative UI Layout syntax\n```swift\nview.addSubview(subview) {\n    subview.top.equalTo(view.top).constant(16)\n    $0.leading.lessThanOrEqualTo($1.leading).constant(16)\n    $0.height.equalTo(100)\n    $0.width.greaterThanOrEqualTo($1.width).multiplier(0.8).constant(-12)\n}\n```\n\nWorry no more AutoLayoutProxy helps you with this situation as follows:\n```swift\nview.addSubview(subview) {\n    subview.top      == view.bottom\n    ...\n    subview.trailing == view.trailing\n}\n// Or in short 🙂\nview.addSubview(subview) { $0.sides == $1.sides }\n\n// Or even shorter 😎\nview.addSubview(subview) { $0 === $1 } \n```\n\nYou see thats all thats required. Now, you might be wondering what would you do if you had to make a constraint with a relation that's not equal but, less than or greater than, like the following:\n```swift\nsubview.leadingAnchor.constraint(lessThanOrEqualTo: view.leadingAnchor, constant: -8).isActive = true\nsubview.trailingAnchor.constraint(greaterThanOrEqualTo: view.trailingAnchor: constant: 16).isActive = true\n```\n\nAutoLayoutProxy let's you do this:\n```swift\nsubview.leading  \u003c= view.leading\nsubview.trailing \u003e= view.trailing\n```\n\nIn the case of constants you can add or substract them in the same expresion, so instead of this:\n```swift\nsubview.topAnchor.constraint(equalTo: view.bottomAnchor, constant: 16).isActive = true\nsubview.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: -32).isActive = true\n```\n\nYou only need this:\nsubview.top     == view.bottom + 16\nsubview.leading == view.trailing - 32\nIf you would like to get the constraint for animations or reference in future, just do:\n```swift\nlet subviewTopConstraint      = subview.top == view.bottom + 16\nsubviewTopConstraint.constant = 32\n```\n\nIf you don't want the constraints to not be active on the first go just do, '!=' or even '!\u003c=' and '!\u003e=', like the following:\n```swift\nsubview.top      != view.bottom\nsubview.leading  !\u003c= view.leading\nsubview.trailing !\u003e= view.trailing\n```\n\nIn case of dimensions like height or width:\n```swift\nsubview.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 2, constant: 8).isActive = true\nsubview.heightAnchor.constraint(equalToConstant: 64).isActive = true\n```\nYou only need this:\n```swift\nsubview.width  == view.width * 2 + 8\nsubview.height == 64\n```\nFor addSubview and translatesAutoresizingMaskIntoConstraints = false you could just write a closure as follows:\n```swift\nview.addSubview(subview) {\n  subview.sides \u003c= view.sides\n}\n```\nYou also have other helpers like sides that include all sides, and size which takes a CGSize and also both horizontal and vertical constraints and centers.\n```swift\n// Constraint all sides with a padding of 2\nsubview.sides == view.sides + 2\n\n// Constraint all sides with different padding on each side.\nsubview.sides == view.sides + UIEdgeInsets(t: 1, l: 2, b: 4, r: 8)\n\n// Align both centers of view and subview\nsubview.centers == view.centers\n\n// Constraint both centers with offsets 4 and 8.\nsubview.centers == view.centers + UIOffset(x: 4, y: 8)\n\n// Constraint vertical(top and bottom) or horizontal(leading and trailing)\nsubview.vertical   == view.vertical\nsubview.horizontal == view.horizontal\n\n// Constraint size either with CGSize or both sides 64\nsubview.size == CGSize(w: 8, h: 16)\nsubview.size == 64\n```\n\n## Installation\n\n### Swift Package Manager\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. It is in early development, but BBLoader does support its use on supported platforms.\n\nOnce you have your Swift package set up, adding BBLoader as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/bibinjacobpulickal/AutoLayoutProxy.git\", .upToNextMajor(from: \"4.0.0\"))\n]\n```\nFrom Xcode 11.0+ you only need to provide the above mentioned URL.\n\nNote: No longer need to provide the above URL. You can search for AutoLayoutProxy package within Xcode.\n\n## Features\n- [x] Remove repetitive code while creating new view.\n- [x] Fill super view or any other view with/without padding.\n- [x] Align center with super view or any other view.\n\n## Support\n\n- iOS 9.0+\n- Xcode 8.3+\n- Swift 3.0+\n\n## License\nAutoLayoutProxy is released under the MIT license.  \nSee [LICENSE](https://github.com/bibinjacobpulickal/AutoLayoutProxy/blob/master/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbibinjacobpulickal%2Fautolayoutproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbibinjacobpulickal%2Fautolayoutproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbibinjacobpulickal%2Fautolayoutproxy/lists"}