{"id":20337583,"url":"https://github.com/k-o-d-e-n/quickcontrol","last_synced_at":"2025-09-18T13:59:35.864Z","repository":{"id":62450776,"uuid":"71731946","full_name":"k-o-d-e-n/QUIckControl","owner":"k-o-d-e-n","description":"Base class for quick implementation UIControl subclass with standard(enabled, highlighted, selected) and custom states.","archived":false,"fork":false,"pushed_at":"2019-12-18T09:21:37.000Z","size":924,"stargazers_count":27,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-05T03:44:02.112Z","etag":null,"topics":["control","custom","pincode","priority","stateful","substate","uicontrol-subclass"],"latest_commit_sha":null,"homepage":null,"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/k-o-d-e-n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-23T21:52:00.000Z","updated_at":"2024-10-17T01:32:26.000Z","dependencies_parsed_at":"2022-11-01T23:33:01.700Z","dependency_job_id":null,"html_url":"https://github.com/k-o-d-e-n/QUIckControl","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/k-o-d-e-n/QUIckControl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-o-d-e-n%2FQUIckControl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-o-d-e-n%2FQUIckControl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-o-d-e-n%2FQUIckControl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-o-d-e-n%2FQUIckControl/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/QUIckControl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-o-d-e-n%2FQUIckControl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275780416,"owners_count":25527345,"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","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["control","custom","pincode","priority","stateful","substate","uicontrol-subclass"],"created_at":"2024-11-14T21:09:31.636Z","updated_at":"2025-09-18T13:59:35.843Z","avatar_url":"https://github.com/k-o-d-e-n.png","language":"Swift","readme":"# QUIckControl\nBase class for quick implementation UIControl subclass based on standard(enabled, highlighted, selected) and custom states.\nImplementation based on KVC.\n\n[![Version](https://img.shields.io/cocoapods/v/QUIckControl.svg?style=flat)](http://cocoapods.org/pods/QUIckControl)\n[![License](https://img.shields.io/cocoapods/l/QUIckControl.svg?style=flat)](http://cocoapods.org/pods/QUIckControl)\n[![Platform](https://img.shields.io/cocoapods/p/QUIckControl.svg?style=flat)](http://cocoapods.org/pods/QUIckControl)\n\n## Installation\n\nQUIckControl is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"QUIckControl\"\n```\n\n\u003ch2\u003eManage states:\u003c/h2\u003e\n\nYou may to bind value for specific target with state of types:\n - simple state as bitmask (UIControlState);\n - state, which contains in current state (.intersected);\n - all states, which not matched specified state (.inverted);\n - all states, where current state contains one or more specified substates (.oneOfSeveral);\n - all states, where current state not contains specified substates (.noneOfThis);\n - custom state, which you implemented (.custom);\n \nAll state types have priority and value setup from most high priority state.\nIn default implementation simple state have priority 1000, intersected 999, inverted 750, oneOfSeveral and noneOfThis 500, custom user defined. For any type of state descriptor you may set your priority.\n\nExample usage:\n\nIn most cases, state looks like bool property or him may be represented in bool property. So, before setup value for state, it need register using:\n```swift\nfunc register(_ state: UIControlState, forBoolKeyPath keyPath: String, inverted: Bool)\nfunc register(_ state: UIControlState, with predicate: NSPredicate)\n```\nexample:\n```swift\nregister(.disabled, forBoolKeyPath: #keyPath(UIControl.enabled), inverted: true)\nregister(.valid, with: NSPredicate { control, _ in\n    return control.filled \u0026\u0026 control.valid\n})\n```\n\nImmediately, after registration you may setup values for this state using:\n```swift\nfunc setValue(_ value: Any?, forTarget: NSObject = default, forKeyPath: String, forInvertedState: UIControlState) {\nfunc setValue(_ value: Any?, forTarget: NSObject = default, forKeyPath: String, forAllStatesContained: UIControlState)\nfunc setValue(_ value: Any?, forTarget: NSObject = default, forKeyPath: String, for: UIControlState)\nfunc setValue(_ value: Any?, forTarget: NSObject = default, forKeyPath: String, for: QUICStateDescriptor)\n```\nexamples:\n```swift\ncontrol.setValue(UIColor.black, forKeyPath: #keyPath(UIView.backgroundColor), forAllStatesContained: .highlighted)\ncontrol.setValue(\"QuickControl sended this string\",\n                 forTarget:receiver\n                 forKeyPath: #keyPath(StringReceiver.value),\n                 for: QUICStateDescriptor(state: [.filled, .invalid], priority: 1000, predicate: { $0.contains(.filled) \u0026\u0026 !$0.contains(.invalid) }))\n```\nRemove values:\n```swift\nfunc removeValues(forTarget target: NSObject, forKeyPath key: String, forState state: UIControlState)\nfunc removeValues(forTarget target: NSObject, forKeyPath key: String)\nfunc removeValues(forTarget target: NSObject? = default)\n```\n\nFor multiple switches state factors (aka bool property) use transitions:\n```swift\nfunc beginTransition()\nfunc endTransition() // without apply current state\nfunc commitTransition() // with apply current state\nfunc performTransition(withCommit commit: Bool = default, transition: () -\u003e Void)\n```\n\n\u003ch2\u003eOther possibilities:\u003c/h2\u003e\n\nYou may subscribe on state and events using:\n```swift\nfunc subscribe(on events: UIControlEvents, _ action: @escaping (QUIckControl) -\u003e Void) -\u003e QUIckControlActionTarget\nfunc subscribe(on state: QUICStateDescriptor, _ action: @escaping () -\u003e ())\n```\nexample:\n```swift\ncontrol.subscribe(on: QUICStateDescriptor(intersected: .valid), { button.enabled = true })\n```\n\n# PinCodeControl\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"Resources/demo.gif\"\u003e\n\u003c/p\u003e\n\nQUIckControl subclass, which is used for input PIN code. It uses programming states for change visual view.\n\n```ruby\npod \"PinCodeControl\"\n```\n\nCustom event and states:\n```swift\nextension UIControlEvents {\n    public static var typeComplete = UIControlEvents(rawValue: 1 \u003c\u003c 24)\n}\nextension UIControlState {\n    public static var filled = UIControlState(rawValue: 1 \u003c\u003c 16)\n    public static var invalid = UIControlState(rawValue: 1 \u003c\u003c 17)\n    public static var valid = UIControlState(rawValue: (1 \u003c\u003c 18) | filled.rawValue)\n}\n// preset state descriptors\nenum States {\n    static public let plain: QUICStateDescriptor\n    static public let valid: QUICStateDescriptor\n    static public let invalid: QUICStateDescriptor\n    static public let highlighted: QUICStateDescriptor\n    static public let disabled: QUICStateDescriptor\n}\n```\n\nMain API\n```swift\nvar code: String { get } // entered code\nvar filled: Bool { get } // enabled, when all code entered\nvar valid: Bool { get } // disabled, when entered code invalid\nvar validator: BlockPredicate\u003cString\u003e? // object for user validation pin code value\nvar shouldUseDefaultValidation: Bool // if true, then code equal strings, such as '1111', '1234', '9876' will be defined as invalid values\nvar filledItemColor: UIColor? // color for entered code element\nvar itemPath: UIBezierPath? // bezier path for code element\n\ninit(parameters: Parameters, frame: CGRect? = default) // main initializer\nfunc clear() // clear all entered code\n\n// methods for set parameters for each state\nfunc setFillColor(fillColor: UIColor?, for state: QUICStateDescriptor)\nfunc setBorderColor(borderColor: UIColor?, for state: QUICStateDescriptor)\nfunc setBorderWidth(borderWidth: CGFloat, for state: QUICStateDescriptor)\nfunc setForValidState(fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat)\nfunc setForInvalidState(fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat)\nfunc setForPlainState(fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat)\nfunc setForHighlightedState(fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat)\nfunc setForDisabledState(fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat)\n// validation\nfunc validate() -\u003e Bool // perform validation current code value\nfunc validate(_ pin: String) -\u003e Bool // method for validation entered pin code. Declared for subclasses override.\n```\n\n\u003ch2\u003eSupport information:\u003c/h2\u003e\nObjective C version is not supported.\n\nFor quick research pattern this implementation, you may see project:\nhttps://github.com/k-o-d-e-n/Statable\n\n## Contributing\n\n[Read here](https://github.com/k-o-d-e-n/QUIckControl/blob/master/CONTRIBUTING.md)\n\n## Author\n\nDenis Koryttsev, koden.u8800@gmail.com\n\n## License\n\nQUIckControl is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-o-d-e-n%2Fquickcontrol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk-o-d-e-n%2Fquickcontrol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-o-d-e-n%2Fquickcontrol/lists"}