diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift index 9d9291e8..3129776b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift @@ -6,7 +6,8 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // -public class ListLeftVariableIconWithRightCaretAllTextLinksModel: ListItemModel, MoleculeModelProtocol { +public class ListLeftVariableIconWithRightCaretAllTextLinksModel: ListItemModel, ParentMoleculeModelProtocol { + //----------------------------------------------------- // MARK: - Properties //----------------------------------------------------- @@ -16,6 +17,10 @@ public class ListLeftVariableIconWithRightCaretAllTextLinksModel: ListItemModel, public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel public var rightLabel: LabelModel + public var children: [MoleculeModelProtocol] { + return [image, eyebrowHeadlineBodyLink, rightLabel] + } + //----------------------------------------------------- // MARK: - Methods //----------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift index ec646f86..83f5b4bd 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift @@ -73,7 +73,7 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol, ParentMolecule backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) headline = try typeContainer.decodeMoleculeIfPresent(codingKey: .headline) - body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body) + body = try typeContainer.decodeMoleculeIfPresent(codingKey: .body) link = try typeContainer.decodeIfPresent(LinkModel.self, forKey: .link) setDefaults() // TODO: This class initializers should ensure that atleast one item is set. diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 293bd49f..8a22e23a 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -653,7 +653,7 @@ import UIKit // MARK: - Behavior Execution //-------------------------------------------------- - func executeBehaviors(_ behaviorBlock: (_ behavior: T) -> Void) { + public func executeBehaviors(_ behaviorBlock: (_ behavior: T) -> Void) { behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) } } } diff --git a/MVMCoreUI/Behaviors/GetContactBehavior.swift b/MVMCoreUI/Behaviors/GetContactBehavior.swift index 2c6205f2..1bb27ac7 100644 --- a/MVMCoreUI/Behaviors/GetContactBehavior.swift +++ b/MVMCoreUI/Behaviors/GetContactBehavior.swift @@ -22,6 +22,7 @@ public class PageGetContactBehaviorModel: PageBehaviorModelProtocol { } public class PageGetContactBehavior: PageVisibilityBehavior { + var delegate: MVMCoreUIDelegateObject? public required init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { @@ -35,21 +36,25 @@ public class PageGetContactBehavior: PageVisibilityBehavior { error == nil, let rootMolecules = self?.delegate?.moleculeDelegate?.getRootMolecules() else { return } // Iterate models and provide contact - let store = CNContactStore() - let consumers: [PageGetContactBehaviorConsumerProtocol] = rootMolecules.allMoleculesOfType() - for consumer in consumers { - guard let parameters = consumer.getMatchParameters(), - let contacts = try? store.unifiedContacts(matching: parameters.0, keysToFetch: parameters.1) else { return } - consumer.consume(contacts: contacts) - } + self?.getContacts(for: rootMolecules) // Tell template to update MVMCoreDispatchUtility.performBlock(onMainThread: { // TODO: move to protocol function instead - (self?.delegate?.moleculeDelegate as? ViewController)?.handleNewData() + (self?.delegate?.moleculeDelegate as? ViewController)?.handleNewDataAndUpdateUI() }) } } + public func getContacts(for molecules: [MoleculeModelProtocol]) { + let consumers: [PageGetContactBehaviorConsumerProtocol] = molecules.allMoleculesOfType() + let store = CNContactStore() + for consumer in consumers { + guard let parameters = consumer.getMatchParameters(), + let contacts = try? store.unifiedContacts(matching: parameters.0, keysToFetch: parameters.1) else { return } + consumer.consume(contacts: contacts) + } + } + public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) {} }