{"id":17043440,"url":"https://github.com/leavez/componentswift","last_synced_at":"2025-04-12T15:11:14.094Z","repository":{"id":56906451,"uuid":"89390635","full_name":"leavez/ComponentSwift","owner":"leavez","description":"Bring ComponentKit to Swift, A React-inspired view framework for iOS","archived":false,"fork":false,"pushed_at":"2018-11-26T02:48:52.000Z","size":336,"stargazers_count":49,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T09:45:09.598Z","etag":null,"topics":["componentkit","ios","listview","react","swift","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Objective-C++","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/leavez.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":"2017-04-25T17:56:15.000Z","updated_at":"2023-03-25T02:32:17.000Z","dependencies_parsed_at":"2022-08-20T19:20:23.688Z","dependency_job_id":null,"html_url":"https://github.com/leavez/ComponentSwift","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavez%2FComponentSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavez%2FComponentSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavez%2FComponentSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavez%2FComponentSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leavez","download_url":"https://codeload.github.com/leavez/ComponentSwift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586231,"owners_count":21128997,"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":["componentkit","ios","listview","react","swift","wrapper"],"created_at":"2024-10-14T09:29:32.485Z","updated_at":"2025-04-12T15:11:14.067Z","avatar_url":"https://github.com/leavez.png","language":"Objective-C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cp align=\"center\"\u003e\u003cimg src=\"/etc/logo.png\" width=\"512\"\u003e\u003c/p\u003e\n\n[![Platform](https://img.shields.io/cocoapods/p/ComponentSwift.svg?style=flat)](http://cocoapods.org/pods/ComponentSwift)\n[![Swift](https://img.shields.io/badge/swift-4.2-orange.svg?style=flat)](#)\n[![Build Status](https://travis-ci.org/leavez/ComponentSwift.svg?branch=master)](https://travis-ci.org/leavez/ComponentSwift)\n\n\nComponentSwift brings ComponentKit to swift.\n\n[ComponentKit](http://componentkit.org) is a react-inspired native view framework for iOS developed by Facebook. It intruduces a new abstract layer (component) to automatically handle view reuse, meanwhile providing the ability to build smooth list views easily.\n\nComponentSwift is an objc wrapper of ComponentKit and refined for swift. ComponentSwift is designed to be a subset of ComponentKit, implementing the most commonly used features.\n\n### Example\n\n```Swift\nclass CellComponent: CompositeComponent {\n\n    init?(text: String) {\n        super.init(\n            view:\n            ViewConfiguration(\n                attributes:\n                .backgroundColor(.gray),\n                .tapGesture(#selector(didTapSelf))\n            ),\n            component:\n            getAnotherComponent(text) //\n    }\n// ...\n\n```\nor try a real demo with `pod try ComponentSwift`\n\n## Supported Features\n#### Supported:\n- [x] Component:\n  -  almost all built-in components.\n  -  ability to wrap an existing CKComponent on your own\n- [x] Datasource: \n  - CollectionViewTransactionalDatasource\n  - TableViewTransactionalDatasource (unofficial) \n  - HostingView\n- [x] Response Chain and Actions\n- [x] Scope and State\n- [x] Animation\n\n\n#### Not supported:\n- [ ] component controller and StatefulViewComponent \n- [ ] things about viewContext, mount\n- [ ] `computeLayoutThatFits:` overriding\n- [ ] ...\n\n\n### Working with legacy code\n\nLegacy CKComponent classes could continue to work in swift when using ComponentSwift. Classes and methods are provided to wrap your legacy components conveniently. Every attribute in ComponentKit has an equivalent in ComponentSwift.\n\nSubclass `CSCompositeComponent` and use `initWithCKComponent` in its implementation. Import `ComponentSubclass.h` to use this stuff. Reference more from `WrapExisted` in the demo project.\n\n[more document here](/etc/doc.md)\n\n## TLDR\nComponentKit is implemented and used with objc++, which is pretty cool. It's incompatible with swift, since swift doesn't support objc++. So that's the reason for ComponentSwift.\n\nA objc wrapper is implemented to bridge componentKit to swift. It creates an objc version equivalent for every type in componentKit's APIs, objc class for c++ struct/class, hiding the c++ header in the implementation. It doesn't touch deep in componentKit. The runtime code is almost the same to the one using componentKit directly in the simplest situation except for construction of objc layer, so it's safe to use.\n\nIt refined the bridged interface for swift, including notating nullability, adding default parameter and swift-only api. C++'s aggregate initialization is very expressive in componentKit. ComponentSwift tries hard to simulate the api with default parameters and ExpressibleByXXXLiteral. At least we got code completion here.\n\n\n## Installation\n\n```ruby\npod \"ComponentSwift\"\n```\n\nSwift version:\n\n- swift 4.2: v0.5\n- swift 4.1: v0.4.1 \n- swift 3: v0.3\n\n## License\n\nComponentSwift is available under the MIT license. \n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleavez%2Fcomponentswift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleavez%2Fcomponentswift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleavez%2Fcomponentswift/lists"}