Signed-off-by: Matt Bruce <matt.bruce@verizon.com>

This commit is contained in:
Matt Bruce 2024-04-29 15:16:56 -05:00
parent cea37eeb77
commit 68d21296a7
9 changed files with 32 additions and 21 deletions

View File

@ -20,7 +20,7 @@ extension SelectorGroup {
public var hasSelectedItem: Bool { items.filter { $0.isSelected == true }.count > 0 }
}
public protocol SelectorGroupMultiSelect: SelectorGroup {}
public protocol SelectorGroupMultiSelect: SelectorGroup, FormFieldable {}
extension SelectorGroupMultiSelect {
/// Current Selected Control for this group.
public var selectedItems: [SelectorItemType]? {
@ -30,7 +30,7 @@ extension SelectorGroupMultiSelect {
}
}
public protocol SelectorGroupSingleSelect: SelectorGroup {}
public protocol SelectorGroupSingleSelect: SelectorGroup, FormFieldable {}
extension SelectorGroupSingleSelect {
/// Current Selected Control for this group.
public var selectedItem: SelectorItemType? {

View File

@ -11,7 +11,7 @@ import Combine
import VDSTokens
/// 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
@ -141,7 +141,9 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
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
@ -214,7 +216,6 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
showError = false
errorText = nil
inputId = nil
value = nil
isSelected = false
onChange = nil

View File

@ -14,6 +14,7 @@ import VDSTokens
/// to allow user selection.
@objc(VDSCheckboxGroup)
open class CheckboxGroup: SelectorGroupBase<CheckboxItem>, SelectorGroupMultiSelect {
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
@ -32,6 +33,10 @@ open class CheckboxGroup: SelectorGroupBase<CheckboxItem>, SelectorGroupMultiSel
//--------------------------------------------------
// 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``.
open var selectorModels: [CheckboxItemModel]? {
didSet {
@ -41,7 +46,7 @@ open class CheckboxGroup: SelectorGroupBase<CheckboxItem>, SelectorGroupMultiSel
$0.isEnabled = !model.disabled
$0.surface = model.surface
$0.inputId = model.inputId
$0.value = model.value
$0.hiddenValue = model.value
$0.accessibilityLabel = model.accessibileText
$0.accessibilityValue = "item \(index+1) of \(selectorModels.count)"
$0.labelText = model.labelText
@ -97,7 +102,7 @@ open class CheckboxGroup: SelectorGroupBase<CheckboxItem>, SelectorGroupMultiSel
}
extension CheckboxGroup {
public struct CheckboxItemModel : Surfaceable, Initable, FormFieldable, Errorable {
public struct CheckboxItemModel : Surfaceable, Initable, Errorable {
/// Whether this object is disabled or not
public var disabled: Bool

View File

@ -14,7 +14,7 @@ import Combine
/// 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.
@objc(VDSButtonIcon)
open class ButtonIcon: Control, Changeable, FormFieldable {
open class ButtonIcon: Control, Changeable {
//--------------------------------------------------
// 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.
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
//--------------------------------------------------

View File

@ -32,6 +32,10 @@ open class RadioBoxGroup: SelectorGroupBase<RadioBoxItem>, SelectorGroupSingleSe
//--------------------------------------------------
// 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``.
open var selectorModels: [RadioBoxItemModel]? {
didSet {
@ -48,6 +52,7 @@ open class RadioBoxGroup: SelectorGroupBase<RadioBoxItem>, SelectorGroupSingleSe
$0.subTextRightAttributes = model.subTextRightAttributes
$0.isEnabled = !model.disabled
$0.inputId = model.inputId
$0.hiddenValue = model.value
$0.isSelected = model.selected
}
}

View File

@ -125,7 +125,9 @@ open class RadioBoxItem: Control, Changeable, FormFieldable {
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
@ -209,7 +211,7 @@ open class RadioBoxItem: Control, Changeable, FormFieldable {
subTextRightAttributedText = nil
strikethrough = false
inputId = nil
value = nil
hiddenValue = nil
isSelected = false
onChange = nil

View File

@ -32,6 +32,10 @@ open class RadioButtonGroup: SelectorGroupBase<RadioButtonItem>, SelectorGroupSi
//--------------------------------------------------
// 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``.
open var selectorModels: [RadioButtonItemModel]? {
didSet {
@ -41,7 +45,7 @@ open class RadioButtonGroup: SelectorGroupBase<RadioButtonItem>, SelectorGroupSi
$0.isEnabled = !model.disabled
$0.surface = model.surface
$0.inputId = model.inputId
$0.value = model.value
$0.hiddenValue = model.value
$0.accessibilityLabel = model.accessibileText
$0.accessibilityValue = "item \(index+1) of \(selectorModels.count)"
$0.labelText = model.labelText

View File

@ -145,7 +145,7 @@ open class Toggle: Control, Changeable, FormFieldable {
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.
open override var intrinsicContentSize: CGSize {
@ -224,7 +224,6 @@ open class Toggle: Control, Changeable, FormFieldable {
textWeight = .regular
textPosition = .left
inputId = nil
value = nil
onChange = nil
shouldUpdateView = true
setNeedsUpdate()

View File

@ -68,7 +68,7 @@ open class ToggleView: Control, Changeable, FormFieldable {
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.
open override var intrinsicContentSize: CGSize { toggleSize }
@ -163,7 +163,6 @@ open class ToggleView: Control, Changeable, FormFieldable {
isOn = false
isAnimated = true
inputId = nil
value = nil
toggleView.backgroundColor = toggleColorConfiguration.getColor(self)
knobView.backgroundColor = knobColorConfiguration.getColor(self)
onChange = nil