swap contact name changes
This commit is contained in:
parent
94f42b32bf
commit
2204e2fd77
@ -6,7 +6,8 @@
|
|||||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
public class ListLeftVariableIconWithRightCaretAllTextLinksModel: ListItemModel, MoleculeModelProtocol {
|
public class ListLeftVariableIconWithRightCaretAllTextLinksModel: ListItemModel, ParentMoleculeModelProtocol {
|
||||||
|
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
@ -16,6 +17,10 @@ public class ListLeftVariableIconWithRightCaretAllTextLinksModel: ListItemModel,
|
|||||||
public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel
|
public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel
|
||||||
public var rightLabel: LabelModel
|
public var rightLabel: LabelModel
|
||||||
|
|
||||||
|
public var children: [MoleculeModelProtocol] {
|
||||||
|
return [image, eyebrowHeadlineBodyLink,rightLabel]
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
// MARK: - Methods
|
// MARK: - Methods
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
|
|||||||
@ -653,7 +653,7 @@ import UIKit
|
|||||||
// MARK: - Behavior Execution
|
// 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) }
|
behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,8 @@ public class PageGetContactBehaviorModel: PageBehaviorModelProtocol {
|
|||||||
public init() {}
|
public init() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PageGetContactBehavior: PageVisibilityBehavior {
|
public class PageGetContactBehavior: PageVisibilityBehavior,PageNextBatchActionBehavior {
|
||||||
|
|
||||||
var delegate: MVMCoreUIDelegateObject?
|
var delegate: MVMCoreUIDelegateObject?
|
||||||
|
|
||||||
public required init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) {
|
public required init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) {
|
||||||
@ -32,24 +33,34 @@ public class PageGetContactBehavior: PageVisibilityBehavior {
|
|||||||
// Ask for permission
|
// Ask for permission
|
||||||
CNContactStore().requestAccess(for: .contacts) { [weak self] (access, error) in
|
CNContactStore().requestAccess(for: .contacts) { [weak self] (access, error) in
|
||||||
guard access,
|
guard access,
|
||||||
error == nil,
|
error == nil else { return }
|
||||||
let rootMolecules = self?.delegate?.moleculeDelegate?.getRootMolecules() else { return }
|
|
||||||
// Iterate models and provide contact
|
// Iterate models and provide contact
|
||||||
let store = CNContactStore()
|
self?.getContacts()
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tell template to update
|
// Tell template to update
|
||||||
MVMCoreDispatchUtility.performBlock(onMainThread: {
|
MVMCoreDispatchUtility.performBlock(onMainThread: {
|
||||||
// TODO: move to protocol function instead
|
// TODO: move to protocol function instead
|
||||||
(self?.delegate?.moleculeDelegate as? ViewController)?.handleNewData()
|
(self?.delegate?.moleculeDelegate as? ViewController)?.handleNewDataAndUpdateUI()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getContacts() {
|
||||||
|
guard let rootMolecules = self.delegate?.moleculeDelegate?.getRootMolecules() else { return }
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) {}
|
public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) {}
|
||||||
|
|
||||||
|
public func nextBatchAction(_ delegateObject: MVMCoreUIDelegateObject?) {
|
||||||
|
if CNContactStore.authorizationStatus(for: .contacts) == .authorized {
|
||||||
|
getContacts()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,12 @@ public protocol PageLocalDataShareBehavior: PageBehaviorProtocol {
|
|||||||
func receiveLocalPageData(_ data:[AnyHashable: Any], _ delegateObject: MVMCoreUIDelegateObject)
|
func receiveLocalPageData(_ data:[AnyHashable: Any], _ delegateObject: MVMCoreUIDelegateObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public protocol PageNextBatchActionBehavior: PageBehaviorProtocol {
|
||||||
|
|
||||||
|
func nextBatchAction(_ delegateObject: MVMCoreUIDelegateObject?)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public protocol PageCustomActionHandlerBehavior: PageBehaviorProtocol {
|
public protocol PageCustomActionHandlerBehavior: PageBehaviorProtocol {
|
||||||
|
|
||||||
func handleAction(type actionType: String?, information: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) -> Bool
|
func handleAction(type actionType: String?, information: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) -> Bool
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user