<commit_before>![Eureka: Elegant form builder in Swift](Eureka.png)

<p align="center">
<a href="https://travis-ci.org/xmartlabs/Eureka"><img src="https://travis-ci.org/xmartlabs/Eureka.svg?branch=master" alt="Build status" /></a>
<img src="https://img.shields.io/badge/platform-iOS-blue.svg?style=flat" alt="Platform iOS" />
<a href="https://developer.apple.com/swift"><img src="https://img.shields.io/badge/swift2-compatible-4BC51D.svg?style=flat" alt="Swift 2 compatible" /></a>
<a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible" /></a>
<a href="https://cocoapods.org/pods/Eureka"><img src="https://img.shields.io/badge/pod-1.4.1-blue.svg" alt="CocoaPods compatible" /></a>
<a href="https://raw.githubusercontent.com/xmartlabs/Eureka/master/LICENSE"><img src="http://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License: MIT" /></a>
<a href="https://codebeat.co/projects/github-com-xmartlabs-eureka"><img alt="codebeat badge" src="https://codebeat.co/badges/16f29afb-f072-4633-9497-333c6eb71263" /></a>
</p>

Made with ❤️  by [XMARTLABS](http://xmartlabs.com).
This is the re-creation of [XLForm] in Swift 2.

* [Introduction]
* [Requirements]
* [Examples]
* [Usage]
  + [How to create a Form]
  + [How to get the form values]
  + [Operators]
  + [Rows]
  + [Customization]
  + [Section Header and Footer]
  + [How to dynamically hide and show rows (or sections)]
* [Extensibility]
  + [How to create custom rows and cells]
  + [How to create custom inline rows]
  + [Implementing a custom Presenter row]
  + [Custom rows catalog]
* [Installation]
* [FAQ]

## Introduction

**Eureka!** is a library to create dynamic table-view forms from a [DSL] specification in Swift. This DSL basically consists of *Rows*, *Sections* and *Forms*. A *Form* is a collection of *Sections* and a *Section* is a collection of *Rows*.

If you have been using `XLForm` then many terms will result familiar to you.

Both `Form` and `Section` classes conform to `MutableCollectionType` and `RangeReplaceableCollectionType` protocols. This makes a whole bunch of functions available to be executed on them.

**For more information look at [our blog post] that introduces *Eureka!*.**

## Requirements

* iOS 8.0+
* Xcode 7.0+


## 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](CONTRIBUTING.md) file for more info.**

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

## Examples

Follow these 3 steps to run Example project: Clone Eureka repository, open Eureka workspace and run the *Example* project.

You can also experiment and learn with the *Eureka Playground* which is contained in *Eureka.workspace*.

<img src="Example/Media/EurekaNavigation.gif" width="300"/>
<img src="Example/Media/EurekaRows.gif" width="300"/>

## Usage

### How to create a form
It is quite simple to create a form, just like this:

```swift
import Eureka

class CustomCellsController : FormViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        form +++ Section("Custom cells")
	            	<<< WeekDayRow(){
	            		$0.value = [.Monday, .Wednesday, .Friday]
	            	}
	            	<<< TextFloatLabelRow() {
	            		$0.title = "Float Label Row, type something to see.."
	            	}
    }
}
```

In this example we create a [CustomCellsController] and then simply add a section with two custom rows to the `form` variable.

And this is the product:

<img src="Example/Media/EurekaCustomCells.gif" width="300" alt="Screenshot of Custom Cells"/>

As you may have noticed `CustomCellsController` extends from `FormViewController` which has a `form` property that can be used to declare the form as the example shows.
`WeekDayRow` and `TextFloatLabelRow` are non-standard rows included in the example project, but the standard rows usage is analog. You can create a form by just setting up the `form` property without extending from `FormViewController` but typically it is more convenient to create a custom view controller that extends from it.

### How to get the form values

We can get all form values by invoking the following `Form` function:

```swift
public func values(includeHidden includeHidden: Bool = false) -> [String: Any?]
```

Passing `true` as `includeHidden` parameter value will also include the hidden rows values in the dictionary.

As you may have noticed the result dictionary key is the row tag value and the value is the row value. Only rows with a tag value will be added to the dictionary.

### Operators

We declared a series of custom operators to make the creation and modification of forms more readable and appealing.
#### +++=
This operator is used to append a row or section to a form. In case you are appending a row, then a section will be created that contains that row and that section will be appended to the form.

```swift
// Will append a section at the end of the 'form' Form.
form +++= Section()

// Will internally create a Section containing a PhoneRow and append it to the 'form' variable:
form +++= PhoneRow()
```

#### +++
Lets you add a Section to a Form or create a Form by adding two sections. For example:

```swift
// Will add two sections at the end of the 'form' Form.
form +++ Section("Custom cells") +++ Section("Another section")

// Will create and assign a Form to the 'form' variable (containing the two sections):
form = Section("Custom cells") +++ Section("Another section")
```

#### <<<
This one is used to append rows to sections or to create a Section by appending two rows. For example:


```swift
// Will append a Check row to the last section of the 'form' Form.
form.last! <<< CheckRow()

// Will implicitly create a Section and add it to the 'form' (containing the two rows):
form +++ PhoneRow("Phone"){ $0.title = "Phone"}
         <<< IntRow("IntRow"){ $0.title = "Int"; $0.value = 5 }
```


#### +=
This operator just invokes the corresponding `appendContentsOf` method which means that it can be used to append arrays of elements to either a Form or a Section like this:

```swift
// Will append three sections to form.
form += [Section("A"), Section("B"), Section("C")]
```

###### To learn more about these operators try them out in Eureka Playground.


### Rows

This is a list of the rows that are provided by default:

* **Field Rows**
	This 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**

Typically we want to show a field row value using a formatter, for instance a currency formatter. To do so the previous rows have a `formatter` property that can be used to set up any formatter.
`useFormatterDuringInput` determines if the formatter also should be used during row editing, this means, when the row's textfield is the first responder. The main challenge of using the formatting when the row is being edited is keeping updated the cursor position accordingly. Eureka provides the following protocol that your formatter should conform to in order to handle cursor position.

For more information take a look at `DecimalFormatter` and `CurrencyFormatter` in the Example project.

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

* **Date Rows**
  Date Rows hold a NSDate 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.
<commit_msg>Fix missing class name UrlRow<commit_after>![Eureka: Elegant form builder in Swift](Eureka.png)

<p align="center">
<a href="https://travis-ci.org/xmartlabs/Eureka"><img src="https://travis-ci.org/xmartlabs/Eureka.svg?branch=master" alt="Build status" /></a>
<img src="https://img.shields.io/badge/platform-iOS-blue.svg?style=flat" alt="Platform iOS" />
<a href="https://developer.apple.com/swift"><img src="https://img.shields.io/badge/swift2-compatible-4BC51D.svg?style=flat" alt="Swift 2 compatible" /></a>
<a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible" /></a>
<a href="https://cocoapods.org/pods/Eureka"><img src="https://img.shields.io/badge/pod-1.4.1-blue.svg" alt="CocoaPods compatible" /></a>
<a href="https://raw.githubusercontent.com/xmartlabs/Eureka/master/LICENSE"><img src="http://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License: MIT" /></a>
<a href="https://codebeat.co/projects/github-com-xmartlabs-eureka"><img alt="codebeat badge" src="https://codebeat.co/badges/16f29afb-f072-4633-9497-333c6eb71263" /></a>
</p>

Made with ❤️  by [XMARTLABS](http://xmartlabs.com).
This is the re-creation of [XLForm] in Swift 2.

* [Introduction]
* [Requirements]
* [Examples]
* [Usage]
  + [How to create a Form]
  + [How to get the form values]
  + [Operators]
  + [Rows]
  + [Customization]
  + [Section Header and Footer]
  + [How to dynamically hide and show rows (or sections)]
* [Extensibility]
  + [How to create custom rows and cells]
  + [How to create custom inline rows]
  + [Implementing a custom Presenter row]
  + [Custom rows catalog]
* [Installation]
* [FAQ]

## Introduction

**Eureka!** is a library to create dynamic table-view forms from a [DSL] specification in Swift. This DSL basically consists of *Rows*, *Sections* and *Forms*. A *Form* is a collection of *Sections* and a *Section* is a collection of *Rows*.

If you have been using `XLForm` then many terms will result familiar to you.

Both `Form` and `Section` classes conform to `MutableCollectionType` and `RangeReplaceableCollectionType` protocols. This makes a whole bunch of functions available to be executed on them.

**For more information look at [our blog post] that introduces *Eureka!*.**

## Requirements

* iOS 8.0+
* Xcode 7.0+


## 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](CONTRIBUTING.md) file for more info.**

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

## Examples

Follow these 3 steps to run Example project: Clone Eureka repository, open Eureka workspace and run the *Example* project.

You can also experiment and learn with the *Eureka Playground* which is contained in *Eureka.workspace*.

<img src="Example/Media/EurekaNavigation.gif" width="300"/>
<img src="Example/Media/EurekaRows.gif" width="300"/>

## Usage

### How to create a form
It is quite simple to create a form, just like this:

```swift
import Eureka

class CustomCellsController : FormViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        form +++ Section("Custom cells")
	            	<<< WeekDayRow(){
	            		$0.value = [.Monday, .Wednesday, .Friday]
	            	}
	            	<<< TextFloatLabelRow() {
	            		$0.title = "Float Label Row, type something to see.."
	            	}
    }
}
```

In this example we create a [CustomCellsController] and then simply add a section with two custom rows to the `form` variable.

And this is the product:

<img src="Example/Media/EurekaCustomCells.gif" width="300" alt="Screenshot of Custom Cells"/>

As you may have noticed `CustomCellsController` extends from `FormViewController` which has a `form` property that can be used to declare the form as the example shows.
`WeekDayRow` and `TextFloatLabelRow` are non-standard rows included in the example project, but the standard rows usage is analog. You can create a form by just setting up the `form` property without extending from `FormViewController` but typically it is more convenient to create a custom view controller that extends from it.

### How to get the form values

We can get all form values by invoking the following `Form` function:

```swift
public func values(includeHidden includeHidden: Bool = false) -> [String: Any?]
```

Passing `true` as `includeHidden` parameter value will also include the hidden rows values in the dictionary.

As you may have noticed the result dictionary key is the row tag value and the value is the row value. Only rows with a tag value will be added to the dictionary.

### Operators

We declared a series of custom operators to make the creation and modification of forms more readable and appealing.
#### +++=
This operator is used to append a row or section to a form. In case you are appending a row, then a section will be created that contains that row and that section will be appended to the form.

```swift
// Will append a section at the end of the 'form' Form.
form +++= Section()

// Will internally create a Section containing a PhoneRow and append it to the 'form' variable:
form +++= PhoneRow()
```

#### +++
Lets you add a Section to a Form or create a Form by adding two sections. For example:

```swift
// Will add two sections at the end of the 'form' Form.
form +++ Section("Custom cells") +++ Section("Another section")

// Will create and assign a Form to the 'form' variable (containing the two sections):
form = Section("Custom cells") +++ Section("Another section")
```

#### <<<
This one is used to append rows to sections or to create a Section by appending two rows. For example:


```swift
// Will append a Check row to the last section of the 'form' Form.
form.last! <<< CheckRow()

// Will implicitly create a Section and add it to the 'form' (containing the two rows):
form +++ PhoneRow("Phone"){ $0.title = "Phone"}
         <<< IntRow("IntRow"){ $0.title = "Int"; $0.value = 5 }
```


#### +=
This operator just invokes the corresponding `appendContentsOf` method which means that it can be used to append arrays of elements to either a Form or a Section like this:

```swift
// Will append three sections to form.
form += [Section("A"), Section("B"), Section("C")]
```

###### To learn more about these operators try them out in Eureka Playground.


### Rows

This is a list of the rows that are provided by default:

* **Field Rows**
	This 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**

Typically we want to show a field row value using a formatter, for instance a currency formatter. To do so the previous rows have a `formatter` property that can be used to set up any formatter.
`useFormatterDuringInput` determines if the formatter also should be used during row editing, this means, when the row's textfield is the first responder. The main challenge of using the formatting when the row is being edited is keeping updated the cursor position accordingly. Eureka provides the following protocol that your formatter should conform to in order to handle cursor position.

For more information take a look at `DecimalFormatter` and `CurrencyFormatter` in the Example project.

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

* **Date Rows**
  Date Rows hold a NSDate 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.

{'fraction_non_alphanumeric': 0.11333576022327388, 'fraction_numerical': 0.00679529183351535, 'mean_word_length': 4.251035361580121, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 55, 'https://': 24, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1384399', 'n_tokens_mistral': 4981, 'n_tokens_neox': 4725, 'n_words': 2080}