Elegant iOS form builder in Swift

Overview

Eureka: Elegant form builder in Swift

Build status Platform iOS Swift 5 compatible Carthage compatible CocoaPods compatible License: MIT codebeat badge

Made with ❤️ by XMARTLABS. This is the re-creation of XLForm in Swift.

简体中文

Overview

Contents

For more information look at our blog post that introduces Eureka.

Requirements (for latest release)

  • Xcode 11+
  • Swift 5.0+

Example project

You can clone and run the Example project to see examples of most of Eureka's features.

Usage

How to create a form

By extending FormViewController you can then simply add sections and rows to the form variable.

import Eureka

class MyFormViewController: FormViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        form +++ Section("Section1")
            <<< TextRow(){ row in
                row.title = "Text Row"
                row.placeholder = "Enter text here"
            }
            <<< PhoneRow(){
                $0.title = "Phone Row"
                $0.placeholder = "And numbers here"
            }
        +++ Section("Section2")
            <<< DateRow(){
                $0.title = "Date Row"
                $0.value = Date(timeIntervalSinceReferenceDate: 0)
            }
    }
}

In the example we create two sections with standard rows, the result is this:

Screenshot of Custom Cells

You could create a form by just setting up the form property by yourself without extending from FormViewController but this method is typically more convenient.

Configuring the keyboard navigation accesory

To change the behaviour of this you should set the navigation options of your controller. The FormViewController has a navigationOptions variable which is an enum and can have one or more of the following values:

  • disabled: no view at all
  • enabled: enable view at the bottom
  • stopDisabledRow: if the navigation should stop when the next row is disabled
  • skipCanNotBecomeFirstResponderRow: if the navigation should skip the rows that return false to canBecomeFirstResponder()

The default value is enabled & skipCanNotBecomeFirstResponderRow

To enable smooth scrolling to off-screen rows, enable it via the animateScroll property. By default, the FormViewController jumps immediately between rows when the user hits the next or previous buttons in the keyboard navigation accesory, including when the next row is off screen.

To set the amount of space between the keyboard and the highlighted row following a navigation event, set the rowKeyboardSpacing property. By default, when the form scrolls to an offscreen view no space will be left between the top of the keyboard and the bottom of the row.

class MyFormViewController: FormViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        form = ...

	// Enables the navigation accessory and stops navigation when a disabled row is encountered
	navigationOptions = RowNavigationOptions.Enabled.union(.StopDisabledRow)
	// Enables smooth scrolling on navigation to off-screen rows
	animateScroll = true
	// Leaves 20pt of space between the keyboard and the highlighted row after scrolling to an off screen row
	rowKeyboardSpacing = 20
    }
}

If you want to change the whole navigation accessory view, you will have to override the navigationAccessoryView variable in your subclass of FormViewController.

Getting row values

The Row object holds a value of a specific type. For example, a SwitchRow holds a Bool value, while a TextRow holds a String value.

// Get the value of a single row
let row: TextRow? = form.rowBy(tag: "MyRowTag")
let value = row.value

// Get the value of all rows which have a Tag assigned
// The dictionary contains the 'rowTag':value pairs.
let valuesDictionary = form.values()

Operators

Eureka includes custom operators to make form creation easy:

+++       Add a section

form +++ Section()

// Chain it to add multiple Sections
form +++ Section("First Section") +++ Section("Another Section")

// Or use it with rows and get a blank section for free
form +++ TextRow()
     +++ TextRow()  // Each row will be on a separate section

<<<       Insert a row

form +++ Section()
        <<< TextRow()
        <<< DateRow()

// Or implicitly create the Section
form +++ TextRow()
        <<< DateRow()

+=        Append an array

// Append Sections into a Form
form += [Section("A"), Section("B"), Section("C")]

// Append Rows into a Section
section += [TextRow(), DateRow()]

Using the callbacks

Eureka includes callbacks to change the appearance and behavior of a row.

Understanding Row and Cell

A Row is an abstraction Eureka uses which holds a value and contains the view Cell. The Cell manages the view and subclasses UITableViewCell.

Here is an example:

let row  = SwitchRow("SwitchRow") { row in      // initializer
                        row.title = "The title"
                    }.onChange { row in
                        row.title = (row.value ?? false) ? "The title expands when on" : "The title"
                        row.updateCell()
                    }.cellSetup { cell, row in
                        cell.backgroundColor = .lightGray
                    }.cellUpdate { cell, row in
                        cell.textLabel?.font = .italicSystemFont(ofSize: 18.0)
                }

Screenshot of Disabled Row

Callbacks list

  • onChange()

    Called when the value of a row changes. You might be interested in adjusting some parameters here or even make some other rows appear or disappear.

  • onCellSelection()

    Called each time the user taps on the row and it gets selected.

  • cellSetup()

    Called only once when the cell is first configured. Set permanent settings here.

  • cellUpdate()

    Called each time the cell appears on screen. You can change the appearance here using variables that may not be present on cellSetup().

  • onCellHighlightChanged()

    Called whenever the cell or any subview become or resign the first responder.

  • onRowValidationChanged()

    Called whenever the the validation errors associated with a row changes.

  • onExpandInlineRow()

    Called before expanding the inline row. Applies to rows conforming InlineRowType protocol.

  • onCollapseInlineRow()

    Called before collapsing the inline row. Applies to rows conforming InlineRowType protocol.

  • onPresent()

    Called by a row just before presenting another view controller. Applies to rows conforming PresenterRowType protocol. Use it to set up the presented controller.

Section Header and Footer

You can set a title String or a custom View as the header or footer of a Section.

String title

Section("Title")

Section(header: "Title", footer: "Footer Title")

Section(footer: "Footer Title")

Custom view

You can use a Custom View from a .xib file:

Section() { section in
    var header = HeaderFooterView<MyHeaderNibFile>(.nibFile(name: "MyHeaderNibFile", bundle: nil))

    // Will be called every time the header appears on screen
    header.onSetupView = { view, _ in
        // Commonly used to setup texts inside the view
        // Don't change the view hierarchy or size here!
    }
    section.header = header
}

Or a custom UIView created programmatically

Section(){ section in
    var header = HeaderFooterView<MyCustomUIView>(.class)
    header.height = {100}
    header.onSetupView = { view, _ in
        view.backgroundColor = .red
    }
    section.header = header
}

Or just build the view with a Callback

Section(){ section in
    section.header = {
          var header = HeaderFooterView<UIView>(.callback({
              let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
              view.backgroundColor = .red
              return view
          }))
          header.height = { 100 }
          return header
        }()
}

Dynamically hide and show rows (or sections)

Screenshot of Hidden Rows

In this case we are hiding and showing whole sections.

To accomplish this each row has a hidden variable of optional type Condition which can be set using a function or NSPredicate.

Hiding using a function condition

Using the function case of Condition:

Condition.function([String], (Form)->Bool)

The array of String to pass should contain the tags of the rows this row depends on. Each time the value of any of those rows changes the function is reevaluated. The function then takes the Form and returns a Bool indicating whether the row should be hidden or not. This the most powerful way of setting up the hidden property as it has no explicit limitations of what can be done.

form +++ Section()
            <<< SwitchRow("switchRowTag"){
                $0.title = "Show message"
            }
            <<< LabelRow(){

                $0.hidden = Condition.function(["switchRowTag"], { form in
                    return !((form.rowBy(tag: "switchRowTag") as? SwitchRow)?.value ?? false)
                })
                $0.title = "Switch is on!"
        }

Screenshot of Hidden Rows

public enum Condition {
    case function([String], (Form)->Bool)
    case predicate(NSPredicate)
}

Hiding using an NSPredicate

The hidden variable can also be set with a NSPredicate. In the predicate string you can reference values of other rows by their tags to determine if a row should be hidden or visible. This will only work if the values of the rows the predicate has to check are NSObjects (String and Int will work as they are bridged to their ObjC counterparts, but enums won't work). Why could it then be useful to use predicates when they are more limited? Well, they can be much simpler, shorter and readable than functions. Look at this example:

$0.hidden = Condition.predicate(NSPredicate(format: "$switchTag == false"))

And we can write it even shorter since Condition conforms to ExpressibleByStringLiteral:

$0.hidden = "$switchTag == false"

Note: we will substitute the value of the row whose tag is 'switchTag' instead of '$switchTag'

For all of this to work, all of the implicated rows must have a tag as the tag will identify them.

We can also hide a row by doing:

$0.hidden = true

as Condition conforms to ExpressibleByBooleanLiteral.

Not setting the hidden variable will leave the row always visible.

Sections

For sections this works just the same. That means we can set up section hidden property to show/hide it dynamically.

Disabling rows

To disable rows, each row has an disabled variable which is also an optional Condition type property. This variable also works the same as the hidden variable so that it requires the rows to have a tag.

Note that if you want to disable a row permanently you can also set disabled variable to true.

List Sections

To display a list of options, Eureka includes a special section called SelectableSection. When creating one you need to pass the type of row to use in the options and the selectionType. The selectionType is an enum which can be either multipleSelection or singleSelection(enableDeselection: Bool) where the enableDeselection parameter determines if the selected rows can be deselected or not.

form +++ SelectableSection<ListCheckRow<String>>("Where do you live", selectionType: .singleSelection(enableDeselection: true))

let continents = ["Africa", "Antarctica", "Asia", "Australia", "Europe", "North America", "South America"]
for option in continents {
    form.last! <<< ListCheckRow<String>(option){ listRow in
        listRow.title = option
        listRow.selectableValue = option
        listRow.value = nil
    }
}
What kind of rows can be used?

To create such a section you have to create a row that conforms the SelectableRowType protocol.

public protocol SelectableRowType : RowType {
    var selectableValue : Value? { get set }
}

This selectableValue is where the value of the row will be permanently stored. The value variable will be used to determine if the row is selected or not, being 'selectableValue' if selected or nil otherwise. Eureka includes the ListCheckRow which is used for example. In the custom rows of the Examples project you can also find the ImageCheckRow.

Getting the selected rows

To easily get the selected row/s of a SelectableSection there are two methods: selectedRow() and selectedRows() which can be called to get the selected row in case it is a SingleSelection section or all the selected rows if it is a MultipleSelection section.

Grouping options in sections

Additionally you can setup list of options to be grouped by sections using following properties of SelectorViewController:

  • sectionKeyForValue - a closure that should return key for particular row value. This key is later used to break options by sections.

  • sectionHeaderTitleForKey - a closure that returns header title for a section for particular key. By default returns the key itself.

  • sectionFooterTitleForKey - a closure that returns footer title for a section for particular key.

Multivalued Sections

Eureka supports multiple values for a certain field (such as telephone numbers in a contact) by using Multivalued sections. It allows us to easily create insertable, deletable and reorderable sections.

Screenshot of Multivalued Section

How to create a multivalued section

In order to create a multivalued section we have to use MultivaluedSection type instead of the regular Section type. MultivaluedSection extends Section and has some additional properties to configure multivalued section behavior.

let's dive into a code example...

form +++
    MultivaluedSection(multivaluedOptions: [.Reorder, .Insert, .Delete],
                       header: "Multivalued TextField",
                       footer: ".Insert adds a 'Add Item' (Add New Tag) button row as last cell.") {
        $0.addButtonProvider = { section in
            return ButtonRow(){
                $0.title = "Add New Tag"
            }
        }
        $0.multivaluedRowToInsertAt = { index in
            return NameRow() {
                $0.placeholder = "Tag Name"
            }
        }
        $0 <<< NameRow() {
            $0.placeholder = "Tag Name"
        }
    }

Previous code snippet shows how to create a multivalued section. In this case we want to insert, delete and reorder rows as multivaluedOptions argument indicates.

addButtonProvider allows us to customize the button row which inserts a new row when tapped and multivaluedOptions contains .Insert value.

multivaluedRowToInsertAt closure property is called by Eureka each time a new row needs to be inserted. In order to provide the row to add into multivalued section we should set this property. Eureka passes the index as closure parameter. Notice that we can return any kind of row, even custom rows, even though in most cases multivalued section rows are of the same type.

Eureka automatically adds a button row when we create a insertable multivalued section. We can customize how the this button row looks like as we explained before. showInsertIconInAddButton property indicates if plus button (insert style) should appear in the left of the button, true by default.

There are some considerations we need to have in mind when creating insertable sections. Any row added to the insertable multivalued section should be placed above the row that Eureka automatically adds to insert new rows. This can be easily achieved by adding these additional rows to the section from inside the section's initializer closure (last parameter of section initializer) so then Eureka adds the adds insert button at the end of the section.

Editing mode

By default Eureka will set the tableView's isEditing to true only if there is a MultivaluedSection in the form. This will be done in viewWillAppear the first time a form is presented.

For more information on how to use multivalued sections please take a look at Eureka example project which contains several usage examples.

Custom add button

If you want to use an add button which is not a ButtonRow then you can use GenericMultivaluedSection<AddButtonType>, where AddButtonType is the type of the row you want to use as add button. This is useful if you want to use a custom row to change the UI of the button.

Example:

GenericMultivaluedSection<LabelRow>(multivaluedOptions: [.Reorder, .Insert, .Delete], {
    $0.addButtonProvider = { section in
        return LabelRow(){
            $0.title = "A Label row as add button"
        }
    }
    // ...
}

Validations

Eureka 2.0.0 introduces the much requested built-in validations feature.

A row has a collection of Rules and a specific configuration that determines when validation rules should be evaluated.

There are some rules provided by default, but you can also create new ones on your own.

The provided rules are:

  • RuleRequired
  • RuleEmail
  • RuleURL
  • RuleGreaterThan, RuleGreaterOrEqualThan, RuleSmallerThan, RuleSmallerOrEqualThan
  • RuleMinLength, RuleMaxLength
  • RuleClosure

Let's see how to set up the validation rules.

override func viewDidLoad() {
        super.viewDidLoad()
        form
          +++ Section(header: "Required Rule", footer: "Options: Validates on change")

            <<< TextRow() {
                $0.title = "Required Rule"
                $0.add(rule: RuleRequired())

		// This could also have been achieved using a closure that returns nil if valid, or a ValidationError otherwise.
		/*
		let ruleRequiredViaClosure = RuleClosure<String> { rowValue in
		return (rowValue == nil || rowValue!.isEmpty) ? ValidationError(msg: "Field required!") : nil
		}
		$0.add(rule: ruleRequiredViaClosure)
		*/

                $0.validationOptions = .validatesOnChange
            }
            .cellUpdate { cell, row in
                if !row.isValid {
                    cell.titleLabel?.textColor = .systemRed
                }
            }

          +++ Section(header: "Email Rule, Required Rule", footer: "Options: Validates on change after blurred")

            <<< TextRow() {
                $0.title = "Email Rule"
                $0.add(rule: RuleRequired())
                $0.add(rule: RuleEmail())
                $0.validationOptions = .validatesOnChangeAfterBlurred
            }
            .cellUpdate { cell, row in
                if !row.isValid {
                    cell.titleLabel?.textColor = .systemRed
                }
            }

As you can see in the previous code snippet we can set up as many rules as we want in a row by invoking row's add(rule:) function.

Row also provides func remove(ruleWithIdentifier identifier: String) to remove a rule. In order to use it we must assign an id to the rule after creating it.

Sometimes the collection of rules we want to use on a row is the same we want to use on many other rows. In this case we can set up all validation rules using a RuleSet which is a collection of validation rules.

var rules = RuleSet<String>()
rules.add(rule: RuleRequired())
rules.add(rule: RuleEmail())

let row = TextRow() {
            $0.title = "Email Rule"
            $0.add(ruleSet: rules)
            $0.validationOptions = .validatesOnChangeAfterBlurred
        }

Eureka allows us to specify when validation rules should be evaluated. We can do it by setting up validationOptions row's property, which can have the following values:

  • .validatesOnChange - Validates whenever a row value changes.
  • .validatesOnBlur - (Default value) validates right after the cell resigns first responder. Not applicable for all rows.
  • .validatesOnChangeAfterBlurred - Validates whenever the row value changes after it resigns first responder for the first time.
  • .validatesOnDemand - We should manually validate the row or form by invoking validate() method.

If you want to validate the entire form (all the rows) you can manually invoke Form validate() method.

How to get validation errors

Each row has the validationErrors property that can be used to retrieve all validation errors. This property just holds the validation error list of the latest row validation execution, which means it doesn't evaluate the validation rules of the row.

Note on types

As expected, the Rules must use the same types as the Row object. Be extra careful to check the row type used. You might see a compiler error ("Incorrect arugment label in call (have 'rule:' expected 'ruleSet:')" that is not pointing to the problem when mixing types.

Swipe Actions

By using swipe actions we can define multiple leadingSwipe and trailingSwipe actions per row. As swipe actions depend on iOS system features, leadingSwipe is available on iOS 11.0+ only.

Let's see how to define swipe actions.

let row = TextRow() {
            let deleteAction = SwipeAction(
                style: .destructive,
                title: "Delete",
                handler: { (action, row, completionHandler) in
                    //add your code here.
                    //make sure you call the completionHandler once done.
                    completionHandler?(true)
                })
            deleteAction.image = UIImage(named: "icon-trash")

            $0.trailingSwipe.actions = [deleteAction]
            $0.trailingSwipe.performsFirstActionWithFullSwipe = true

            //please be aware: `leadingSwipe` is only available on iOS 11+ only
            let infoAction = SwipeAction(
                style: .normal,
                title: "Info",
                handler: { (action, row, completionHandler) in
                    //add your code here.
                    //make sure you call the completionHandler once done.
                    completionHandler?(true)
                })
            infoAction.actionBackgroundColor = .blue
            infoAction.image = UIImage(named: "icon-info")

            $0.leadingSwipe.actions = [infoAction]
            $0.leadingSwipe.performsFirstActionWithFullSwipe = true
        }

Swipe Actions need tableView.isEditing be set to false. Eureka will set this to true if there is a MultivaluedSection in the form (in the viewWillAppear). If you have both MultivaluedSections and swipe actions in the same form you should set isEditing according to your needs.

Custom rows

It is very common that you need a row that is different from those included in Eureka. If this is the case you will have to create your own row but this should not be difficult. You can read this tutorial on how to create custom rows to get started. You might also want to have a look at EurekaCommunity which includes some extra rows ready to be added to Eureka.

Basic custom rows

To create a row with custom behaviour and appearance you'll probably want to create subclasses of Row and Cell.

Remember that Row is the abstraction Eureka uses, while the Cell is the actual UITableViewCell in charge of the view. As the Row contains the Cell, both Row and Cell must be defined for the same value type.

// Custom Cell with value type: Bool
// The cell is defined using a .xib, so we can set outlets :)
public class CustomCell: Cell<Bool>, CellType {
    @IBOutlet weak var switchControl: UISwitch!
    @IBOutlet weak var label: UILabel!

    public override func setup() {
        super.setup()
        switchControl.addTarget(self, action: #selector(CustomCell.switchValueChanged), for: .valueChanged)
    }

    func switchValueChanged(){
        row.value = switchControl.on
        row.updateCell() // Re-draws the cell which calls 'update' bellow
    }

    public override func update() {
        super.update()
        backgroundColor = (row.value ?? false) ? .white : .black
    }
}

// The custom Row also has the cell: CustomCell and its correspond value
public final class CustomRow: Row<CustomCell>, RowType {
    required public init(tag: String?) {
        super.init(tag: tag)
        // We set the cellProvider to load the .xib corresponding to our cell
        cellProvider = CellProvider<CustomCell>(nibName: "CustomCell")
    }
}

The result:
Screenshot of Disabled Row


Custom rows need to subclass `Row` and conform to `RowType` protocol. Custom cells need to subclass `Cell` and conform to `CellType` protocol.

Just like the callbacks cellSetup and CellUpdate, the Cell has the setup and update methods where you can customize it.

Custom inline rows

An inline row is a specific type of row that shows dynamically a row below it, normally an inline row changes between an expanded and collapsed mode whenever the row is tapped.

So to create an inline row we need 2 rows, the row that is "always" visible and the row that will expand/collapse.

Another requirement is that the value type of these 2 rows must be the same. This means if one row holds a String value then the other must have a String value too.

Once we have these 2 rows, we should make the top row type conform to InlineRowType. This protocol requires you to define an InlineRow typealias and a setupInlineRow function. The InlineRow type will be the type of the row that will expand/collapse. Take this as an example:

class PickerInlineRow<T> : Row<PickerInlineCell<T>> where T: Equatable {

    public typealias InlineRow = PickerRow<T>
    open var options = [T]()

    required public init(tag: String?) {
        super.init(tag: tag)
    }

    public func setupInlineRow(_ inlineRow: InlineRow) {
        inlineRow.options = self.options
        inlineRow.displayValueFor = self.displayValueFor
        inlineRow.cell.height = { UITableViewAutomaticDimension }
    }
}

The InlineRowType will also add some methods to your inline row:

func expandInlineRow()
func collapseInlineRow()
func toggleInlineRow()

These methods should work fine but should you want to override them keep in mind that it is toggleInlineRow that has to call expandInlineRow and collapseInlineRow.

Finally you must invoke toggleInlineRow() when the row is selected, for example overriding customDidSelect:

public override func customDidSelect() {
    super.customDidSelect()
    if !isDisabled {
        toggleInlineRow()
    }
}

Custom Presenter rows

Note: A Presenter row is a row that presents a new UIViewController.

To create a custom Presenter row you must create a class that conforms the PresenterRowType protocol. It is highly recommended to subclass SelectorRow as it does conform to that protocol and adds other useful functionality.

The PresenterRowType protocol is defined as follows:

public protocol PresenterRowType: TypedRowType {

     associatedtype PresentedControllerType : UIViewController, TypedRowControllerType

     /// Defines how the view controller will be presented, pushed, etc.
     var presentationMode: PresentationMode<PresentedControllerType>? { get set }

     /// Will be called before the presentation occurs.
     var onPresentCallback: ((FormViewController, PresentedControllerType) -> Void)? { get set }
}

The onPresentCallback will be called when the row is about to present another view controller. This is done in the SelectorRow so if you do not subclass it you will have to call it yourself.

The presentationMode is what defines how the controller is presented and which controller is presented. This presentation can be using a Segue identifier, a segue class, presenting a controller modally or pushing to a specific view controller. For example a CustomPushRow can be defined like this:

Let's see an example..

/// Generic row type where a user must select a value among several options.
open class SelectorRow<Cell: CellType>: OptionsRow<Cell>, PresenterRowType where Cell: BaseCell {


    /// Defines how the view controller will be presented, pushed, etc.
    open var presentationMode: PresentationMode<SelectorViewController<SelectorRow<Cell>>>?

    /// Will be called before the presentation occurs.
    open var onPresentCallback: ((FormViewController, SelectorViewController<SelectorRow<Cell>>) -> Void)?

    required public init(tag: String?) {
        super.init(tag: tag)
    }

    /**
     Extends `didSelect` method
     */
    open override func customDidSelect() {
        super.customDidSelect()
        guard let presentationMode = presentationMode, !isDisabled else { return }
        if let controller = presentationMode.makeController() {
            controller.row = self
            controller.title = selectorTitle ?? controller.title
            onPresentCallback?(cell.formViewController()!, controller)
            presentationMode.present(controller, row: self, presentingController: self.cell.formViewController()!)
        } else {
            presentationMode.present(nil, row: self, presentingController: self.cell.formViewController()!)
        }
    }

    /**
     Prepares the pushed row setting its title and completion callback.
     */
    open override func prepare(for segue: UIStoryboardSegue) {
        super.prepare(for: segue)
        guard let rowVC = segue.destination as Any as? SelectorViewController<SelectorRow<Cell>> else { return }
        rowVC.title = selectorTitle ?? rowVC.title
        rowVC.onDismissCallback = presentationMode?.onDismissCallback ?? rowVC.onDismissCallback
        onPresentCallback?(cell.formViewController()!, rowVC)
        rowVC.row = self
    }
}


// SelectorRow conforms to PresenterRowType
public final class CustomPushRow<T: Equatable>: SelectorRow<PushSelectorCell<T>>, RowType {

    public required init(tag: String?) {
        super.init(tag: tag)
        presentationMode = .show(controllerProvider: ControllerProvider.callback {
            return SelectorViewController<T>(){ _ in }
            }, onDismiss: { vc in
                _ = vc.navigationController?.popViewController(animated: true)
        })
    }
}

Subclassing cells using the same row

Sometimes we want to change the UI look of one of our rows but without changing the row type and all the logic associated to one row. There is currently one way to do this if you are using cells that are instantiated from nib files. Currently, none of Eureka's core rows are instantiated from nib files but some of the custom rows in EurekaCommunity are, in particular the PostalAddressRow which was moved there.

What you have to do is:

  • Create a nib file containing the cell you want to create.
  • Then set the class of the cell to be the existing cell you want to modify (if you want to change something more apart from pure UI then you should subclass that cell). Make sure the module of that class is correctly set
  • Connect the outlets to your class
  • Tell your row to use the new nib file. This is done by setting the cellProvider variable to use this nib. You should do this in the initialiser, either in each concrete instantiation or using the defaultRowInitializer. For example:
<<< PostalAddressRow() {
     $0.cellProvider = CellProvider<PostalAddressCell>(nibName: "CustomNib", bundle: Bundle.main)
}

You could also create a new row for this. In that case try to inherit from the same superclass as the row you want to change to inherit its logic.

There are some things to consider when you do this:

  • If you want to see an example have a look at the PostalAddressRow or the CreditCardRow which have use a custom nib file in their examples.
  • If you get an error saying Unknown class <YOUR_CLASS_NAME> in Interface Builder file, it might be that you have to instantiate that new type somewhere in your code to load it in the runtime. Calling let t = YourClass.self helped in my case.

Row catalog

Controls Rows

Label Row


Button Row


Check Row


Switch Row


Slider Row


Stepper Row


Text Area Row


Field Rows

These rows have a textfield on the right side of the cell. The difference between each one of them consists in a different capitalization, autocorrection and keyboard type configuration.

TextRow

NameRow

URLRow

IntRow

PhoneRow

PasswordRow

EmailRow

DecimalRow

TwitterRow

AccountRow

ZipCodeRow

All of the FieldRow subtypes above have a formatter property of type NSFormatter which can be set to determine how that row's value should be displayed. A custom formatter for numbers with two digits after the decimal mark is included with Eureka (DecimalFormatter). The Example project also contains a CurrencyFormatter which displays a number as currency according to the user's locale.

By default, setting a row's formatter only affects how a value is displayed when it is not being edited. To also format the value while the row is being edited, set useFormatterDuringInput to true when initializing the row. Formatting the value as it is being edited may require updating the cursor position and Eureka provides the following protocol that your formatter should conform to in order to handle cursor position:

public protocol FormatterProtocol {
    func getNewPosition(forPosition forPosition: UITextPosition, inTextInput textInput: UITextInput, oldValue: String?, newValue: String?) -> UITextPosition
}

Additionally, FieldRow subtypes have a useFormatterOnDidBeginEditing property. When using a DecimalRow with a formatter that allows decimal values and conforms to the user's locale (e.g. DecimalFormatter), if useFormatterDuringInput is false, useFormatterOnDidBeginEditing must be set to true so that the decimal mark in the value being edited matches the decimal mark on the keyboard.

Date Rows

Date Rows hold a Date and allow us to set up a new value through UIDatePicker control. The mode of the UIDatePicker and the way how the date picker view is shown is what changes between them.

Date Row
Picker shown in the keyboard.
Date Row (Inline)
The row expands.
Date Row (Picker)
The picker is always visible.

With those 3 styles (Normal, Inline & Picker), Eureka includes:

  • DateRow
  • TimeRow
  • DateTimeRow
  • CountDownRow

Option Rows

These are rows with a list of options associated from which the user must choose.

<<< ActionSheetRow<String>() {
                $0.title = "ActionSheetRow"
                $0.selectorTitle = "Pick a number"
                $0.options = ["One","Two","Three"]
                $0.value = "Two"    // initially selected
            }
Alert Row

Will show an alert with the options to choose from.
ActionSheet Row

Will show an action sheet with the options to choose from.
Push Row

Will push to a new controller from where to choose options listed using Check rows.
Multiple Selector Row

Like PushRow but allows the selection of multiple options.
Segmented Row
Segmented Row (w/Title)
Picker Row

Presents options of a generic type through a picker view
(There is also Picker Inline Row)

Built your own custom row?

Let us know about it, we would be glad to mention it here. :)

  • LocationRow (Included as custom row in the example project)

Screenshot of Location Row

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

Specify Eureka into your project's Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

pod 'Eureka'

Then run the following command:

$ pod install

Swift Package Manager

Swift Package Manager is a tool for managing the distribution of Swift code.

After you set up your Package.swift manifest file, you can add Eureka as a dependency by adding it to the dependencies value of your Package.swift.

dependencies: [ .package(url: "https://github.com/xmartlabs/Eureka.git", from: "5.3.3") ]

Carthage

Carthage is a simple, decentralized dependency manager for Cocoa.

Specify Eureka into your project's Cartfile:

github "xmartlabs/Eureka" ~> 5.3

Manually as Embedded Framework

  • Clone Eureka as a git submodule by running the following command from your project root git folder.
$ git submodule add https://github.com/xmartlabs/Eureka.git
  • Open Eureka folder that was created by the previous git submodule command and drag the Eureka.xcodeproj into the Project Navigator of your application's Xcode project.

  • Select the Eureka.xcodeproj in the Project Navigator and verify the deployment target matches with your application deployment target.

  • Select your project in the Xcode Navigation and then select your application target from the sidebar. Next select the "General" tab and click on the + button under the "Embedded Binaries" section.

  • Select Eureka.framework and we are done!

Getting involved

  • If you want to contribute please feel free to submit pull requests.
  • If you have a feature request please open an issue.
  • If you found a bug check older issues before submitting an issue.
  • If you need help or would like to ask general question, use StackOverflow. (Tag eureka-forms).

Before contribute check the CONTRIBUTING file for more info.

If you use Eureka in your app We would love to hear about it! Drop us a line on twitter.

Authors

FAQ

How to change the text representation of the row value shown in the cell.

Every row has the following property:

/// Block variable used to get the String that should be displayed for the value of this row.
public var displayValueFor: ((T?) -> String?)? = {
    return $0.map { String(describing: $0) }
}

You can set displayValueFor according the string value you want to display.

How to get a Row using its tag value

We can get a particular row by invoking any of the following functions exposed by the Form class:

public func rowBy<T: Equatable>(tag: String) -> RowOf<T>?
public func rowBy<Row: RowType>(tag: String) -> Row?
public func rowBy(tag: String) -> BaseRow?

For instance:

let dateRow : DateRow? = form.rowBy(tag: "dateRowTag")
let labelRow: LabelRow? = form.rowBy(tag: "labelRowTag")

let dateRow2: Row<DateCell>? = form.rowBy(tag: "dateRowTag")

let labelRow2: BaseRow? = form.rowBy(tag: "labelRowTag")

How to get a Section using its tag value

let section: Section?  = form.sectionBy(tag: "sectionTag")

How to set the form values using a dictionary

Invoking setValues(values: [String: Any?]) which is exposed by Form class.

For example:

form.setValues(["IntRowTag": 8, "TextRowTag": "Hello world!", "PushRowTag": Company(name:"Xmartlabs")])

Where "IntRowTag", "TextRowTag", "PushRowTag" are row tags (each one uniquely identifies a row) and 8, "Hello world!", Company(name:"Xmartlabs") are the corresponding row value to assign.

The value type of a row must match with the value type of the corresponding dictionary value otherwise nil will be assigned.

If the form was already displayed we have to reload the visible rows either by reloading the table view tableView.reloadData() or invoking updateCell() to each visible row.

Row does not update after changing hidden or disabled condition

After setting a condition, this condition is not automatically evaluated. If you want it to do so immediately you can call .evaluateHidden() or .evaluateDisabled().

This functions are just called when a row is added to the form and when a row it depends on changes. If the condition is changed when the row is being displayed then it must be reevaluated manually.

onCellUnHighlight doesn't get called unless onCellHighlight is also defined

Look at this issue.

How to update a Section header/footer

  • Set up a new header/footer data ....
section.header = HeaderFooterView(title: "Header title \(variable)") // use String interpolation
//or
var header = HeaderFooterView<UIView>(.class) // most flexible way to set up a header using any view type
header.height = { 60 }  // height can be calculated
header.onSetupView = { view, section in  // each time the view is about to be displayed onSetupView is invoked.
    view.backgroundColor = .orange
}
section.header = header
  • Reload the Section to perform the changes
section.reload()

How to customize Selector and MultipleSelector option cells

selectableRowSetup, selectableRowCellUpdate and selectableRowCellSetup properties are provided to be able to customize SelectorViewController and MultipleSelectorViewController selectable cells.

let row = PushRow<Emoji>() {
              $0.title = "PushRow"
              $0.options = [💁🏻, 🍐, 👦🏼, 🐗, 🐼, 🐻]
              $0.value = 👦🏼
              $0.selectorTitle = "Choose an Emoji!"
          }.onPresent { from, to in
              to.dismissOnSelection = false
              to.dismissOnChange = false
              to.selectableRowSetup = { row in
                  row.cellProvider = CellProvider<ListCheckCell<Emoji>>(nibName: "EmojiCell", bundle: Bundle.main)
              }
              to.selectableRowCellUpdate = { cell, row in
                  cell.textLabel?.text = "Text " + row.selectableValue!  // customization
                  cell.detailTextLabel?.text = "Detail " +  row.selectableValue!
              }
          }

Don't want to use Eureka custom operators?

As we've said Form and Section types conform to MutableCollection and RangeReplaceableCollection. A Form is a collection of Sections and a Section is a collection of Rows.

RangeReplaceableCollection protocol extension provides many useful methods to modify collection.

extension RangeReplaceableCollection {
    public mutating func append(_ newElement: Self.Element)
    public mutating func append<S>(contentsOf newElements: S) where S : Sequence, Self.Element == S.Element
    public mutating func insert(_ newElement: Self.Element, at i: Self.Index)
    public mutating func insert<S>(contentsOf newElements: S, at i: Self.Index) where S : Collection, Self.Element == S.Element
    public mutating func remove(at i: Self.Index) -> Self.Element
    public mutating func removeSubrange(_ bounds: Range<Self.Index>)
    public mutating func removeFirst(_ n: Int)
    public mutating func removeFirst() -> Self.Element
    public mutating func removeAll(keepingCapacity keepCapacity: Bool)
    public mutating func reserveCapacity(_ n: Self.IndexDistance)
}

These methods are used internally to implement the custom operators as shown bellow:

public func +++(left: Form, right: Section) -> Form {
    left.append(right)
    return left
}

public func +=<C : Collection>(inout lhs: Form, rhs: C) where C.Element == Section {
    lhs.append(contentsOf: rhs)
}

public func <<<(left: Section, right: BaseRow) -> Section {
    left.append(right)
    return left
}

public func +=<C : Collection>(inout lhs: Section, rhs: C) where C.Element == BaseRow {
    lhs.append(contentsOf: rhs)
}

You can see how the rest of custom operators are implemented here.

It's up to you to decide if you want to use Eureka custom operators or not.

How to set up your form from a storyboard

The form is always displayed in a UITableView. You can set up your view controller in a storyboard and add a UITableView where you want it to be and then connect the outlet to FormViewController's tableView variable. This allows you to define a custom frame (possibly with constraints) for your form.

All of this can also be done by programmatically changing frame, margins, etc. of the tableView of your FormViewController.

Donate to Eureka

So we can make Eureka even better!

Change Log

This can be found in the CHANGELOG.md file.

Comments
  • Does not work on Xcode 8 / Swift 3

    Does not work on Xcode 8 / Swift 3

    Xcode 8 Swift 3

    I am trying to use this framework on a new project. I installed it with cocoapods but it does not work after I convert the syntax to Swift 3.

    Any ideas on how can I deal with this? or are you guys updating the framework to support Swift 3?

    Thanks.

    type: awaiting response swift 3.0 
    opened by JorgeAGomez 50
  • Thread 1: EXC_BAD_ACCESS (code=2, address=0x16b7eff30) - in function Cell.update()

    Thread 1: EXC_BAD_ACCESS (code=2, address=0x16b7eff30) - in function Cell.update()

    The combination Xcode 9.3 beta 3 and Eureka 4.1.0 is not working properly on my physical iPhone X device with iOS 11.3 beta 3. The simulator (for iPhone X) is working fine however.

    I'm getting an error Thread 1: EXC_BAD_ACCESS (code=2, address=0x16b7eff30) when I click on a Pushrow. A Textrow or Daterow does work normally.

    The branch with the latest beta was working fine, so I tried to go back. But that is not working any more:

    [!] Error installing Eureka [!] Failed to download 'Eureka'

    type: issue help wanted difficulty: moderate 
    opened by arakweker 44
  • Segmentation Fault: 11 when build with Xcode 12

    Segmentation Fault: 11 when build with Xcode 12

    When building my project with Xcode 12, Eureka fails to build with a Segmentation Fault: 11 error. The error log begings like this:

    1.	Apple Swift version 5.3 (swiftlang-1200.0.16.13 clang-1200.0.22.25)
    2.	While evaluating request TypeCheckSourceFileRequest(source_file "<omitted>/Pods/Eureka/Source/Core/SelectableSection.swift")
    3.	While evaluating request TypeCheckFunctionBodyUntilRequest(Eureka.(file).SelectableSectionType extension.selectedRows()@<omitted>/Pods/Eureka/Source/Core/SelectableSection.swift:76:17, )
    4.	While type-checking statement at [<omitted>/Pods/Eureka/Source/Core/SelectableSection.swift:76:51 - line:79:5] RangeText="{
            let selectedRows: [BaseRow] = self.filter { $0 is SelectableRow && $0.baseValue != nil }
            return selectedRows.map { $0 as! SelectableRow }
        "
    5.	While type-checking declaration 0x7fd43d09ab50 (at <omitted>/Pods/Eureka/Source/Core/SelectableSection.swift:77:9)
    6.	While type-checking expression at [<omitted>/Pods/Eureka/Source/Core/SelectableSection.swift:77:39 - line:77:96] RangeText="self.filter { $0 is SelectableRow && $0.baseValue != nil "
    

    Seems llvm is having trouble understanding this part in SelectableSection.swift:

         /**
         Returns the selected rows of this section. Should be used if selectionType is MultipleSelection
         */
        public func selectedRows() -> [SelectableRow] {
            let selectedRows: [BaseRow] = self.filter { $0 is SelectableRow && $0.baseValue != nil }
            return selectedRows.map { $0 as! SelectableRow }
        }
    

    I tried rewrite it with compactMap or if let but no luck.

    Did anyone succeed building Eureka with Xcode 12? Thanks!

    Environment: Eureka 5.2.1 Xcode 12 beta 2 macOS 10.15.5

    Swift compiler issue 
    opened by xiao99xiao 42
  • xCode13 CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler

    xCode13 CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler

    Hello, just ran into this with SPM :

    https://developer.apple.com/documentation/Xcode-Release-Notes/xcode-13-release-notes

    Swift libraries depending on Combine may fail to build for targets including armv7 and i386 architectures. (82183186, 82189214)

    Workaround: Use an updated version of the library that isn’t impacted (if available) or remove armv7 and i386 support

    CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'Eureka' from project 'Eureka')

    opened by PierreBrisorgueil 33
  • Eureka is not compiling in Xcode 9.3

    Eureka is not compiling in Xcode 9.3

    Environment:

    • Xcode Version 9.3 (9E145)
    • Swift Language Version = 4.1 (is set for Eureka framework target build settings in Xcode)

    Eureka is installed with cocoapods with pod 'Eureka' and pod update

    While installing log says Using Eureka (3.0.0)

    When try to compile I got

    'Sequence' requires the types '[BaseRow]' and 'ArraySlice<B

    and

    Type 'Section' does not conform to protocol 'RangeReplaceableCollection'

    as well as suggestion to

    Add '@ objc' to expose this instance method to Objective-C

    opened by moonvader 29
  • Any plans to upgrade the code to Swift 3?

    Any plans to upgrade the code to Swift 3?

    Tried to convert to swift 3 using the XCode 8 converter but I'm still getting alot of errors that wont go away. Any plans to have an official Swift 3 upgrade?

    swift 3.0 
    opened by iamlogiq 28
  • Form data validation

    Form data validation

    Hi, is there any way of validating the data of the rows like the validations in XLForm?

    It would be nice to e.g. only activate a specific ButtonRow if the whole form is valid and this depends upon the validations of each row (e.g. row 1,2 and 3 must not be empty)

    type: feature request type: discussion Validations 
    opened by ffittschen 24
  • validationErrors property not reset

    validationErrors property not reset

    • Environment: Eureka: 4.0.1, Xcode: 9.2 and iOS: 10 for deployment target
    • Issue: When navigating from segment to segment the previous segments errors persist.
    • Excepted behavior: Upon switching segments the validationErrors property should not persist. Code can be found here: https://github.com/TrustWallet/trust-wallet-ios/blob/master/Trust/Wallet/ViewControllers/ImportWalletViewController.swift#L86
    opened by MillerApps 22
  • What about adding Swift Package Manager support?

    What about adding Swift Package Manager support?

    Xcode 11 allows adding swift packages very easily. Have you thought about adding SPM support to Eureka? I could not find any old discussion about this here, therefore I would like to start one!

    I personally would love to use Eureka via swift package manager. It does not support assets though. However as far as I can tell this should not be an issue for Eureka.

    type: discussion 
    opened by funkenstrahlen 19
  • Swipeable

    Swipeable "Actions" for Eureka rows?

    Will there be a Swipeable actions present in Eureka? It would be cool to have something like the following:

    <<< DateInlineRow("DateInlineRow"){
        $0.title = $0.tag
        $0.rowActionsRight = [ RowAction("Delete",
            action: { ... },
            condition: Condition.Function(...)),
            ... ]
        $0.rowActionsLeft = [ ... ]
    }
    
    type: feature request type: discussion 
    opened by marbetschar 18
  • SelectorRow documentation is corrupt

    SelectorRow documentation is corrupt

    How to develop a Custom Presenter row in Eureka 4.x? The offocial documentation is still

    public final class CustomPushRow<T: Equatable>: SelectorRow<PushSelectorCell, SelectorViewController>, RowType {

        public required init(tag: String?) {
            super.init(tag: tag)
            presentationMode = .show(controllerProvider: ControllerProvider.callback {
                return SelectorViewController<T>(){ _ in }
                }, onDismiss: { vc in
                    _ = vc.navigationController?.popViewController(animated: true)
            })
        }
    }
    

    but this couldn't get compiled.

    documentation 
    opened by fhchina 16
  • SegmentedRow crash due to selectedSegmentIndex == -1

    SegmentedRow crash due to selectedSegmentIndex == -1

    When selecting different Section Segments sometimes my app crashes due to segmentedControl.selectedSegmentIndex (within class SegmentedCell) returning a "-1" instead of legitimate value that is >=0

    Existing Eureka code: @objc (segmentedValueDidChange) func valueChanged() { row.value = (row as! OptionsRow).options?[segmentedControl.selectedSegmentIndex] }

    Hack I'm using to avoid the crash: @objc (segmentedValueDidChange) func valueChanged() { if segmentedControl.selectedSegmentIndex == -1 { segmentedControl.selectedSegmentIndex = 0 } row.value = (row as! OptionsRow).options?[segmentedControl.selectedSegmentIndex] }

    type: issue row: SegmentedRow 
    opened by mikeymike9000 9
  • Section custom header with xib file+class

    Section custom header with xib file+class

    Describe the bug I wish to re-use a custom class with a xib file in a section with some rows added dynamically, but when I use the following code

    var section = Section() { section in
          section.tag = v
          var header = HeaderFooterView<EKHeaderClass>(.nibFile(name: "EKHeader", bundle: nil))
          header.height = { 25 }
          header.onSetupView = { view, _ in
            view.titleLabel.text = "My title"
            view.subTitleLabel.isHidden = "My subtitle"
          }
         section.header = header
    }
    
    section.insert(contentsOf: [rowA, rowB], at: 0)
    form.insert(section, at: mealParts.count)
    

    I see that the xib view and its class gets instantiated but it disappear immediately; if I keep adding more of the same to have a very long table/form and i start to scroll, the headers reappear without problems. On the contrary, if I use a simple view class, I have no problems and I see the header being attach and never disappear. Does anyone knows how to fix this?

    Thanks 1k

    Versions (please complete the following information):

    • Device: iPhone 12
    • OS: 15.0
    • Eureka Version 5.4.0
    • Xcode version 14.1
    opened by DigitalVanilla 9
  • SegmentControl animates when changing userInterfaceStyle

    SegmentControl animates when changing userInterfaceStyle

    Describe the bug On selection of new segment, i change userInterfaceStyle in animated block. During this labels of the segmentControl, also animate. How to fix this?

    Thanks.

    To Reproduce

    	<<< SegmentedRow<String>() {
    						
    			$0.title = "Select theme"
    			$0.options = ["System", "Light", "Dark"]
    
    			let currentInterfaceStyle = self.userDefaults.string(forKey: "currentUserInterfaceStyle")
    						
    			switch currentInterfaceStyle {
    				case "light":
    					$0.value = "Light"
    				case "dark":
    					$0.value = "Dark"
    				default:
    					$0.value = "System"
    			}
    						
    		}.cellSetup { cell, row in
    			cell.textLabel?.textColor = Constants.ColorCompatibility.label
    			cell.textLabel?.font = UIFont.boldSystemFont(ofSize: 14)
    			cell.segmentedControl.selectedSegmentTintColor = Constants.ColorCompatibility.globalTintColor
    		}.onChange({ (row) in
    
    			let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
    					
    				UIView.animate(withDuration: 0.4) {
    
    					switch row.value {
    								
    						case "Dark":
    							window?.overrideUserInterfaceStyle = UIUserInterfaceStyle.dark
    							self.userDefaults.set("dark", forKey: "currentUserInterfaceStyle")
    
    						case "Light":
    							window?.overrideUserInterfaceStyle = UIUserInterfaceStyle.light
    							self.userDefaults.set("light", forKey: "currentUserInterfaceStyle")
    								
    						case "System":
    							window?.overrideUserInterfaceStyle = UIUserInterfaceStyle.unspecified
    							self.userDefaults.set("system", forKey: "currentUserInterfaceStyle")
    
    						default:
    							window?.overrideUserInterfaceStyle = UIUserInterfaceStyle.unspecified
    							self.userDefaults.set("system", forKey: "currentUserInterfaceStyle")
    					}
    				}
    				self.userDefaults.synchronize()
    						
    						
    		})
    
    

    Expected behavior Segment control labels should not animate Screenshots If applicable, add screenshots to help explain your problem.

    Versions (please complete the following information):

    • Device: iPhone 12 simulator/Iphone 11 device
    • OS: iOS 15.0
    • Eureka Version 5.3.4
    • Xcode version 13.3 segment control anination
    opened by ashish-naik 10
  • MeasurementFormatter not support

    MeasurementFormatter not support

    let numberFormatter = MeasurementFormatter()
    let km = Measurement<UnitLength>(value: 2000, unit: .kilometers)
    formatter = numberFormatter
    

    its will crash

    type: feature request 
    opened by miaoruiyuan 2
Releases(5.4.0)
  • 5.4.0(Sep 30, 2022)

    • Renamed several methods that clashed with private Obj-C methods and triggered warnings when uploading to App Store (#2231)
    • Other minor fixes (#2220, #2222)
    Source code(tar.gz)
    Source code(zip)
  • 5.3.6(Apr 26, 2022)

  • 5.3.5(Mar 1, 2022)

    Several fixes included in this releases:

    • Fix a compiler error in Xcode 13 (#2162)
    • Change CI to GitHub Actions and remove Travis (#2185)
    • Fix crash when user taps tab key on external keyboard (#2205)
    • Other minor fixes (#2191, #2206, #2183)
    Source code(tar.gz)
    Source code(zip)
  • 5.3.4(Oct 6, 2021)

    • Resolve class protocol inheritance warnings (#2151)
    • Fix Chinese input issue (#2150)
    • Specific special characters are allowed in the username of an email address (#2160)
    • Fix SliderRow not rendering properly (#2166)
    Source code(tar.gz)
    Source code(zip)
  • 5.3.3(Mar 11, 2021)

    • Add option for different ScrollPosition behavior on keyboard appearance (#2112)
    • Prefix Eureka to certain class names to avoid clashes with other pods (#2113)
    • Remove the default header title of section (#2128)
    • Modify hugging priority for PasswordRow (#2129)
    • Add replace method for all sections (#2105)
    • Fix: Non-public API usage (valueChanged, datePickerValueChanged) (#2130)
    • Fix: remove EXCLUDED_ARCHS build setting to support M1 mac iphone simulator (#2137)
    • Fix: removeAll method in sections (#2141)
    Source code(tar.gz)
    Source code(zip)
  • 5.3.2(Nov 2, 2020)

    • Make tableViewStyle public (#2092)
    • Fix CountDown rows crash (#2095)
    • Make ValidationRuleHelper's rule property public. (#2101)
    • Fix for building with Carthage and Xcode 12 (#2104)
    Source code(tar.gz)
    Source code(zip)
  • 5.3.1(Sep 29, 2020)

    • Fix building for Mac Catalyst on Xcode 12 (#2078)
    • Fix datePickerStyle for DateFieldRow and DatePickerCell (#2077)
    • Adjust font size of PasswordRow to avoid dots (#2080)
    Source code(tar.gz)
    Source code(zip)
  • 5.3.0(Sep 15, 2020)

    • Reload rows on viewWillAppear for iOS 12 and below. (#2029)
    • Change validation functions access level to open (#2049)
    • Start editing field rows at the end when tapping blank space in row (#2046)
    • Update SelectorViewController.swift (#2062)
    • Fix subtitle field row constraints (#2069)
    • Create a workaround for Swift crash (#2057, #2061)
    • Fix date row style/rendering issues for iOS14 (#2067)
    Source code(tar.gz)
    Source code(zip)
  • 5.2.1(Mar 25, 2020)

    This version includes these changes:

    • Mark tableView:editActionsForRowAt as deprecated (#2000)
    • Removes unwanted assertionFailure Core.swift Navigation (#1998)
    • Fix for crash in iOS 13.4 with Xcode 11.4 (#2008)
    Source code(tar.gz)
    Source code(zip)
  • 5.2.0(Jan 27, 2020)

    This version includes the following changes:

    • Support for Swift Package Manager (#1976)
    • Add GenericMultivaluedSection to allow changing add button (#1843)
    • Remove InputTypeInitiable constraint for PickerInputRow (#1975)
    • Fix: avoid reloading rows in viewWillAppear when tableView is not added to window (#1971)
    • Fix optional header and footer in SelectorViewController. (#1962)
    • Fix table view contentInset adjustment with safe area when keyboard shows (#1960)
    • Fix for iOS 13 that was not removing the row automatically anymore even after calling the completion handler in a destructive swipe action (#1944)
    • Fixed reference cycle (#1930)
    • Allows a section's header and footer to be nil (#1927)
    Source code(tar.gz)
    Source code(zip)
  • 5.1.0(Oct 2, 2019)

  • 5.0.1(Sep 11, 2019)

    • Added quietly parameter for use with non-ui validation (#1817)
    • RuleMinLength (and others) now pass for nil and empty strings.
    • iOS deployment target back on iOS 9.0
    • Several other fixes
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0(Apr 1, 2019)

  • 4.3.1(Dec 19, 2018)

  • 4.3.0(Sep 21, 2018)

    • Changes for Swift 4.2, Xcode 10 and iOS 12
    • Add ability to customise the text color of UIPickerView used by PickerRow
    • Make onPresent result discardable
    • Add insert(row: after:) method on Section which allows inserting rows after a hidden row
    • Other minor fixes
    Source code(tar.gz)
    Source code(zip)
  • 4.2.0(Jun 28, 2018)

    • Adding support for RowType.subtitle on FieldRow (#1468)
    • CompletionHandler for SwipeAction under iOS < 11
    • Allow setting position of the cell after scrolling (#1452)
    • Add Chinese readme (#1487)
    • Implement readOnly textAreaRow feature (#1489)
    • Update cell when tintColor changes (#1492)
    • PickerRow for 2 and 3 components (#1540)
    • And several bug fixes
    Source code(tar.gz)
    Source code(zip)
  • 4.1.1(Mar 16, 2018)

  • 4.1.0(Mar 1, 2018)

    • Add compatibility for Xcode 9.3 beta 2 and Swift 4.1.
    • New functionality 🎉. https://github.com/xmartlabs/eureka#swipe-actions. Thanks @marbetschar.
    • Add sectionIndexTitles and sectionForSectionIndexTitles to FormViewController to allow for subclasses to override.
    • Fix SliderRow layout.
    • Fix regular expression for URLs to allow query and location parameter.
    • Corrected issue in section sorting function of MultipleSelectorViewController, where all options were placed in one section, with a section title based on the first option.
    • Added missing call to super.updateConstraints in SegmentedCell.
    • Add ability to setup alert cancel title from AlertRow.
    • remove blank section headers/footers from plain tables on iOS 11. This prevents blank section headers and footers from appearing on iOS 11 when setting the table view style to plain and there are no headers or footers.
    • Fix UIDatePicker bug when mode == .countDownTimer.
    • Allow non-selectable rows to exist besides selectable rows in a selectable section.
    • SliderRow - added option 'shouldHideValue' to hide value label (default to false).
    • Update cell when tintColor changes.
    • Support dynamic font size changes.
    Source code(tar.gz)
    Source code(zip)
  • 4.0.1(Oct 6, 2017)

  • 3.0.0(Apr 17, 2017)

  • 2.0.1(Feb 15, 2017)

  • 2.0.0-beta.1(Sep 26, 2016)

  • 1.7.0(Jul 7, 2016)

    • Breaking change: Fixed typo in hightlightCell. You must now call / override highlightCell.
    • Added allSections method to Form. (by @programmarchy)
    • Updated navigation images for row navigation. (thanks @VladislavJevremovic)
    • Removed +++= operator.
    • Other bug fixes and minor improvements
    Source code(tar.gz)
    Source code(zip)
  • 1.6.0(May 26, 2016)

    • Breaking change: Remove controller: FormViewController parameter from HeaderFooterViewRepresentable viewForSection method.
    • Support for Xcode 7.3.1.
    • Fixed ImageRow issue when trying to access imageURL after selecting image. Now imageURL is properly set up. #346
    • Made FieldRowConformance protocol public.
    • Added ability to override TextAreaRow constraints.
    • Fix. Now section headerView/footerView cache is deleted whenever section header/footer is assigned.
    • Made public navigateToDirection(direction: Direction) method.
    • Fixed autolayout in cells. #396
    • Removed cell.setNeedsLayout() and cell.setNeedsUpdateConstraints() from updateCell process.
    • Added ButtonRow onCellSelecttion example.
    • Improve row deselection behavior during interactive transitions. #406
    • Autosize TextAreaRow functionality added.
    • Moved inputAccessoryViewForRow method from extension to FormViewController allowing it to be overridden.
    • Added ability to show a text when there is no value selected to some rows.
    • Fixed: The top divider of a PickerInlineRow disappears upon selection.
    • Fixed crash when selecting a date. DatePickerRow.
    • Ensure inline row is visible when it’s expanded.
    • Fixed PostalAddressRow - When a long form is scrolled up/down, values in Address box disappears.

    Thanks to all contributors!! 🚀🚀

    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Mar 22, 2016)

    • Xcode 7.3 support.
    • Expose a public KeyboardReturnTypeConfiguration initializer.
    • Allow to override constraints of FieldRow.
    • Fixed SelectableSection wrong behaviour when the selectable rows was added to the section before adding the selectable section to the form.
    • Implemented StepperRow and added an example to the example project.
    • Allow AlertRow cancel title to be changed.
    • Enabled CI UI testing and added some tests.
    • Fixed "0 after decimal separator (DecimalRow)"
    • Added ability to customize selector and multiple selector view controller option rows. Added selectableRowCellUpdate property to SelectorViewController and MultipleSelectorViewController.
    • Performance improvement. Store values for each tag in a dictionary and do not calculate it every time we evaluateHidden.

    Thanks to all contributors!! 🍻🍻

    Source code(tar.gz)
    Source code(zip)
  • 1.4.1(Feb 25, 2016)

    • SelectorRow now requires the cell among its generic values. This means it is easier to change the cell for a selector row.
    • _AlertRow and _ActionSheetRow require generic cell parameter

    If you are using custom rows that inherit from SelectorRow then you might want to change them as follows (or use your custom cell):

    // before
    // public final class LocationRow : SelectorRow<CLLocation, MapViewController>, RowType
    
    // now
    public final class LocationRow : SelectorRow<CLLocation, MapViewController, PushSelectorCell<CLLocation>>, RowType
    
    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Feb 25, 2016)

    • PopoverSelectorRow added.
    • BaseRow reload, select, deselect helpers added.
    • ImageRow update: allows clear button, image sources are public
    • Added PostalAddressRow
    • Lots of smaller bug fixes and new documentation
    Breaking Changes
    • BaseCellType protocol method func cellBecomeFirstResponder() -> Bool was renamed to func cellBecomeFirstResponder(direction: Direction) -> Bool

    If you are using custom rows you may have to fix the compiler error by adding the new parameter.

    • DecimalRow value type changed from Float to Double.
    Source code(tar.gz)
    Source code(zip)
  • 1.3.1(Jan 11, 2016)

Custom Field component with validation for creating easier form-like UI from interface builder.

#YALField Custom Field component with validation for creating easier form-like UI from interface builder. ##Example Project To run the example project

Yalantis 476 Sep 1, 2022
The most flexible and powerful way to build a form on iOS

The most flexible and powerful way to build a form on iOS. Form came out from our need to have a form that could share logic between our iOS apps and

HyperRedink 32 Aug 15, 2022
Declarative form building framework for iOS

Formalist Swift framework for building forms on iOS Formalist is a Swift framework for building forms on iOS using a simple, declarative, and readable

Seed 159 May 25, 2022
iOS validation framework with form validation support

ATGValidator ATGValidator is a validation framework written to address most common issues faced while verifying user input data. You can use it to val

null 51 Oct 19, 2022
APValidators - Codeless solution for form validation in iOS!

APValidators is a codeless solution for form validation. Just connect everything right in Interface Builder and you're done. Supports really complex and extendable forms by allowing to connect validators in tree.

Alty 131 Aug 16, 2022
Former is a fully customizable Swift library for easy creating UITableView based form.

Former is a fully customizable Swift library for easy creating UITableView based form. Submitting Issues Click HERE to get started with filing a bug r

Ryo Aoyama 1.3k Dec 27, 2022
ObjectForm - a simple yet powerful library to build form for your class models.

ObjectForm A simple yet powerful library to build form for your class models. Motivations I found most form libraries for swift are too complicated to

jakehao 175 Nov 2, 2022
Some cells to Form a Pod

CellsGao Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation CellsGao

null 0 Nov 2, 2021
XLForm is the most flexible and powerful iOS library to create dynamic table-view forms. Fully compatible with Swift & Obj-C.

XLForm By XMARTLABS. If you are working in Swift then you should have a look at Eureka, a complete re-design of XLForm in Swift and with more features

xmartlabs 5.8k Jan 6, 2023
GrouponHeader - iOS TableView Header Animation, Swift/UIKit

GrouponHeader Description: iOS TableView Header Animation Technology: Swift, UIK

James Sedlacek 8 Dec 15, 2022
SwiftyFORM is a lightweight iOS framework for creating forms

SwiftyFORM is a lightweight iOS framework for creating forms Because form code is hard to write, hard to read, hard to reason about. Has a

Simon Strandgaard 1.1k Dec 29, 2022
Boring-example - Using boring crate from iOS application

BoringSSL example Using boring crate from iOS application. Checkout git clone gi

Alexei Lozovsky 0 Dec 31, 2021
iOS Validation Library

Honour Validation library for iOS inspired by Respect/Validation. Validator.mustBe(Uppercase()).andMust(StartsWith("F")).validate("FOOBAR") ❗ If you w

Jean Pimentel 55 Jun 3, 2021
Meet CRRulerControl - Customizable Control for iOS

Customizable component, created by Cleveroad iOS developers, is aimed at turning a simple ruler into a handy and smart instrument

Cleveroad 112 Oct 2, 2022
SwiftForms is a small and lightweight library written in Swift that allows you to easily create forms.

SwiftForms is a powerful and extremely flexible library written in Swift that allows to create forms by just defining them in a couple of lines. It also provides the ability to customize cells appearance, use custom cells and define your own selector controllers.

Miguel Ángel Ortuño 1.3k Dec 27, 2022
A rule-based validation library for Swift

SwiftValidator Swift Validator is a rule-based validation library for Swift. Core Concepts UITextField + [Rule] + (and optional error UILabel) go into

null 1.4k Dec 29, 2022
Declarative data validation framework, written in Swift

Peppermint Introduction Requirements Installation Swift Package Manager Usage Examples Predicates Constraints Predicate Constraint Compound Constraint

iOS NSAgora 43 Nov 22, 2022
Custom-TopBarController - A Custom TopBar Controller With Swift

TopBarController Верстка Для IPhone и IPod вертска адаптивная, для IPad frane To

Fadeev Sergey 1 Aug 2, 2022
AtomicReferenceCell - Atomic Reference Cell (Arc) for Swift

Atomic Reference Cell This project provide two structures: Arc<T> and WeakArc<T>

cjw 0 Jan 30, 2022