diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift index 405a0081..a2d4ff96 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift @@ -145,7 +145,7 @@ import Foundation hideBorders = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideBorders) ?? false baseValue = text fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - shouldMaskRecordedView = try typeContainer.decode(Bool.self, forKey: .shouldMaskRecordedView) + shouldMaskRecordedView = try typeContainer.decodeIfPresent(Bool.self, forKey: .shouldMaskRecordedView) ?? shouldMaskRecordedView if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName } diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 01804b13..8dc1ded9 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -26,8 +26,7 @@ public extension TemplateProtocol where Self: ViewController { model = templateModel as? MVMControllerModelProtocol guard let model = model else { return } traverseAndAddRequiredBehaviors() - var behaviorHandler = self - behaviorHandler.createBehaviors(for: model, delegateObject: delegateObjectIVar) + self.behaviors = createBehaviors(for: model, delegateObject: delegateObjectIVar) MVMCoreUISession.sharedGlobal()?.applyGlobalBehaviors(to: self) } diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index 6ecce3d7..0194ecbd 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -60,7 +60,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol open override func viewForTop() -> UIView { guard let headerModel = templateModel?.header, - let molecule = generateMoleculeView(from: headerModel) + let molecule = generateMoleculeView(from: headerModel) else { return super.viewForTop() } // Temporary, Default the horizontal padding diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 2851b479..b221cf6d 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -230,7 +230,7 @@ import UIKit let navigationItem = createDefaultLegacyNavigationModel() model?.navigationBar = navigationItem } - self.model?.template + executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in behavior.onPageNew(rootMolecules: getRootMolecules(), delegateObjectIVar) } diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift index b8f117d6..9eaddc05 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift @@ -13,9 +13,9 @@ public protocol PageBehaviorHandlerProtocol { public extension PageBehaviorHandlerProtocol { /// Creates the behaviors and sets the variable. - mutating func createBehaviors(for model: PageBehaviorHandlerModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { + func createBehaviors(for model: PageBehaviorHandlerModelProtocol, delegateObject: MVMCoreUIDelegateObject?) -> [PageBehaviorProtocol] { guard let behaviorModels = model.behaviors else { - return + return [] } var behaviors: [PageBehaviorProtocol] = [] @@ -32,8 +32,6 @@ public extension PageBehaviorHandlerProtocol { } } - if behaviors.count > 0 { - self.behaviors = behaviors + (self.behaviors ?? []) - } + return behaviors } }