ecoding & decoding fillContainer param in TwoButtonView molecule

This commit is contained in:
Sumanth Nadigadda 2024-03-08 18:05:23 +05:30
parent aa6e55e55d
commit deac7b37f0

View File

@ -38,6 +38,7 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol {
case backgroundColor case backgroundColor
case primaryButton case primaryButton
case secondaryButton case secondaryButton
case fillContainer
} }
//-------------------------------------------------- //--------------------------------------------------
@ -69,6 +70,7 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol {
try decoder.setContext(value: Use.secondary, for: "style") { try decoder.setContext(value: Use.secondary, for: "style") {
self.secondaryButton = try typeContainer.decodeMoleculeIfPresent(codingKey: .secondaryButton) self.secondaryButton = try typeContainer.decodeMoleculeIfPresent(codingKey: .secondaryButton)
} }
fillContainer = try typeContainer.decodeIfPresent(Bool.self, forKey: .fillContainer) ?? false
} }
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
@ -78,5 +80,6 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol {
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeIfPresent(primaryButton, forKey: .primaryButton) try container.encodeIfPresent(primaryButton, forKey: .primaryButton)
try container.encodeIfPresent(secondaryButton, forKey: .secondaryButton) try container.encodeIfPresent(secondaryButton, forKey: .secondaryButton)
try container.encodeIfPresent(fillContainer, forKey: .fillContainer)
} }
} }