Skip to content

Commit

Permalink
fix #111
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Barreto committed Dec 3, 2015
1 parent 52b0d45 commit 29d9f0c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Example/Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="6g3-M9-WkD">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="6g3-M9-WkD">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
</dependencies>
<scenes>
<!--Navigation Accessory Controller-->
Expand Down
4 changes: 2 additions & 2 deletions Source/Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public protocol BaseInlineRowType {
public protocol InlineRowType: TypedRowType, BaseInlineRowType {
typealias InlineRow: RowType

var onPresentInlineRow : (InlineRow -> Void)? { get set }
func setupInlineRow(inlineRow: InlineRow)
}

extension InlineRowType where Self: BaseRow, Self.InlineRow : BaseRow, Self.Cell : TypedCellType, Self.Cell.Value == Self.Value, Self.InlineRow.Cell.Value == Self.InlineRow.Value, Self.InlineRow.Value == Self.Value {
Expand All @@ -108,7 +108,7 @@ extension InlineRowType where Self: BaseRow, Self.InlineRow : BaseRow, Self.Cell
self?.value = $0.value
self?.updateCell()
}
onPresentInlineRow?(inline)
setupInlineRow(inline)
if (form.inlineRowHideOptions ?? Form.defaultInlineRowHideOptions).contains(.AnotherInlineRowIsShown) {
for row in form.allRows {
if let inlineRow = row as? BaseInlineRowType {
Expand Down
37 changes: 28 additions & 9 deletions Source/Rows.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public class _DateInlineFieldRow: Row<NSDate, DateInlineCell>, _DatePickerRowPro
public class _DateInlineRow: _DateInlineFieldRow {

public typealias InlineRow = DatePickerRow
public var onPresentInlineRow : (DatePickerRow -> Void)?

public required init(tag: String?) {
super.init(tag: tag)
Expand All @@ -124,12 +123,17 @@ public class _DateInlineRow: _DateInlineFieldRow {
dateFormatter?.dateStyle = .MediumStyle
dateFormatter?.locale = .currentLocale()
}

public func setupInlineRow(inlineRow: DatePickerRow) {
inlineRow.minimumDate = minimumDate
inlineRow.maximumDate = maximumDate
inlineRow.minuteInterval = minuteInterval
}
}

public class _DateTimeInlineRow: _DateInlineFieldRow {

public typealias InlineRow = DateTimePickerRow
public var onPresentInlineRow : (DateTimePickerRow -> Void)?

public required init(tag: String?) {
super.init(tag: tag)
Expand All @@ -138,12 +142,17 @@ public class _DateTimeInlineRow: _DateInlineFieldRow {
dateFormatter?.dateStyle = .ShortStyle
dateFormatter?.locale = .currentLocale()
}

public func setupInlineRow(inlineRow: DateTimePickerRow) {
inlineRow.minimumDate = minimumDate
inlineRow.maximumDate = maximumDate
inlineRow.minuteInterval = minuteInterval
}
}

public class _TimeInlineRow: _DateInlineFieldRow {

public typealias InlineRow = TimePickerRow
public var onPresentInlineRow : (TimePickerRow -> Void)?

public required init(tag: String?) {
super.init(tag: tag)
Expand All @@ -152,12 +161,17 @@ public class _TimeInlineRow: _DateInlineFieldRow {
dateFormatter?.dateStyle = .NoStyle
dateFormatter?.locale = .currentLocale()
}

public func setupInlineRow(inlineRow: TimePickerRow) {
inlineRow.minimumDate = minimumDate
inlineRow.maximumDate = maximumDate
inlineRow.minuteInterval = minuteInterval
}
}

public class _CountDownInlineRow: _DateInlineFieldRow {

public typealias InlineRow = CountDownPickerRow
public var onPresentInlineRow : (CountDownPickerRow -> Void)?

public required init(tag: String?) {
super.init(tag: tag)
Expand All @@ -173,6 +187,12 @@ public class _CountDownInlineRow: _DateInlineFieldRow {
return "\(hour) hours \(min) min"
}
}

public func setupInlineRow(inlineRow: CountDownPickerRow) {
inlineRow.minimumDate = minimumDate
inlineRow.maximumDate = maximumDate
inlineRow.minuteInterval = minuteInterval
}
}

public class _TextRow: FieldRow<String, TextCell> {
Expand Down Expand Up @@ -325,7 +345,6 @@ public class _PickerRow<T where T: Equatable> : Row<T, PickerCell<T>>{
public class _PickerInlineRow<T where T: Equatable> : Row<T, LabelCellOf<T>>{

public typealias InlineRow = PickerRow<T>
public var onPresentInlineRow : (PickerRow<T> -> Void)?
public var options = [T]()

required public init(tag: String?) {
Expand All @@ -337,10 +356,6 @@ public final class PickerInlineRow<T where T: Equatable> : _PickerInlineRow<T>,

required public init(tag: String?) {
super.init(tag: tag)
onPresentInlineRow = { [unowned self] inlineRow in
inlineRow.options = self.options
inlineRow.displayValueFor = self.displayValueFor
}
onExpandInlineRow { cell, row, _ in
let color = cell.detailTextLabel?.textColor
row.onCollapseInlineRow { cell, _, _ in
Expand All @@ -357,6 +372,10 @@ public final class PickerInlineRow<T where T: Equatable> : _PickerInlineRow<T>,
}
}

public func setupInlineRow(inlineRow: InlineRow) {
inlineRow.options = self.options
inlineRow.displayValueFor = self.displayValueFor
}
}

public final class PickerRow<T where T: Equatable>: _PickerRow<T>, RowType {
Expand Down

0 comments on commit 29d9f0c

Please sign in to comment.