From d1b1db196731efe482254b170835f81cc87cfe89 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Thu, 4 Aug 2022 22:19:20 +0530 Subject: [PATCH] Updating logic to read style params from context, JSON and default --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 7c6f9ef6..3c702d49 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -206,15 +206,14 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat title = try typeContainer.decode(String.self, forKey: .title) action = try typeContainer.decodeModel(codingKey: .action) + ///Reading the style param from context which is set is molecules, ex: TwoButtonView if let style = decoder.context?.value(forKey: CodingKeys.style.stringValue) as? Styler.Button.Style{ self.style = style setFacade(by: style) - } - - if let style = try typeContainer.decodeIfPresent(Styler.Button.Style.self, forKey: .style) { + } else if let style = try typeContainer.decodeIfPresent(Styler.Button.Style.self, forKey: .style) { ///Style captured from the JSON self.style = style setFacade(by: style) - } else { + } else { ///Default style setFacade(by: .primary) }