Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Otbivnoe/NxEnabled
Library that allows you binding `enabled` property of button with textable elements (TextView, TextField)
https://github.com/Otbivnoe/NxEnabled
ios swift uibutton
Last synced: 3 months ago
JSON representation
Library that allows you binding `enabled` property of button with textable elements (TextView, TextField)
- Host: GitHub
- URL: https://github.com/Otbivnoe/NxEnabled
- Owner: Otbivnoe
- License: mit
- Archived: true
- Created: 2017-01-12T08:22:52.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-04T06:01:03.000Z (about 7 years ago)
- Last Synced: 2024-04-29T09:42:13.502Z (6 months ago)
- Topics: ios, swift, uibutton
- Language: Swift
- Homepage:
- Size: 55.7 KB
- Stars: 33
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - NxEnabled - Library which allows you binding `enabled` property of button with textable elements (TextView, TextField). (UI / TextField & TextView)
- awesome-ios-star - NxEnabled - Library which allows you binding `enabled` property of button with textable elements (TextView, TextField). (UI / TextField & TextView)
README
[![Build Status](https://travis-ci.org/Otbivnoe/NxEnabled.svg?branch=master)](https://travis-ci.org/Otbivnoe/NxEnabled)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](#carthage)
[![CocoaPods compatible](https://img.shields.io/cocoapods/v/NxEnabled.svg)](#cocoapods)
![Swift 3.0.x](https://img.shields.io/badge/Swift-3.0.x-orange.svg)
![platforms](https://img.shields.io/badge/platforms-iOS-lightgrey.svg)## What is NxEnabled?
It's a fairly common case, when the `enabled` state of button depends on some textable elements such as TextView, TextField. So this library allows the simplest way to achive this purpose with only few lines of code.
## Getting started :rocket:
Typical login screen with short, beautiful validation code:
```swift
loginButton.isEnabled(by: usernameTextField, passwordTextField) { username, password in
username.characters.count > 5 && password.characters.count > 5
}
```you can also combine together `UITextView` with `UITextField`'s:
```swift
signUpButton.isEnabled(by: firstnameTextField, lastnameTextField, bioTextView) { firstname, lastname, bio in
return /* validation value */
}
```*So there is also oportunity to add not UI element:*
* Implement `Textable` protocol
* Be a successor from `NSObject`
* Not forget about `dynamic` label for property
* Done.
```swift
class Object: NSObject, Textable {
dynamic var value: String?
var textKey: String {
return "value"
}
}
```### NOTE:
**One important case is that you should clear button's bag. It removes all observers from textable elements. Usually it needs to do in `deinit` method.**```swift
deinit {
signUpButton.clearBag()
}
```### **Now library allows to add textable elements up to six. :clap:**
## Installation :fire:
#### CocoaPods
To integrate NxEnabled, simply add the following line to your `Podfile`:
```ruby
pod "NxEnabled"
```#### Carthage
To integrate NxEnabled into your Xcode project using Carthage, specify it in your `Cartfile`:
```ogdl
github "Otbivnoe/NxEnabled"
```Run `carthage update` to build the framework and drag the built `NxEnabled.framework` into your Xcode project.
## Author :muscle:
Nikita Ermolenko, [email protected]
## License :exclamation:
NxEnabled is available under the MIT license. See the LICENSE file for more info.