{"id":17506228,"url":"https://github.com/orchetect/crappkit","last_synced_at":"2025-04-23T12:27:02.198Z","repository":{"id":103425597,"uuid":"559187326","full_name":"orchetect/CrappKit","owner":"orchetect","description":"Pseudo-declarative AppKit UI","archived":false,"fork":false,"pushed_at":"2024-11-25T13:05:43.000Z","size":83,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T23:41:10.450Z","etag":null,"topics":["appkit","declarative-ui","swift"],"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/orchetect.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"orchetect"}},"created_at":"2022-10-29T10:33:08.000Z","updated_at":"2024-11-25T13:04:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"be90ce1d-7306-41e6-ba66-8edf3f365e02","html_url":"https://github.com/orchetect/CrappKit","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orchetect%2FCrappKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orchetect%2FCrappKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orchetect%2FCrappKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orchetect%2FCrappKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orchetect","download_url":"https://codeload.github.com/orchetect/CrappKit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250432828,"owners_count":21429747,"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","declarative-ui","swift"],"created_at":"2024-10-20T03:34:10.178Z","updated_at":"2025-04-23T12:27:02.158Z","avatar_url":"https://github.com/orchetect.png","language":"Swift","funding_links":["https://github.com/sponsors/orchetect"],"categories":[],"sub_categories":[],"readme":"# Cr*appKit*\n\nFor times when you need to use AppKit UI but wish it was more declarative like SwiftUI.\n\nEnter CrappKit: The (not too) crappy pseudo-declarative AppKit UI builder.\n\nThis library was built for convenience and is not exhaustive but covers a lot of essential use cases. No bindings or fancy tricks are involved; this is not meant to replace SwiftUI. This merely provides declarative sugar to build UI programmatically and reduce the boilerplate necessary.\n\n```swift\nclass ViewController: NSViewController {\n    weak var textField: NSTextField?\n    weak var datePicker: NSDatePicker?\n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n        view = body\n    }\n    \n    var body: some NSView {\n        CKVStack(distribution: .equalSpacing) {\n            CKText(\"Hello world\")\n            \n            CKTextField(placeholder: \"Enter some text here\")\n                .constraints(width: 200)\n                .store(in: \u0026textField)\n            \n            CKHStack {\n                CKButton(title: \"One\") { print(\"One\") }\n                CKButton(title: \"Two\") { print(\"Two\") }\n            }\n            \n            MyView()\n            \n            NSDatePicker()\n                .store(in: \u0026datePicker)\n        }\n        .constraints(padding: .standardToSuperview())\n    }\n}\n\n@MainActor func MyView() -\u003e some NSView {\n    CKHStack {\n        CKText(\"Hello\")\n        CKText(\"World\")\n    }\n}\n```\n\n## Usage\n\nAdd to your project using Swift Package Manager and `import CrappKit`.\n\nSee the Demo project for usage examples.\n\n### DSL Types\n\nAny `NSView` subclass may be used directly in the view builder, but a number of intuitive convenience classes and constructors are provided.\n\n- `CKVStack` - vertical `NSStackView`\n- `CKHStack` - horizontal `NSStackView` \n- `CKText` - `NSTextField` single \u0026 multi-line labels, and attributed string\n- `CKTextField` - editable `NSTextField`\n- `CKButton` - `NSButton` with action closure\n- `CKPathControl` - `NSPathControl` with properties and action closure\n\n### NSView Modifiers\n\nVarious NSView modifiers are provided.\n\n`NSView`\n- `autoresizingMask(_:)` - set autoresizing mask for the view\n- `disableAutoresizingMask()` - disable autoresizing mask for the view\n- `frame(rect:)` - set view rect\n- `frame(size:)` - set view size\n- `focusRingType(_:)` - set focus ring type for view\n- `withView { view in }` - modify the view within a closure\n- `store(in:)` - overwrites the passed variable with a reference to the view, usually a `weak var` akin to Interface Builder's IBOutlet\n\n`NSTextField`\n- `multilineTextAlignment(:_)` - set alignment for wrapping text\n\n### NSView NSLayoutConstraint Modifiers\n\nVarious NSView modifiers to apply NSLayoutConstraints are provided.\n\n- `constraints(height:width:)` - adds static height and/or width constraints\n- `constraints(minHeight:minWidth:)` - adds minimum height and/or width constraints\n- `constraints(maxHeight:maxWidth:)` - adds maximum height and/or width constraints\n- `constraints(padding:)` - wraps the view in an enclosing NSView with the given padding insets\n- `constraintsPriority(_:)` - sets the priority for all constraints applied to the view\n- `constraints(insets:)` - adds constraints to the view's four sides (*experimental*)\n- `constraints(centerX:centerY:)` - adds center X and/or Y constraints (*experimental*)\n\n## Roadmap\n\n- More convenience views and view modifiers\n- Support for UIKit on iOS\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forchetect%2Fcrappkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forchetect%2Fcrappkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forchetect%2Fcrappkit/lists"}