Latest 1.1.1
Homepage https://github.com/Otbivnoe/NxEnabled
License MIT
Platforms ios 8.4, requires ARC
Authors

NxEnabled

Build Status
Carthage compatible
CocoaPods compatible
Swift 3.0.x
platforms

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:

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:

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.
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.

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:

pod "NxEnabled"

Carthage

To integrate NxEnabled into your Xcode project using Carthage, specify it in your Cartfile:

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.

Latest podspec

{
    "name": "NxEnabled",
    "version": "1.1.1",
    "summary": "Library which allows you binding `enabled` property of button with textable elements (TextView, TextField).",
    "homepage": "https://github.com/Otbivnoe/NxEnabled",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Nikita Ermolenko": "[email protected]"
    },
    "platforms": {
        "ios": "8.4"
    },
    "requires_arc": true,
    "source": {
        "git": "https://github.com/Otbivnoe/NxEnabled.git",
        "tag": "1.1.1"
    },
    "source_files": "Sources/*.{h,swift}",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This