Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
cea37eeb77
commit
68d21296a7
@ -20,7 +20,7 @@ extension SelectorGroup {
|
|||||||
public var hasSelectedItem: Bool { items.filter { $0.isSelected == true }.count > 0 }
|
public var hasSelectedItem: Bool { items.filter { $0.isSelected == true }.count > 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
public protocol SelectorGroupMultiSelect: SelectorGroup {}
|
public protocol SelectorGroupMultiSelect: SelectorGroup, FormFieldable {}
|
||||||
extension SelectorGroupMultiSelect {
|
extension SelectorGroupMultiSelect {
|
||||||
/// Current Selected Control for this group.
|
/// Current Selected Control for this group.
|
||||||
public var selectedItems: [SelectorItemType]? {
|
public var selectedItems: [SelectorItemType]? {
|
||||||
@ -30,7 +30,7 @@ extension SelectorGroupMultiSelect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public protocol SelectorGroupSingleSelect: SelectorGroup {}
|
public protocol SelectorGroupSingleSelect: SelectorGroup, FormFieldable {}
|
||||||
extension SelectorGroupSingleSelect {
|
extension SelectorGroupSingleSelect {
|
||||||
/// Current Selected Control for this group.
|
/// Current Selected Control for this group.
|
||||||
public var selectedItem: SelectorItemType? {
|
public var selectedItem: SelectorItemType? {
|
||||||
@ -39,7 +39,7 @@ extension SelectorGroupSingleSelect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Base Class used for any Grouped Form Control of a Selector Type.
|
/// Base Class used for any Grouped Form Control of a Selector Type.
|
||||||
open class SelectorGroupBase<SelectorItemType: Control>: Control, SelectorGroup, Changeable {
|
open class SelectorGroupBase<SelectorItemType: Control>: Control, SelectorGroup, Changeable {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Properties
|
// MARK: - Private Properties
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import Combine
|
|||||||
import VDSTokens
|
import VDSTokens
|
||||||
|
|
||||||
/// Base Class used to build out a SelectorControlable control.
|
/// Base Class used to build out a SelectorControlable control.
|
||||||
open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable, Changeable, FormFieldable {
|
open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable, Changeable {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
@ -141,8 +141,10 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
|||||||
|
|
||||||
open var inputId: String? { didSet { setNeedsUpdate() } }
|
open var inputId: String? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var value: AnyHashable? { didSet { setNeedsUpdate() } }
|
open var value: AnyHashable? { hiddenValue }
|
||||||
|
|
||||||
|
open var hiddenValue: AnyHashable? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Overrides
|
// MARK: - Overrides
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -214,7 +216,6 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
|||||||
showError = false
|
showError = false
|
||||||
errorText = nil
|
errorText = nil
|
||||||
inputId = nil
|
inputId = nil
|
||||||
value = nil
|
|
||||||
isSelected = false
|
isSelected = false
|
||||||
|
|
||||||
onChange = nil
|
onChange = nil
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import VDSTokens
|
|||||||
/// to allow user selection.
|
/// to allow user selection.
|
||||||
@objc(VDSCheckboxGroup)
|
@objc(VDSCheckboxGroup)
|
||||||
open class CheckboxGroup: SelectorGroupBase<CheckboxItem>, SelectorGroupMultiSelect {
|
open class CheckboxGroup: SelectorGroupBase<CheckboxItem>, SelectorGroupMultiSelect {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -32,6 +33,10 @@ open class CheckboxGroup: SelectorGroupBase<CheckboxItem>, SelectorGroupMultiSel
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var inputId: String?
|
||||||
|
|
||||||
|
public var value: [SelectorItemType]? { selectedItems }
|
||||||
|
|
||||||
/// Array of ``CheckboxItemModel`` that will be used to build the selectorViews of type ``CheckboxItem``.
|
/// Array of ``CheckboxItemModel`` that will be used to build the selectorViews of type ``CheckboxItem``.
|
||||||
open var selectorModels: [CheckboxItemModel]? {
|
open var selectorModels: [CheckboxItemModel]? {
|
||||||
didSet {
|
didSet {
|
||||||
@ -41,7 +46,7 @@ open class CheckboxGroup: SelectorGroupBase<CheckboxItem>, SelectorGroupMultiSel
|
|||||||
$0.isEnabled = !model.disabled
|
$0.isEnabled = !model.disabled
|
||||||
$0.surface = model.surface
|
$0.surface = model.surface
|
||||||
$0.inputId = model.inputId
|
$0.inputId = model.inputId
|
||||||
$0.value = model.value
|
$0.hiddenValue = model.value
|
||||||
$0.accessibilityLabel = model.accessibileText
|
$0.accessibilityLabel = model.accessibileText
|
||||||
$0.accessibilityValue = "item \(index+1) of \(selectorModels.count)"
|
$0.accessibilityValue = "item \(index+1) of \(selectorModels.count)"
|
||||||
$0.labelText = model.labelText
|
$0.labelText = model.labelText
|
||||||
@ -97,7 +102,7 @@ open class CheckboxGroup: SelectorGroupBase<CheckboxItem>, SelectorGroupMultiSel
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension CheckboxGroup {
|
extension CheckboxGroup {
|
||||||
public struct CheckboxItemModel : Surfaceable, Initable, FormFieldable, Errorable {
|
public struct CheckboxItemModel : Surfaceable, Initable, Errorable {
|
||||||
|
|
||||||
/// Whether this object is disabled or not
|
/// Whether this object is disabled or not
|
||||||
public var disabled: Bool
|
public var disabled: Bool
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import Combine
|
|||||||
/// It usually represents a supplementary or utilitarian action. A button icon can stand alone, but often
|
/// It usually represents a supplementary or utilitarian action. A button icon can stand alone, but often
|
||||||
/// exists in a group when there are several actions that can be performed.
|
/// exists in a group when there are several actions that can be performed.
|
||||||
@objc(VDSButtonIcon)
|
@objc(VDSButtonIcon)
|
||||||
open class ButtonIcon: Control, Changeable, FormFieldable {
|
open class ButtonIcon: Control, Changeable {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
@ -173,10 +173,6 @@ open class ButtonIcon: Control, Changeable, FormFieldable {
|
|||||||
/// Used to move the icon inside the button in both x and y axis.
|
/// Used to move the icon inside the button in both x and y axis.
|
||||||
open var iconOffset: CGPoint = .init(x: 0, y: 0) { didSet { setNeedsUpdate() } }
|
open var iconOffset: CGPoint = .init(x: 0, y: 0) { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var inputId: String? { didSet { setNeedsUpdate() } }
|
|
||||||
|
|
||||||
open var value: AnyHashable? { didSet { setNeedsUpdate() } }
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration
|
// MARK: - Configuration
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -32,6 +32,10 @@ open class RadioBoxGroup: SelectorGroupBase<RadioBoxItem>, SelectorGroupSingleSe
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var inputId: String?
|
||||||
|
|
||||||
|
public var value: SelectorItemType? { selectedItem }
|
||||||
|
|
||||||
/// Array of ``RadioBoxItemModel`` that will be used to build the selectorViews of type ``RadioBoxItem``.
|
/// Array of ``RadioBoxItemModel`` that will be used to build the selectorViews of type ``RadioBoxItem``.
|
||||||
open var selectorModels: [RadioBoxItemModel]? {
|
open var selectorModels: [RadioBoxItemModel]? {
|
||||||
didSet {
|
didSet {
|
||||||
@ -48,6 +52,7 @@ open class RadioBoxGroup: SelectorGroupBase<RadioBoxItem>, SelectorGroupSingleSe
|
|||||||
$0.subTextRightAttributes = model.subTextRightAttributes
|
$0.subTextRightAttributes = model.subTextRightAttributes
|
||||||
$0.isEnabled = !model.disabled
|
$0.isEnabled = !model.disabled
|
||||||
$0.inputId = model.inputId
|
$0.inputId = model.inputId
|
||||||
|
$0.hiddenValue = model.value
|
||||||
$0.isSelected = model.selected
|
$0.isSelected = model.selected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,7 +125,9 @@ open class RadioBoxItem: Control, Changeable, FormFieldable {
|
|||||||
|
|
||||||
open var inputId: String? { didSet { setNeedsUpdate() } }
|
open var inputId: String? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var value: AnyHashable? { didSet { setNeedsUpdate() } }
|
open var value: AnyHashable? { hiddenValue }
|
||||||
|
|
||||||
|
open var hiddenValue: AnyHashable? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration Properties
|
// MARK: - Configuration Properties
|
||||||
@ -209,7 +211,7 @@ open class RadioBoxItem: Control, Changeable, FormFieldable {
|
|||||||
subTextRightAttributedText = nil
|
subTextRightAttributedText = nil
|
||||||
strikethrough = false
|
strikethrough = false
|
||||||
inputId = nil
|
inputId = nil
|
||||||
value = nil
|
hiddenValue = nil
|
||||||
|
|
||||||
isSelected = false
|
isSelected = false
|
||||||
onChange = nil
|
onChange = nil
|
||||||
|
|||||||
@ -32,6 +32,10 @@ open class RadioButtonGroup: SelectorGroupBase<RadioButtonItem>, SelectorGroupSi
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var inputId: String?
|
||||||
|
|
||||||
|
public var value: SelectorItemType? { selectedItem }
|
||||||
|
|
||||||
/// Array of ``RadioButtonItemModel`` that will be used to build the selectorViews of type ``RadioButtonItem``.
|
/// Array of ``RadioButtonItemModel`` that will be used to build the selectorViews of type ``RadioButtonItem``.
|
||||||
open var selectorModels: [RadioButtonItemModel]? {
|
open var selectorModels: [RadioButtonItemModel]? {
|
||||||
didSet {
|
didSet {
|
||||||
@ -41,7 +45,7 @@ open class RadioButtonGroup: SelectorGroupBase<RadioButtonItem>, SelectorGroupSi
|
|||||||
$0.isEnabled = !model.disabled
|
$0.isEnabled = !model.disabled
|
||||||
$0.surface = model.surface
|
$0.surface = model.surface
|
||||||
$0.inputId = model.inputId
|
$0.inputId = model.inputId
|
||||||
$0.value = model.value
|
$0.hiddenValue = model.value
|
||||||
$0.accessibilityLabel = model.accessibileText
|
$0.accessibilityLabel = model.accessibileText
|
||||||
$0.accessibilityValue = "item \(index+1) of \(selectorModels.count)"
|
$0.accessibilityValue = "item \(index+1) of \(selectorModels.count)"
|
||||||
$0.labelText = model.labelText
|
$0.labelText = model.labelText
|
||||||
@ -57,7 +61,7 @@ open class RadioButtonGroup: SelectorGroupBase<RadioButtonItem>, SelectorGroupSi
|
|||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var _showError: Bool = false
|
private var _showError: Bool = false
|
||||||
|
|
||||||
/// Whether not to show the error.
|
/// Whether not to show the error.
|
||||||
|
|||||||
@ -145,7 +145,7 @@ open class Toggle: Control, Changeable, FormFieldable {
|
|||||||
|
|
||||||
open var inputId: String? { didSet { setNeedsUpdate() } }
|
open var inputId: String? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var value: AnyHashable? { didSet { setNeedsUpdate() } }
|
open var value: AnyHashable? { isOn }
|
||||||
|
|
||||||
/// The natural size for the receiving view, considering only properties of the view itself.
|
/// The natural size for the receiving view, considering only properties of the view itself.
|
||||||
open override var intrinsicContentSize: CGSize {
|
open override var intrinsicContentSize: CGSize {
|
||||||
@ -224,7 +224,6 @@ open class Toggle: Control, Changeable, FormFieldable {
|
|||||||
textWeight = .regular
|
textWeight = .regular
|
||||||
textPosition = .left
|
textPosition = .left
|
||||||
inputId = nil
|
inputId = nil
|
||||||
value = nil
|
|
||||||
onChange = nil
|
onChange = nil
|
||||||
shouldUpdateView = true
|
shouldUpdateView = true
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
|
|||||||
@ -68,7 +68,7 @@ open class ToggleView: Control, Changeable, FormFieldable {
|
|||||||
|
|
||||||
open var inputId: String? { didSet { setNeedsUpdate() } }
|
open var inputId: String? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var value: AnyHashable? { didSet { setNeedsUpdate() } }
|
open var value: AnyHashable? { isOn }
|
||||||
|
|
||||||
/// The natural size for the receiving view, considering only properties of the view itself.
|
/// The natural size for the receiving view, considering only properties of the view itself.
|
||||||
open override var intrinsicContentSize: CGSize { toggleSize }
|
open override var intrinsicContentSize: CGSize { toggleSize }
|
||||||
@ -163,7 +163,6 @@ open class ToggleView: Control, Changeable, FormFieldable {
|
|||||||
isOn = false
|
isOn = false
|
||||||
isAnimated = true
|
isAnimated = true
|
||||||
inputId = nil
|
inputId = nil
|
||||||
value = nil
|
|
||||||
toggleView.backgroundColor = toggleColorConfiguration.getColor(self)
|
toggleView.backgroundColor = toggleColorConfiguration.getColor(self)
|
||||||
knobView.backgroundColor = knobColorConfiguration.getColor(self)
|
knobView.backgroundColor = knobColorConfiguration.getColor(self)
|
||||||
onChange = nil
|
onChange = nil
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user