added onChange
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
fa273bad1c
commit
308ef596a4
@ -7,14 +7,23 @@
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Combine
|
||||
|
||||
public class SelectorGroupHandlerBase<HandlerType: Control>: Control {
|
||||
public class SelectorGroupHandlerBase<HandlerType: Control>: Control, Changeable {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
public var selectorViews: [HandlerType] = []
|
||||
|
||||
public var onChangeSubscriber: AnyCancellable? {
|
||||
willSet {
|
||||
if let onChangeSubscriber {
|
||||
onChangeSubscriber.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Overrides
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -7,13 +7,13 @@
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Combine
|
||||
import VDSColorTokens
|
||||
import VDSFormControlsTokens
|
||||
import Combine
|
||||
|
||||
/// Checkboxes are a multi-select component through which a customer indicates a choice. If a binary choice, the component is a checkbox. If the choice has multiple options, the component is a ``CheckboxGroup``.
|
||||
@objc(VDSCheckboxBase)
|
||||
open class Checkbox: Control, Errorable {
|
||||
open class Checkbox: Control, Errorable, Changeable {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
@ -63,6 +63,14 @@ open class Checkbox: Control, Errorable {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
public var onChangeSubscriber: AnyCancellable? {
|
||||
willSet {
|
||||
if let onChangeSubscriber {
|
||||
onChangeSubscriber.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open var label = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
|
||||
@ -7,12 +7,12 @@
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Combine
|
||||
import VDSColorTokens
|
||||
import VDSFormControlsTokens
|
||||
import Combine
|
||||
|
||||
@objc(VDSRadioBox)
|
||||
open class RadioBox: Control {
|
||||
open class RadioBox: Control, Changeable {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
@ -56,6 +56,14 @@ open class RadioBox: Control {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
public var onChangeSubscriber: AnyCancellable? {
|
||||
willSet {
|
||||
if let onChangeSubscriber {
|
||||
onChangeSubscriber.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open var textLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
|
||||
@ -7,11 +7,12 @@
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Combine
|
||||
import VDSColorTokens
|
||||
import VDSFormControlsTokens
|
||||
|
||||
@objc(VDSRadioButton)
|
||||
open class RadioButton: Control, Errorable {
|
||||
open class RadioButton: Control, Errorable, Changeable {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
@ -61,6 +62,14 @@ open class RadioButton: Control, Errorable {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
public var onChangeSubscriber: AnyCancellable? {
|
||||
willSet {
|
||||
if let onChangeSubscriber {
|
||||
onChangeSubscriber.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open var label = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
|
||||
@ -12,7 +12,7 @@ import VDSFormControlsTokens
|
||||
import Combine
|
||||
|
||||
@objc(VDSEntryField)
|
||||
open class EntryField: Control {
|
||||
open class EntryField: Control, Changeable {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Enums
|
||||
//--------------------------------------------------
|
||||
@ -98,6 +98,14 @@ open class EntryField: Control {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
public var onChangeSubscriber: AnyCancellable? {
|
||||
willSet {
|
||||
if let onChangeSubscriber {
|
||||
onChangeSubscriber.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open var titleLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.attributes = []
|
||||
|
||||
@ -18,7 +18,7 @@ import Combine
|
||||
Knob: The circular indicator that slides on the container.
|
||||
*/
|
||||
@objc(VDSToggle)
|
||||
open class Toggle: Control {
|
||||
open class Toggle: Control, Changeable {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Enums
|
||||
//--------------------------------------------------
|
||||
@ -107,6 +107,14 @@ open class Toggle: Control {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
public var onChangeSubscriber: AnyCancellable? {
|
||||
willSet {
|
||||
if let onChangeSubscriber {
|
||||
onChangeSubscriber.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open var label = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
}
|
||||
|
||||
@ -15,13 +15,6 @@ public protocol Clickable: Handlerable where Self: UIControl {
|
||||
}
|
||||
|
||||
extension Clickable {
|
||||
public func addEvent(event: UIControl.Event, block: @escaping (Self)->()) {
|
||||
publisher(for: event)
|
||||
.sink(receiveValue: { c in
|
||||
block(c)
|
||||
}).store(in: &subscribers)
|
||||
}
|
||||
|
||||
public var onClick: ((Self) -> ())? {
|
||||
get { return nil }
|
||||
set {
|
||||
|
||||
@ -34,3 +34,12 @@ extension Handlerable where Self: UIView {
|
||||
subject.send()
|
||||
}
|
||||
}
|
||||
|
||||
extension Handlerable where Self: UIControl {
|
||||
public func addEvent(event: UIControl.Event, block: @escaping (Self)->()) {
|
||||
publisher(for: event)
|
||||
.sink(receiveValue: { c in
|
||||
block(c)
|
||||
}).store(in: &subscribers)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user