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 Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import Combine
|
||||||
|
|
||||||
public class SelectorGroupHandlerBase<HandlerType: Control>: Control {
|
public class SelectorGroupHandlerBase<HandlerType: Control>: Control, Changeable {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public var selectorViews: [HandlerType] = []
|
public var selectorViews: [HandlerType] = []
|
||||||
|
|
||||||
|
public var onChangeSubscriber: AnyCancellable? {
|
||||||
|
willSet {
|
||||||
|
if let onChangeSubscriber {
|
||||||
|
onChangeSubscriber.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Overrides
|
// MARK: - Overrides
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -7,13 +7,13 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import Combine
|
||||||
import VDSColorTokens
|
import VDSColorTokens
|
||||||
import VDSFormControlsTokens
|
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``.
|
/// 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)
|
@objc(VDSCheckboxBase)
|
||||||
open class Checkbox: Control, Errorable {
|
open class Checkbox: Control, Errorable, Changeable {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
@ -63,6 +63,14 @@ open class Checkbox: Control, Errorable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var onChangeSubscriber: AnyCancellable? {
|
||||||
|
willSet {
|
||||||
|
if let onChangeSubscriber {
|
||||||
|
onChangeSubscriber.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open var label = Label().with {
|
open var label = Label().with {
|
||||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
$0.textPosition = .left
|
$0.textPosition = .left
|
||||||
|
|||||||
@ -7,12 +7,12 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import Combine
|
||||||
import VDSColorTokens
|
import VDSColorTokens
|
||||||
import VDSFormControlsTokens
|
import VDSFormControlsTokens
|
||||||
import Combine
|
|
||||||
|
|
||||||
@objc(VDSRadioBox)
|
@objc(VDSRadioBox)
|
||||||
open class RadioBox: Control {
|
open class RadioBox: Control, Changeable {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
@ -56,6 +56,14 @@ open class RadioBox: Control {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var onChangeSubscriber: AnyCancellable? {
|
||||||
|
willSet {
|
||||||
|
if let onChangeSubscriber {
|
||||||
|
onChangeSubscriber.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open var textLabel = Label().with {
|
open var textLabel = Label().with {
|
||||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
$0.textPosition = .left
|
$0.textPosition = .left
|
||||||
|
|||||||
@ -7,11 +7,12 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import Combine
|
||||||
import VDSColorTokens
|
import VDSColorTokens
|
||||||
import VDSFormControlsTokens
|
import VDSFormControlsTokens
|
||||||
|
|
||||||
@objc(VDSRadioButton)
|
@objc(VDSRadioButton)
|
||||||
open class RadioButton: Control, Errorable {
|
open class RadioButton: Control, Errorable, Changeable {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
@ -61,6 +62,14 @@ open class RadioButton: Control, Errorable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var onChangeSubscriber: AnyCancellable? {
|
||||||
|
willSet {
|
||||||
|
if let onChangeSubscriber {
|
||||||
|
onChangeSubscriber.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open var label = Label().with {
|
open var label = Label().with {
|
||||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
$0.textPosition = .left
|
$0.textPosition = .left
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import VDSFormControlsTokens
|
|||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
@objc(VDSEntryField)
|
@objc(VDSEntryField)
|
||||||
open class EntryField: Control {
|
open class EntryField: Control, Changeable {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Enums
|
// MARK: - Enums
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -98,6 +98,14 @@ open class EntryField: Control {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var onChangeSubscriber: AnyCancellable? {
|
||||||
|
willSet {
|
||||||
|
if let onChangeSubscriber {
|
||||||
|
onChangeSubscriber.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open var titleLabel = Label().with {
|
open var titleLabel = Label().with {
|
||||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
$0.attributes = []
|
$0.attributes = []
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import Combine
|
|||||||
Knob: The circular indicator that slides on the container.
|
Knob: The circular indicator that slides on the container.
|
||||||
*/
|
*/
|
||||||
@objc(VDSToggle)
|
@objc(VDSToggle)
|
||||||
open class Toggle: Control {
|
open class Toggle: Control, Changeable {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Enums
|
// MARK: - Enums
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -107,6 +107,14 @@ open class Toggle: Control {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var onChangeSubscriber: AnyCancellable? {
|
||||||
|
willSet {
|
||||||
|
if let onChangeSubscriber {
|
||||||
|
onChangeSubscriber.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open var label = Label().with {
|
open var label = Label().with {
|
||||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,13 +15,6 @@ public protocol Clickable: Handlerable where Self: UIControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Clickable {
|
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) -> ())? {
|
public var onClick: ((Self) -> ())? {
|
||||||
get { return nil }
|
get { return nil }
|
||||||
set {
|
set {
|
||||||
|
|||||||
@ -34,3 +34,12 @@ extension Handlerable where Self: UIView {
|
|||||||
subject.send()
|
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