2015-07-09 20:32:22 +03:00
|
|
|
//
|
2015-12-29 18:56:21 +03:00
|
|
|
// UIDatePicker+Rx.swift
|
2015-07-09 20:32:22 +03:00
|
|
|
// RxCocoa
|
|
|
|
//
|
|
|
|
// Created by Daniel Tartaglia on 5/31/15.
|
2015-12-29 18:56:21 +03:00
|
|
|
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
|
2015-07-09 20:32:22 +03:00
|
|
|
//
|
|
|
|
|
2015-09-28 23:03:59 +03:00
|
|
|
#if os(iOS)
|
2015-07-09 20:32:22 +03:00
|
|
|
|
|
|
|
import RxSwift
|
|
|
|
import UIKit
|
|
|
|
|
2016-08-03 21:11:43 +03:00
|
|
|
extension Reactive where Base: UIDatePicker {
|
2016-10-23 20:26:22 +03:00
|
|
|
/// Reactive wrapper for `date` property.
|
2016-08-03 21:11:43 +03:00
|
|
|
public var date: ControlProperty<Date> {
|
2016-12-18 00:14:36 +03:00
|
|
|
return value
|
|
|
|
}
|
2017-02-13 17:47:56 +03:00
|
|
|
|
2016-12-18 00:14:36 +03:00
|
|
|
/// Reactive wrapper for `date` property.
|
|
|
|
public var value: ControlProperty<Date> {
|
2017-10-10 11:49:53 +03:00
|
|
|
return base.rx.controlPropertyWithDefaultEvents(
|
2016-02-13 23:25:31 +03:00
|
|
|
getter: { datePicker in
|
|
|
|
datePicker.date
|
|
|
|
}, setter: { datePicker, value in
|
|
|
|
datePicker.date = value
|
|
|
|
}
|
|
|
|
)
|
2015-07-09 20:32:22 +03:00
|
|
|
}
|
2017-02-13 17:47:56 +03:00
|
|
|
|
|
|
|
/// Reactive wrapper for `countDownDuration` property.
|
|
|
|
public var countDownDuration: ControlProperty<TimeInterval> {
|
2017-10-10 11:49:53 +03:00
|
|
|
return base.rx.controlPropertyWithDefaultEvents(
|
2017-02-13 17:47:56 +03:00
|
|
|
getter: { datePicker in
|
|
|
|
datePicker.countDownDuration
|
|
|
|
}, setter: { datePicker, value in
|
|
|
|
datePicker.countDownDuration = value
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2015-09-28 23:03:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|