RxSwift/RxCocoa/iOS/UIDatePicker+Rx.swift

44 lines
1.1 KiB
Swift
Raw Normal View History

//
2015-12-29 18:56:21 +03:00
// UIDatePicker+Rx.swift
// 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-09-28 23:03:59 +03:00
#if os(iOS)
import RxSwift
import UIKit
extension Reactive where Base: UIDatePicker {
2016-10-23 20:26:22 +03:00
/// Reactive wrapper for `date` property.
public var date: ControlProperty<Date> {
return value
}
2017-02-13 17:47:56 +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
}
)
}
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