updated protocol

This commit is contained in:
Kevin G Christiano 2021-06-22 15:22:27 -04:00
parent 2b378f5597
commit f27e3cd680
3 changed files with 2 additions and 19 deletions

View File

@ -71,14 +71,6 @@
public func formFieldValue() -> AnyHashable? { selected } public func formFieldValue() -> AnyHashable? { selected }
//--------------------------------------------------
// MARK: - Selectable Protocol
//--------------------------------------------------
public func select(as isSelected: Bool) {
selected = isSelected
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializer // MARK: - Initializer
//-------------------------------------------------- //--------------------------------------------------

View File

@ -58,14 +58,6 @@ public class ToggleModel: NSObject, MoleculeModelProtocol, FormFieldProtocol, En
public func formFieldValue() -> AnyHashable? { selected } public func formFieldValue() -> AnyHashable? { selected }
//--------------------------------------------------
// MARK: - Selectable Protocol
//--------------------------------------------------
public func select(as isSelected: Bool) {
selected = isSelected
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializer // MARK: - Initializer
//-------------------------------------------------- //--------------------------------------------------

View File

@ -8,10 +8,9 @@
/// Protocol to apply to any model of a UI Control with a binary on/off nature. /// Protocol to apply to any model of a UI Control with a binary on/off nature.
/// ///
/// Example classes: Checkbox or Switch. /// Example classes: Checkbox or Toggle.
@objc public protocol SelectableMoleculeModel: AnyObject { @objc public protocol SelectableMoleculeModel: AnyObject {
@objc dynamic var selected: Bool { get set } @objc dynamic var selected: Bool { get set }
func select(as isSelected: Bool)
} }
public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol { public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol {
@ -148,7 +147,7 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu
// Iterate through selectable molecules. // Iterate through selectable molecules.
for selectableModel in selectableModels { for selectableModel in selectableModels {
if toSelect(model: selectableModel) || toDeselect(model: selectableModel) { if toSelect(model: selectableModel) || toDeselect(model: selectableModel) {
selectableModel.select(as: didSelectAllState) selectableModel.selected = didSelectAllState
} }
} }