vds_ios/VDS/Components/Checkbox/CheckboxItem.swift
Matt Bruce 42e6f9025c refactored checkbox for new subclasses
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2023-06-05 10:42:42 -05:00

48 lines
1.3 KiB
Swift

//
// Checkbox.swift
// VDS
//
// Created by Matt Bruce on 7/22/22.
//
import Foundation
import UIKit
/// 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(VDSCheckboxItem)
open class CheckboxItem: SelectorItemBase<Checkbox> {
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
required public init() {
super.init(frame: .zero)
}
public override init(frame: CGRect) {
super.init(frame: .zero)
}
public required init?(coder: NSCoder) {
super.init(coder: coder)
}
//--------------------------------------------------
// MARK: - Overrides
//--------------------------------------------------
/// This will checkbox the state of the Selector and execute the actionBlock if provided.
open override func toggle() {
//removed error
if showError && isSelected == false {
showError.toggle()
}
isSelected.toggle()
sendActions(for: .valueChanged)
}
open override func updateView() {
selectorView.isAnimated = isAnimated
super.updateView()
}
}