Skip to content

Commit

Permalink
Merge pull request #671 from xmartlabs/Swift3
Browse files Browse the repository at this point in the history
Swift3
  • Loading branch information
Martin Barreto authored Sep 26, 2016
2 parents cf312cb + 1a7ef72 commit 3efe00e
Show file tree
Hide file tree
Showing 97 changed files with 4,292 additions and 3,296 deletions.
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: objective-c
osx_image: xcode7.3
osx_image: xcode8
env:
- DESTINATION="OS=9.3,name=iPhone 6s" SCHEME="Eureka" SDK=iphonesimulator9.3
- DESTINATION="OS=10.0,name=iPhone 6s" SCHEME="Eureka" SDK=iphonesimulator10.0
before_install:
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
- brew update
Expand Down
44 changes: 43 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,53 @@
# Change Log
All notable changes to this project will be documented in this file.

### master branch
### [2.0.0-beta.1](https://github.com/xmartlabs/Eureka/releases/tag/2.0.0)

Pull requests associated with this milestone can be found in this [filter](https://github.com/xmartlabs/Eureka/issues?utf8=%E2%9C%93&q=milestone%3A2.0.0%20).

We have made tons of changes to the Eureka API to follow the new Swift API design guidelines.
It's hard to enumerate all changes and most of them will be automatically suggested by Xcode.

We have also added to Eureka a extensible build-in validations support.

These are the most important changes...

#### Deleted

* `PostalAddressRow` was removed.
* `ImageRow` was removed.

You can find these both rows under [EurekaCommunity] github organization.

* Row's `func highlightCell()`
* Row's `func unhighlightCell()`
* Cell's `func highlight()`
* Cell's `func unhighlight()`
* Cell's `func didSelect()`

#### Added

* Rows's `var isHighlighted: Bool`.
* Rows's `var isValid: Bool`.
* Row's `func onCellHighlightChanged(_ callback: @escaping (_ cell: Cell, _ row: Self)->()) -> Self `.
* Row's `func onRowValidationChanged(_ callback: @escaping (_ cell: Cell, _ row: Self)->()) -> Self`.
* Row's `func validate() -> [ValidationError]`
* Form's `func validate() -> [ValidationError]`
* Row's `func add<Rule: RuleType>(rule: Rule)`
* Row's `func remove(ruleWithIdentifier: String)`
* `RuleSet<T: Equatable>` type.
* `ValidationOptions` Enum type.
* `RuleType` protocol.
* `ValidationError` type.

##### Fixes

* Fixed textlabel alignment for cells with custom constraints (FieldRow, SegmentedRow, TextAreaRow).
* Set 'Require Only App-Extension-Safe API' to YES to enable code sharing in App Extensions.
* Other bug fixes and minor improvements

Take a look at [2.0.0 Migration guide]() for more information on how to solve breaking changes.

### [1.7.0](https://github.com/xmartlabs/Eureka/releases/tag/1.7.0)

* **Breaking change**: Fixed typo in `hightlightCell`. You must now call / override `highlightCell`.
Expand Down Expand Up @@ -132,3 +173,4 @@ Released on 2015-09-29. This is the initial version.
[mikaoj]: https://github.com/mikaoj
[estebansotoara]: https://github.com/estebansotoara
[dernster]: https://github.com/dernster
[EurekaCommunity]: https://github.com/EurekaCommunity
54 changes: 54 additions & 0 deletions Documentation/Eureka 2.0 Migration Guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Eureka 2.0 Migration Guide

#### Requirements:

Eureka 2.0.0 needs Xcode 8, Swift3+ to work. Minimum supported iOS version is 8.0.

#### Changes

Eureka 2.0.0 includes complete Swift 3 Compatibility and adopts the new [API Design Guidelines](https://swift.org/documentation/api-design-guidelines/). It also includes the whole new validations build-in feature.
Bring support to swift 3 involves some API updates to follow Apple's Swift API best practices, we have also changed and deprecated some API's.

Most important changes will be listed below...


Many properties, methods, types were renamed and Xcode should suggest the fix automatically.



These are some examples:

|Old API| New API|
|----|----|
|`func rowByTag<T: Equatable>(_: String) -> RowOf<T>?`|`func rowBy<T: Equatable>(tag: String) -> RowOf<T>?`|
|`func rowByTag<Row: RowType>(_: String) -> Row?`|`func rowBy<Row: RowType>(tag: String) -> Row?`|
|`func rowByTag(_: String) -> BaseRow?`|`func rowBy(tag: String) -> BaseRow?`|
|`func sectionByTag(_: String) -> Section?`|`func sectionBy(tag: String) -> Section?`|
|`func rowValueHasBeenChanged(_: BaseRow, oldValue: Any?, newValue: Any?)`|`func valueHasBeenChanged(for: BaseRow, oldValue: Any?, newValue: Any?)`|
|`public final func indexPath() -> IndexPath?`|`public final var indexPath: IndexPath?`|
|`func prepareForSegue(_ segue: UIStoryboardSegue)`|`func prepare(for segue: UIStoryboardSegue)`|
|`func presentViewController(_ viewController: VCType!, row: BaseRow, presentingViewController:FormViewController)`|`present(_ viewController: VCType!, row: BaseRow, presentingViewController:FormViewController)`|
|`func createController() -> VCType?`|`func makeController() -> VCType?`|


There are also some breaking changes related with deprecated API:

Removed APIs:

* `PostalAddressRow` and `ImageRow` was deleted. You can find them and many other custom rows at EurekaCommunity [organization account](https://github.com/eurekaCommunity).
* `highlightCell` and `unhighlightCell` callbacks were deleted, now we should use `row.isHighlighted` from cell update to check from highlighted status and make UI modification according its value.

In case you want to do something when the row's highlighted state switches its value you can set up `onCellHighlightChanged` callback.

Custom Rows changes:

Row generic type no longer specify the value type. Its Value type is inferred from cell specification.

Before:

`public final class WeekDayRow: Row<Set<WeekDay>, WeekDayCell>, RowType`


After:

`public final class WeekDayRow: Row<WeekDayCell>, RowType`
28 changes: 18 additions & 10 deletions Eureka.playground/Contents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@

import UIKit
import XCPlayground
import PlaygroundSupport

//: Start by importing Eureka module
import Eureka

//: Any **Eureka** form must extend from `FromViewController`
let formController = FormViewController()
XCPlaygroundPage.currentPage.liveView = formController.view
PlaygroundPage.current.liveView = formController.view


let b = Array<Int>()
b.last

let f = Form()
f.last


//: ## Operators
Expand Down Expand Up @@ -47,10 +55,10 @@ formController.view
formController.form +++ Section("Callbacks") <<< SwitchRow("scr1"){ $0.title = "Switch to turn red"; $0.value = false }
.onChange({ row in
if row.value == true {
row.cell.backgroundColor = .redColor()
row.cell.backgroundColor = .red
}
else {
row.cell.backgroundColor = .blackColor()
row.cell.backgroundColor = .black
}
})

Expand All @@ -64,9 +72,9 @@ formController.view
//: The cellSetup will be called when the cell of this row is configured (just once at the beginning) and the cellUpdate will be called when it is updated (each time it reappears on screen). Here you should define the appearance of the cell

formController.form.last! <<< SegmentedRow<String>("Segments") { $0.title = "Choose an animal"; $0.value = "🐼"; $0.options = ["🐼", "🐶", "🐻"]}.cellSetup({ cell, row in
cell.backgroundColor = .redColor()
cell.backgroundColor = .red
}).cellUpdate({ (cell, row) -> () in
cell.textLabel?.textColor = .yellowColor()
cell.textLabel?.textColor = .yellow
})


Expand All @@ -93,15 +101,15 @@ formController.form.last! <<< LabelRow("Confirm") {
//: Now let's see how this works:

formController.view
formController.form.rowByTag("Segments2")?.baseValue = "🐶"
formController.form.rowBy(tag: "Segments2")?.baseValue = "🐶"
formController.view

//: We can do the same using functions. Functions are specially useful for more complicated conditions. This applies when the value of the row we depend on is not compatible with NSPredicates (which is not the current case, but anyway).

formController.form.last! <<< LabelRow("Confirm2") {
$0.title = "Well chosen!!"
$0.hidden = Condition.Function(["Segments2"]){ form in
if let r:SegmentedRow<String> = form.rowByTag("Segments2") {
$0.hidden = Condition.function(["Segments2"]){ form in
if let r:SegmentedRow<String> = form.rowBy(tag: "Segments2") {
return r.value != "🐼"
}
return true
Expand All @@ -111,7 +119,7 @@ formController.form.last! <<< LabelRow("Confirm2") {
//: Now let's see how this works:

formController.view
formController.form.rowByTag("Segments2")?.baseValue = "🐼"
formController.form.rowBy(tag: "Segments2")?.baseValue = "🐼"
formController.view


2 changes: 1 addition & 1 deletion Eureka.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios' auto-termination-delay='20' display-mode='rendered' executeOnSourceChanges='false' timelineScrubberEnabled='true'>
<playground version='5.0' target-platform='ios' auto-termination-delay='20' display-mode='rendered' executeOnSourceChanges='false' timelineScrubberEnabled='true' last-migration='0800'>
<timeline fileName='timeline.xctimeline'/>
</playground>
28 changes: 14 additions & 14 deletions Eureka.playground/timeline.xctimeline
Original file line number Diff line number Diff line change
Expand Up @@ -3,82 +3,82 @@
version = "3.0">
<TimelineItems>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=662&amp;EndingColumnNumber=20&amp;EndingLineNumber=28&amp;StartingColumnNumber=1&amp;StartingLineNumber=27&amp;Timestamp=474155368.399866"
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=734&amp;EndingColumnNumber=20&amp;EndingLineNumber=36&amp;StartingColumnNumber=1&amp;StartingLineNumber=35&amp;Timestamp=489699812.048581"
lockedSize = "{1063, 340}"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=1181&amp;EndingColumnNumber=20&amp;EndingLineNumber=41&amp;StartingColumnNumber=1&amp;StartingLineNumber=40&amp;Timestamp=474155368.400147"
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=1253&amp;EndingColumnNumber=20&amp;EndingLineNumber=49&amp;StartingColumnNumber=1&amp;StartingLineNumber=48&amp;Timestamp=489699812.048742"
lockedSize = "{322, 325}"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=9&amp;CharacterRangeLoc=1495&amp;EndingColumnNumber=20&amp;EndingLineNumber=55&amp;StartingColumnNumber=1&amp;StartingLineNumber=55&amp;Timestamp=474155368.400296"
documentLocation = "#CharacterRangeLen=9&amp;CharacterRangeLoc=1567&amp;EndingColumnNumber=20&amp;EndingLineNumber=63&amp;StartingColumnNumber=1&amp;StartingLineNumber=63&amp;Timestamp=489699812.048863"
lockedSize = "{328, 416}"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=1301&amp;EndingColumnNumber=20&amp;EndingLineNumber=45&amp;StartingColumnNumber=1&amp;StartingLineNumber=45&amp;Timestamp=474155368.400435"
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=1373&amp;EndingColumnNumber=20&amp;EndingLineNumber=53&amp;StartingColumnNumber=1&amp;StartingLineNumber=53&amp;Timestamp=489699812.048994"
lockedSize = "{395, 526}"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=3605&amp;EndingColumnNumber=20&amp;EndingLineNumber=57&amp;StartingColumnNumber=1&amp;StartingLineNumber=57&amp;Timestamp=474155368.400573"
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=3649&amp;EndingColumnNumber=20&amp;EndingLineNumber=65&amp;StartingColumnNumber=1&amp;StartingLineNumber=65&amp;Timestamp=492491796.689164"
lockedSize = "{354, 450}"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=1526&amp;EndingColumnNumber=20&amp;EndingLineNumber=55&amp;StartingColumnNumber=1&amp;StartingLineNumber=55&amp;Timestamp=474155368.400709"
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=1598&amp;EndingColumnNumber=20&amp;EndingLineNumber=63&amp;StartingColumnNumber=1&amp;StartingLineNumber=63&amp;Timestamp=489699812.049266"
lockedSize = "{453, 531}"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=152&amp;EndingColumnNumber=20&amp;EndingLineNumber=8&amp;StartingColumnNumber=1&amp;StartingLineNumber=8&amp;Timestamp=474155368.400845"
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=152&amp;EndingColumnNumber=20&amp;EndingLineNumber=9&amp;StartingColumnNumber=1&amp;StartingLineNumber=9&amp;Timestamp=489699812.049381"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=1569&amp;EndingColumnNumber=20&amp;EndingLineNumber=57&amp;StartingColumnNumber=1&amp;StartingLineNumber=57&amp;Timestamp=474155368.400979"
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=1641&amp;EndingColumnNumber=20&amp;EndingLineNumber=65&amp;StartingColumnNumber=1&amp;StartingLineNumber=65&amp;Timestamp=489699812.049506"
lockedSize = "{566, 773}"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=916&amp;EndingColumnNumber=20&amp;EndingLineNumber=35&amp;StartingColumnNumber=1&amp;StartingLineNumber=35&amp;Timestamp=474155368.401117"
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=988&amp;EndingColumnNumber=20&amp;EndingLineNumber=43&amp;StartingColumnNumber=1&amp;StartingLineNumber=43&amp;Timestamp=489699812.049641"
lockedSize = "{177, 169}"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=1549&amp;EndingColumnNumber=20&amp;EndingLineNumber=55&amp;StartingColumnNumber=1&amp;StartingLineNumber=55&amp;Timestamp=474155368.401255"
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=1621&amp;EndingColumnNumber=20&amp;EndingLineNumber=63&amp;StartingColumnNumber=1&amp;StartingLineNumber=63&amp;Timestamp=489699812.049755"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=985&amp;EndingColumnNumber=20&amp;EndingLineNumber=37&amp;StartingColumnNumber=1&amp;StartingLineNumber=37&amp;Timestamp=474155368.401389"
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=1057&amp;EndingColumnNumber=20&amp;EndingLineNumber=45&amp;StartingColumnNumber=1&amp;StartingLineNumber=45&amp;Timestamp=489699812.049864"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=2187&amp;EndingColumnNumber=20&amp;EndingLineNumber=80&amp;StartingColumnNumber=1&amp;StartingLineNumber=80&amp;Timestamp=474155368.401519"
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=2259&amp;EndingColumnNumber=20&amp;EndingLineNumber=88&amp;StartingColumnNumber=1&amp;StartingLineNumber=88&amp;Timestamp=489699812.049988"
lockedSize = "{298, 389}"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=1798&amp;EndingColumnNumber=20&amp;EndingLineNumber=64&amp;StartingColumnNumber=1&amp;StartingLineNumber=64&amp;Timestamp=474155368.401651"
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=1870&amp;EndingColumnNumber=20&amp;EndingLineNumber=72&amp;StartingColumnNumber=1&amp;StartingLineNumber=72&amp;Timestamp=489699812.050102"
lockedSize = "{475, 564}"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=1718&amp;EndingColumnNumber=20&amp;EndingLineNumber=62&amp;StartingColumnNumber=1&amp;StartingLineNumber=62&amp;Timestamp=474155368.401792"
documentLocation = "#CharacterRangeLen=19&amp;CharacterRangeLoc=1790&amp;EndingColumnNumber=20&amp;EndingLineNumber=70&amp;StartingColumnNumber=1&amp;StartingLineNumber=70&amp;Timestamp=489699812.050307"
lockedSize = "{397, 516}"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
Expand Down
2 changes: 1 addition & 1 deletion Eureka.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Eureka'
s.version = '1.7.0'
s.version = '2.0.0-beta.1'
s.license = 'MIT'
s.summary = 'Elegant iOS Forms in pure Swift 2'
s.homepage = 'https://github.com/xmartlabs/Eureka'
Expand Down
Loading

0 comments on commit 3efe00e

Please sign in to comment.