Merge branch 'feature/swapContactName' into 'develop'

swap contact name changes

See merge request BPHV_MIPS/mvm_core_ui!709
This commit is contained in:
Pfeil, Scott Robert 2021-04-23 12:30:41 -04:00
commit 06e0e47c62
3 changed files with 20 additions and 10 deletions

View File

@ -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
//-----------------------------------------------------

View File

@ -653,7 +653,7 @@ import UIKit
// MARK: - Behavior Execution
//--------------------------------------------------
func executeBehaviors<T>(_ behaviorBlock: (_ behavior: T) -> Void) {
public func executeBehaviors<T>(_ behaviorBlock: (_ behavior: T) -> Void) {
behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) }
}
}

View File

@ -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?) {}
}