From eab6fb5f3b52509f331c448226c5bfbac6a08080 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 30 Jul 2024 16:13:17 -0500 Subject: [PATCH] refactored model to remove default text Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index 398ba42c..c310e47c 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -28,8 +28,8 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { public var surface: Surface { inverted ? .dark : .light } public var inverted: Bool = false public var showText: Bool = false - public var onText: String = "On" - public var offText: String = "Off" + public var onText: String? + public var offText: String? public var textSize: VDS.Toggle.TextSize = .small public var textWeight: VDS.Toggle.TextWeight = .regular public var textPosition: VDS.Toggle.TextPosition = .left @@ -126,8 +126,8 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) ?? false showText = try typeContainer.decodeIfPresent(Bool.self, forKey: .showText) ?? false - onText = try typeContainer.decodeIfPresent(String.self, forKey: .onText) ?? "On" - offText = try typeContainer.decodeIfPresent(String.self, forKey: .offText) ?? "Off" + onText = try typeContainer.decodeIfPresent(String.self, forKey: .onText) + offText = try typeContainer.decodeIfPresent(String.self, forKey: .offText) textSize = try typeContainer.decodeIfPresent(VDS.Toggle.TextSize.self, forKey: .textSize) ?? .small textWeight = try typeContainer.decodeIfPresent(VDS.Toggle.TextWeight.self, forKey: .textWeight) ?? .regular textPosition = try typeContainer.decodeIfPresent(VDS.Toggle.TextPosition.self, forKey: .textPosition) ?? .left @@ -151,8 +151,8 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { try container.encode(inverted, forKey: .inverted) try container.encode(showText, forKey: .showText) - try container.encode(onText, forKey: .onText) - try container.encode(offText, forKey: .offText) + try container.encodeIfPresent(onText, forKey: .onText) + try container.encodeIfPresent(offText, forKey: .offText) try container.encode(textSize, forKey: .textSize) try container.encode(textWeight, forKey: .textWeight) try container.encode(textPosition, forKey: .textPosition)