{"id":2971,"url":"https://github.com/SiarheiFedartsou/MeasurementTextField","last_synced_at":"2025-08-03T12:31:53.188Z","repository":{"id":62447651,"uuid":"117434723","full_name":"SiarheiFedartsou/MeasurementTextField","owner":"SiarheiFedartsou","description":"UITextField-based control for (NS)Measurement values input.","archived":false,"fork":false,"pushed_at":"2018-02-02T08:29:15.000Z","size":859,"stargazers_count":15,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-24T02:33:57.279Z","etag":null,"topics":["ios","measurement","nsmeasurement","uitextfield"],"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/SiarheiFedartsou.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":"2018-01-14T13:56:45.000Z","updated_at":"2023-03-03T10:35:33.000Z","dependencies_parsed_at":"2022-11-01T23:06:52.179Z","dependency_job_id":null,"html_url":"https://github.com/SiarheiFedartsou/MeasurementTextField","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/SiarheiFedartsou%2FMeasurementTextField","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiarheiFedartsou%2FMeasurementTextField/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiarheiFedartsou%2FMeasurementTextField/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiarheiFedartsou%2FMeasurementTextField/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SiarheiFedartsou","download_url":"https://codeload.github.com/SiarheiFedartsou/MeasurementTextField/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228543229,"owners_count":17934447,"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":["ios","measurement","nsmeasurement","uitextfield"],"created_at":"2024-01-05T20:16:27.782Z","updated_at":"2024-12-07T00:31:10.068Z","avatar_url":"https://github.com/SiarheiFedartsou.png","language":"Swift","funding_links":[],"categories":["UI"],"sub_categories":["TextField \u0026 TextView","Other free courses"],"readme":"# MeasurementTextField\n\n[![CI Status](http://img.shields.io/travis/SiarheiFedartsou/MeasurementTextField.svg?style=flat)](https://travis-ci.org/SiarheiFedartsou/MeasurementTextField)\n[![Version](https://img.shields.io/cocoapods/v/MeasurementTextField.svg?style=flat)](http://cocoapods.org/pods/MeasurementTextField)\n[![License](https://img.shields.io/cocoapods/l/MeasurementTextField.svg?style=flat)](http://cocoapods.org/pods/MeasurementTextField)\n[![Platform](https://img.shields.io/cocoapods/p/MeasurementTextField.svg?style=flat)](http://cocoapods.org/pods/MeasurementTextField)\n\nUITextField-based control for (NS)Measurement values input. Provides type-safe keyboard and picker based input of different measurements(such as length, mass, speed etc). See example app for API details.\n\n## Screenshots\n\n\u003cimg src=\"/images/screenshot1.png\" alt=\"Screenshot 1\" width=\"50%\" /\u003e\u003cimg src=\"/images/screenshot2.png\" alt=\"Screenshot 2\"  width=\"50%\" /\u003e\n\n## Example Usage\n\nFirst of all you need to import `MeasurementTextField`:\n```swift\nimport MeasurementTextField\n```\n\nNeed text field for angle input? Just write:\n```swift\nlet angleTextField = MeasurementTextField\u003cUnitAngle\u003e(inputType: .keyboard(.degrees))\n```\nInstead of `UnitAngle` you can use [any `Dimension` type defined in Foundation](https://developer.apple.com/documentation/foundation/dimension) or implement own `Dimension` subclass if you need something special.\nThen to obtain [Measurement](https://developer.apple.com/documentation/foundation/measurement) value inputted by user just use `value` property:\n```swift\nif let value = angleTextField.value {\n    let formatter = MeasurementFormatter()\n    print(\"Your input is \\(formatter.string(from: value))!\")\n} else {\n    print(\"You cleared the field!\")\n}\n```\nDegrees input is not enough? Want also arc minutes and arc seconds? Just use another input type:\n```swift\nlet angleTextField = MeasurementTextField\u003cUnitAngle\u003e(inputType: .picker([\n    PickerColumn(unit: UnitAngle.degrees, range: 0...360, step: 1.0), // `step` is optional here, 1.0 by default\n    PickerColumn(unit: UnitAngle.arcMinutes, range: 0...60),\n    PickerColumn(unit: UnitAngle.arcSeconds, range: 0...60),\n]))\n```\nNeed to be notified when value is changed? Just subscribe on `UIControlEvents.valueChanged`:\n```swift\n@objc private func onAngleValueChanged() {\n    print(\"Angle value was changed!\")\n}\nangleTextField.addTarget(self, action: #selector(onAngleValueChanged), for: .valueChanged)\n```\n\n### Customization\n\nTo change text color of measurement unit label for `.keyboard` input type just change `tintColor`:\n```swift\nangleTextField.tintColor = .red\n```\nWant to remove it completely? Just pass `showMeasureUnit: false` in input type configuration:\n```swift\nlet angleTextField = MeasurementTextField\u003cUnitAngle\u003e(inputType: .keyboard(.degrees, showMeasureUnit: false))\n```\nAlso be aware that `MeasurementTextField` is an usual `UITextField`, so you can use all APIs provided by it, except of `textField(_:shouldChangeCharactersIn:replacementString:)` delegate method.\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n\n## Requirements\n\n- Swift 4\n\n## Issues\n\nIf you need some feature or you found a bug feel free to [open an issue](https://github.com/SiarheiFedartsou/MeasurementTextField/issues/new).\n\n## Installation\n\nMeasurementTextField is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'MeasurementTextField'\n```\n\n## Author\n\nSiarheiFedartsou, siarhei.fedartsou@gmail.com\n\n## License\n\nMeasurementTextField is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSiarheiFedartsou%2FMeasurementTextField","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSiarheiFedartsou%2FMeasurementTextField","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSiarheiFedartsou%2FMeasurementTextField/lists"}