Latest 0.1
Homepage https://github.com/vitormesquita/JFB
License MIT
Platforms ios 9.0
Authors

J.F.B (Jera Form Builder)

JFB is Jera’s way to create forms quickly and easily.

We are using Eureka’s enginee and Material components to concept good and beautiful forms.

Requirements

  • Xcode 9.0+
  • Swift 4.0+

Installation

Pod

JFB is available through CocoaPods. To install following line at Podfile

pod 'JFB'

Carthage

Coming soon

Manually

If you don’t use any dependency managers, you can use JFB in your project manually just adding the files which contains JFB Classes

You will need to add JFB’s dependecies libraries as well:

Concept

JFB helps you create forms with Material components (other layouts soon), and all concepts of a form like validations, masks …

Basically with a few code’s line you can create a form just manipulating the result (to send to API for example)

FormBuilderViewController

FormBuilderViewController is the UIViewController that build all fields and create a submit button by default.

To create it you will need pass an Array of JField and it’s FormBuilderDelegate must by be implemented to receive form values as a Dictionary.

JField

It’s a protocol that all fields will implement.

Fields List

  • JTextField
  • JDateField
  • JTimeField
  • (Coming soon others)

By default JField needs these attributes:

  • id: It’s the dictionary Key that you’ll receive value from form.
  • placeholder: It’s the field’s placeholder
  • validations: Set field’s validation.

Usage

How to create a form

Set your field an Array and call FormBuilderViewController passing your fields and delegate

import JFB

class ViewController: UIViewController {

    let loginFormFields: [JField] = [
        JTextField(id: "email", type: .email, placeholder: "E-mail", validations: [.required, .email]),
        JTextField(id: "password", type: .password, placeholder: "Password", validations: [.required,
                                                                                        .minLength(6)])
    ]

    lazy var formViewController: FormBuilderViewController = { 
        return FormBuilderViewController(fields: loginFormFields, delegate: self) 
    }()

    override func viewDidLoad() {
        super.viewDidLoad()

        formViewController.submitText = .white
        formViewController.submitBackgroundColor = .blue
        formViewController.submitText = "LOGIN"
    }

    @IBAction func action(_ sender: Any) {
        let nv = UINavigationController(rootViewController: formViewController)
        present(nv, animated: true)
    }
}

extension ViewController: FormBuilderDelegate {

    func formReceivedValues(_ values: [String: Any]) {
        print(values)
    }
}

Photo

Customize

Of course form’s layout always needs to be configured. So for this we provide some attributes to configure form layout as you want.

/// Color to apply at all input tint color and navigation accessory view
open var tintColor: UIColor = Color.blue.base

/// Text to show on submit button
open var submitText: String?

/// Submit button's text color
open var submitTextColor: UIColor

/// Submit button's background color
open var submitBackgroundColor: UIColor

/// Submit button's background color when was disable
open var submitDisableColor: UIColor

/// Submit button's click callback color
open var submitPulseColor: UIColor

If you want more customization please let we now, submit an issue explaning what kind of customization you need.

Validations

Each field has its own validations, so when you’ll create a field need to pass an Array of ValidationType.

ValidationType List

  • cpf
  • email
  • required
  • regex
  • maxLength
  • minLength

The validation is applied on real time (when user is typping) and error message is showing as well.

Author

Vitor Mesquita, [email protected]

License

JFB is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "JFB",
    "version": "0.1",
    "summary": "Jera's new way to build form quickly and easily",
    "description": "Jera Form Builder (JFB) bring a new way to build form using *Eureka* enginee",
    "homepage": "https://github.com/vitormesquita/JFB",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Vitor Mesquita": "[email protected]"
    },
    "source": {
        "git": "https://github.com/vitormesquita/JFB.git",
        "tag": "0.1"
    },
    "platforms": {
        "ios": "9.0"
    },
    "default_subspecs": "Core",
    "resource_bundles": {
        "JFB": [
            "Assets/*.png"
        ]
    },
    "subspecs": [
        {
            "name": "Core",
            "source_files": "Source/**/*.swift",
            "dependencies": {
                "Eureka": [
                    "~> 4"
                ],
                "Material": [
                    "~> 2"
                ],
                "NSStringMask": [
                    "~> 1.2"
                ]
            }
        }
    ]
}

Pin It on Pinterest

Share This