From c40dc5e396bb312091c99ad1722a5f31198a274b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 22 Aug 2024 13:11:35 -0500 Subject: [PATCH] added isEqual to RadioBox variations Signed-off-by: Matt Bruce --- .../Atoms/Selectors/RadioBoxModel.swift | 23 ++++++++++++++++++- .../Atoms/Selectors/RadioBoxesModel.swift | 10 ++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift index 90f12a09..ad7dad7d 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift @@ -31,7 +31,6 @@ public class RadioBoxModel: FormFieldModel { case text case subText case subTextRight - case backgroundColor case selected case strikethrough case action @@ -90,4 +89,26 @@ public class RadioBoxModel: FormFieldModel { try container.encode(strikethrough, forKey: .strikethrough) try container.encodeModelIfPresent(action, forKey: .action) } + + open override func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard super.isEqual(to: model), let model = model as? Self else { return false } + return text == model.text + && subText == model.subText + && subTextRight == model.subTextRight + && selected == model.selected + && strikethrough == model.strikethrough + && fieldValue == model.fieldValue + && action.isEqual(to: model.action) + } + + open override func isVisuallyEquivalent(to model: any MoleculeModelComparisonProtocol) -> Bool { + guard super.isVisuallyEquivalent(to: model), let model = model as? Self else { return false } + return text == model.text + && subText == model.subText + && subTextRight == model.subTextRight + && selected == model.selected + && strikethrough == model.strikethrough + && fieldValue == model.fieldValue + } } + diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift index a5a66a5d..f1bf76f4 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift @@ -69,6 +69,16 @@ public class RadioBoxesModel: FormFieldModel { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(boxes, forKey: .boxes) } + + open override func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard super.isEqual(to: model), let model = model as? Self else { return false } + return boxes == model.boxes + } + + open override func isVisuallyEquivalent(to model: any MoleculeModelComparisonProtocol) -> Bool { + guard super.isVisuallyEquivalent(to: model), let model = model as? Self else { return false } + return boxes == model.boxes + } } extension Array where Element == RadioBoxModel {