Giter VIP home page Giter VIP logo

prgvalidationfield's Introduction

PRGValidationField

PRGValidationField is a flexible and customizable implementation of a self validating Text Field.

It is written in Swift 3.0 and Compatible with iOS 9.0+

Usage

To start using the component add it to your project manually as per the Installation section.

The UI component can be used via the PRGValidationField class.

To create an instance of the class, drag a UIView from the Interface builder and set it's class to PRGValidationField. PRGValidationField is @IBDesinable and customizable via @IBInspectable properties, this way almost everything can be done via the interface builder.

The properties are pretty straightforward and documented in-code but here are the most important things you need to know:

Appearance

fieldTitle:

The title of the Field, for example: "Email Address"

 @IBInspectable var fieldTitle: String

titleFont, errorFont, textFont:

The fonts used for the Field's Title, The Error Message and The Field itself.

As @IBInspectable's do not cover fonts, If you are using custom fonts you can type the name of the font (the same way you would type it programmaticaly) followed by a comma (",") and the desired size of the font. Do not forget to add all custom fonts on Info.plist OR use an awesome library called FontBlaster which does that automatically.

If the font you supplied is not found, the fallback font is the system font.

@IBInspectable var textFont: String
@IBInspectable var titleFont: String
@IBInspectable var errorFont: String 

titleColor, errorColor:

The color of the Field's Title and Error Message.

@IBInspectable var titleColor: UIColor
@IBInspectable var errorColor: UIColor

bgColor, borderColor, textColor

The DEFAULT color of the Field's Background, Border and it's Text.

@IBInspectable var bgColor: UIColor
@IBInspectable var borderColor: UIColor
@IBInspectable var textColor: UIColor

validBgColor, validBorderColor, validTextColor, validImage

The [VALID] state color of the Field's Background, Border, Text as well as the right view indicator image

@IBInspectable var validBorderColor: UIColor
@IBInspectable var validBgColor: UIColor
@IBInspectable var validTextColor: UIColor
@IBInspectable var validImage: UIImage

invalidBgColor, invalidBorderColor, invalidTextColor, invalidImage

The [INVALID] state color of the Field's Background, Border, Text as well as the right view indicator image

@IBInspectable var invalidBorderColor: UIColor
@IBInspectable var invalidBgColor: UIColor
@IBInspectable var invalidTextColor: UIColor
@IBInspectable var invalidImage: UIImage

Internal Stuff

validationMode

You can set the validation mode programmaticaly:

enum ValidationMode: Int {
    case name = 0,email,password,confirmPassword
}

nameField.validationMode = .name

mode

@IBInspectable property to set validation mode (See ValidationMode Enum)

     0 = Name , Surname
     1 = Email
     2 = Password
     3 = Confirm PassWord

text

Getter for the text field's text

public var text: String?

otherPasswordField

Set this in order for "Password" and "Confirm Password" fields to be able to see each other. NOTE: Only set one of two fields. Only password field or confirm password field

weak var otherPasswordField: PRGValidationField

isValid

Get the validation status of the Text Field

var isValid: Bool?

PRGValidationFieldDelegate

There is one optional callback function:

@objc optional func PRGValidationField(_field: PRGValidationField, didValidateWithResult result: Bool, andErrorMessage errorMessage: String?)

Installation

Manual

Just clone this repo and copy the PRGValidationField folder into your project.

Cocoapods

Coming soon.

Contributing

We welcome all contributions. Please contanct me or submit a pull request, and I will give you an e-Cookie :)

License

PRGValidationField is made for Programize LLC by John Spiropoulos and it is available under the MIT license.

prgvalidationfield's People

Contributors

jspiropoulosprogramize avatar ispiropoulos avatar abdullahselek avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.