vds_ios/VDS/Components/Checkbox/CheckboxItem.swift
Matt Bruce 56c2217b0c public to open
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2023-08-04 16:01:38 -05:00

53 lines
1.6 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: - Properties
//--------------------------------------------------
open var isAnimated: Bool = false { didSet { setNeedsUpdate() }}
//--------------------------------------------------
// 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)
}
/// Function used to make changes to the View based off a change events or from local properties.
open override func updateView() {
selectorView.isAnimated = isAnimated
super.updateView()
}
}