Giter Club home page Giter Club logo

former's Introduction

Former

Former is a fully customizable Swift2 library for easy creating UITableView based form.

iOS 7.0+ Swift2

MIT License

Requirements

  • Xcode 7+
  • iOS 7.0+
  • Swift 2.0+

Overview

Installation

iOS 8.0+

Coming soon...

iOS 7.0+

Run the following command:

git submodule add https://github.com/ra1028/Former.git

Add the following line to your Seedfile:

github "ra1028/Former", :files => "Former/**/*.{swift,h}"

Usage(WIP)

You can setting the cell appearance and events callback at the same time.
ViewController and Cell does not need to override.

Simple Example

import Former

final class ViewController: FormViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let labelRow = LabelRowFormer<FormLabelCell>()
            .configure { row in
                row.text = "Label Cell"
            }.onSelected { row in
                // Do Something
        }
        let inlinePickerRow = InlinePickerRowFormer<FormInlinePickerCell, Int>() {
            $0.titleLabel.text = "Inline Picker Cell"
            }.configure { row in
                row.pickerItems = (1...5).map {
                    InlinePickerItem(title: "Option\($0)", value: Int($0))
                }
            }.onValueChanged { item in
                // Do Something
        }
        let header = LabelViewFormer<FormLabelHeaderView>() { view in
            view.titleLabel.text = "Label Header"
        }
        let section = SectionFormer(rowFormer: labelRow, inlinePickerRow)
            .set(headerViewFormer: header)
        former.append(sectionFormer: section)
    }
}

RowFormer

RowFormer is the base of the class that manages the cell.
Cell that managed by the RowFormer class should conform to the corresponding protocol.
Each of RowFormer classes You can set the event handling in function named like on~ (onSelected, onValueChanged, etc...)
Default provided RowFormer classes and the protocols that corresponding to it are the below.

Demo Class Protocol Default provided cell
LabelRowFormer LabelFormableRow FormLabelCell
TextFieldRowFormer TextFieldFormableRow FormTextFieldCell
TextViewRowFormer TextViewFormableRow FormTextViewCell
CheckRowFormer CheckFormableRow FormCheckCell
SwitchRowFormer SwitchFormableRow FormSwitchCell
StepperRowFormer StepperFormableRow FormStepperCell
SegmentedRowFormer SegmentedFormableRow FormSegmentedCell
SliderRowFormer SliderFormableRow FormSliderCell
PickerRowFormer PickerFormableRow FormPickerCell
DatePickerRowFormer DatePickerFormableRow FormDatePickerCell
SelecterPickerRowFormer SelecterPickerFormableRow FormSelecterPickerCell
SelecterDatePickerRowFormer SelecterDatePickerFormableRow FormSelecterDatePickerCell
InlinePickerRowFormer InlinePickerFormableRow FormInlinePickerCell
InlineDatePickerRowFormer InlineDatePickerFormableRow FormInlineDatePickerCell

License

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

former's People

Contributors

ra1028 avatar

Watchers

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