refactored model to remove default text

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-07-30 16:13:17 -05:00
parent 3d86b8fcf7
commit eab6fb5f3b

View File

@ -28,8 +28,8 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol {
public var surface: Surface { inverted ? .dark : .light } public var surface: Surface { inverted ? .dark : .light }
public var inverted: Bool = false public var inverted: Bool = false
public var showText: Bool = false public var showText: Bool = false
public var onText: String = "On" public var onText: String?
public var offText: String = "Off" public var offText: String?
public var textSize: VDS.Toggle.TextSize = .small public var textSize: VDS.Toggle.TextSize = .small
public var textWeight: VDS.Toggle.TextWeight = .regular public var textWeight: VDS.Toggle.TextWeight = .regular
public var textPosition: VDS.Toggle.TextPosition = .left 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 inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) ?? false
showText = try typeContainer.decodeIfPresent(Bool.self, forKey: .showText) ?? false showText = try typeContainer.decodeIfPresent(Bool.self, forKey: .showText) ?? false
onText = try typeContainer.decodeIfPresent(String.self, forKey: .onText) ?? "On" onText = try typeContainer.decodeIfPresent(String.self, forKey: .onText)
offText = try typeContainer.decodeIfPresent(String.self, forKey: .offText) ?? "Off" offText = try typeContainer.decodeIfPresent(String.self, forKey: .offText)
textSize = try typeContainer.decodeIfPresent(VDS.Toggle.TextSize.self, forKey: .textSize) ?? .small textSize = try typeContainer.decodeIfPresent(VDS.Toggle.TextSize.self, forKey: .textSize) ?? .small
textWeight = try typeContainer.decodeIfPresent(VDS.Toggle.TextWeight.self, forKey: .textWeight) ?? .regular textWeight = try typeContainer.decodeIfPresent(VDS.Toggle.TextWeight.self, forKey: .textWeight) ?? .regular
textPosition = try typeContainer.decodeIfPresent(VDS.Toggle.TextPosition.self, forKey: .textPosition) ?? .left 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(inverted, forKey: .inverted)
try container.encode(showText, forKey: .showText) try container.encode(showText, forKey: .showText)
try container.encode(onText, forKey: .onText) try container.encodeIfPresent(onText, forKey: .onText)
try container.encode(offText, forKey: .offText) try container.encodeIfPresent(offText, forKey: .offText)
try container.encode(textSize, forKey: .textSize) try container.encode(textSize, forKey: .textSize)
try container.encode(textWeight, forKey: .textWeight) try container.encode(textWeight, forKey: .textWeight)
try container.encode(textPosition, forKey: .textPosition) try container.encode(textPosition, forKey: .textPosition)