diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift index 190d3a01..ca6f1e52 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift @@ -7,6 +7,7 @@ // import Foundation +import VDS @objcMembers open class FormFieldModel: MoleculeModelProtocol, FormFieldProtocol, FormRuleWatcherFieldProtocol, UIUpdatableModelProtocol { @@ -28,6 +29,9 @@ import Foundation public var fieldKey: String? public var groupName: String = FormValidator.defaultGroupName public var baseValue: AnyHashable? + + public var inverted: Bool = false + public var surface: Surface { inverted ? .dark : .light } public var dynamicErrorMessage: String? { didSet { @@ -66,6 +70,7 @@ import Foundation case required case fieldKey case groupName + case inverted } //-------------------------------------------------- @@ -103,6 +108,10 @@ import Foundation readOnly = try typeContainer.decodeIfPresent(Bool.self, forKey: .readOnly) ?? false fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) ?? FormValidator.defaultGroupName + + if let inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) { + self.inverted = inverted + } } open func encode(to encoder: Encoder) throws { @@ -116,5 +125,6 @@ import Foundation try container.encode(readOnly, forKey: .readOnly) try container.encode(enabled, forKey: .enabled) try container.encode(required, forKey: .required) + try container.encode(inverted, forKey: .inverted) } }