Latest 1.0.8
Homepage https://github.com/dimebt/DSForm
License MIT
Platforms ios 12.2
Authors

DSForm Logo
Build Status
codecov
Cocoapods platforms
GitHub repo size
Gitter
GitHub
Cocoapods
Website

Swift framework for creating dynamic forms.

Simple and easy to implement iOS Swift framework for building forms. It is builded on top of UICollectionViewController component.

Supports 4 basic types of form elements:

  1. FormElementTitle (top title label of the form)
  2. FormElementButton (subclass of UIButton control)
  3. FormElementTextField (subclass of UITextField control)
  4. FormElementLabel (subclass of UILabel control)

Requirements

  • Xcode 10.2
  • Swift 5.0

Installation

CocoaPods

# Podfile
use_frameworks!

target 'YOUR_TARGET_NAME' do
    pod 'DSForm'
end

Replace YOUR_TARGET_NAME and then, in the Podfile directory, type:

$ pod install

Example usage

  1. Create new UICollectionVewController and make it subbclass of FormCollectionViewController.
  2. Set the formDelegate to self in viewDidLoad() method so we can use the protocol FormDelegate methods in our class.
import UIKit
import DSForm

class ViewController: FormCollectionViewController, FormDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()        

        let element1 = FormElementTitle(text: "Please Sign Up")
        let element2 = FormElementTextField(text: "Username")
        let element3 = FormElementTextField(text: "Password")
        let element4 = FormElementButton(title: "Sign Up")
        fields = [element1, element2, element3, element4]

        formDelegate = self
    }

    func didSubmitForm(fields: [String : String]) {
        print(fields)
    }
}

Form Elements

DSForm supports 4 basic form elements inside our collection:

FormElementTitle

It defines the title of the form and it is a subclass of the standard UILabel control.

let element1 = FormElementTitle(text: "Please Sign Up")

FormElementTitle

FormElementTitle available public properties:

    public var font: UIFont
    public var identifier: String
    public var backgroundColor: UIColor
    public var fontColor: UIColor
    public var text: String

FormElementTextField

Supports user input and it is a subclass of the standard UITextField control.

var element2 = FormElementTextField(text: "Username")
element2.topLabel = "Username"

FormElementTextField

FormElementTextField available public properties:

    public var font: UIFont
    public var identifier: String
    public var backgroundColor: UIColor
    public var fontColor: UIColor
    public var topLabel: String
    public var placeholder: String
    public var validation: DSForm.FormValidation
    public var text: String

FormElementButton

Subclass of the standard UIButton control.

let element4 = FormElementButton(title: "Sign Up")

FormElementButton

FormElementButton available public properties:

    public var font: UIFont
    public var identifier: String
    public var backgroundColor: UIColor
    public var fontColor: UIColor
    public var title: String

FormElementLabel

Subclass of the standard UILabel control.

let element5 = FormElementLabel(text: "Sample text")

FormElementLabel

FormElementLabel available public properties:

    public var font: UIFont
    public var identifier: String
    public var backgroundColor: UIColor
    public var fontColor: UIColor
    public var text: String

ToDo:

  • [ ] Add support for more form elements and variations (image, checkmark, radio button etc…)
  • [ ] Add validation to UITextField (phone number, email address, numbers, regex, password etc…)
  • [ ] Add more styles to form elements
  • [ ] Add more Unit Tests
  • [ ] Add detailed documentation for every new feature

Done:

  • [ ] Add blank space (element) between form elements
  • [x] Added element size property
  • [x] Added CollectionView UIEdgeInsets property
  • [x] Added placeholder text to FormElementTextField
  • [x] Added new .Line style to FormElementTextField

Simulator Screencast

DSForm Screencast

Screenshot Simulator

Screenshot Xcode

Latest podspec

{
    "name": "DSForm",
    "version": "1.0.8",
    "summary": "Simple form library for iOS written in Swift",
    "description": "Simple to use form builder framework for iOS. Build on top of UICollectionView.",
    "homepage": "https://github.com/dimebt/DSForm",
    "screenshots": [
        "https://github.com/dimebt/DSForm/blob/master/images/screenshot_simulator.png?raw=true",
        "https://raw.githubusercontent.com/dimebt/DSForm/master/images/screenshoot_xcode.png"
    ],
    "license": "MIT",
    "authors": {
        "Dimitar Stefanovski": "[email protected]"
    },
    "social_media_url": "https://www.instagram.com/dime_codes/",
    "platforms": {
        "ios": "12.2"
    },
    "swift_versions": "5.0",
    "source": {
        "git": "https://github.com/dimebt/DSForm.git",
        "tag": "1.0.8"
    },
    "source_files": "DSForm/**/*.{h,m,swift,xib}",
    "exclude_files": "DSFormTests/**"
}

Pin It on Pinterest

Share This