move swap label to mf
This commit is contained in:
parent
7a689ea7eb
commit
9dcd7afbac
@ -7,12 +7,12 @@
|
||||
//
|
||||
|
||||
|
||||
@objcMembers public class LabelModel: MoleculeModelProtocol {
|
||||
@objcMembers open class LabelModel: MoleculeModelProtocol {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
public class var identifier: String { "label" }
|
||||
open class var identifier: String { "label" }
|
||||
public var backgroundColor: Color?
|
||||
public var text: String
|
||||
public var accessibilityText: String?
|
||||
|
||||
@ -80,7 +80,7 @@ open class VideoModel: MoleculeModelProtocol, PageBehaviorProtocolRequirer {
|
||||
}
|
||||
|
||||
public func getRequiredBehaviors() -> [PageBehaviorModelProtocol] {
|
||||
return [VisibleBehaviorForVideoModel(with: self), ScrollBehaviorForVideoModel(with: self)]
|
||||
return [VisibleBehaviorForVideoModel(with: self)]
|
||||
}
|
||||
|
||||
open func addVisibilityHalting(for view: Video, delegateObject: MVMCoreUIDelegateObject?) {
|
||||
|
||||
@ -264,7 +264,6 @@ import Foundation
|
||||
// MARK:- Behaviors
|
||||
try? ModelRegistry.register(handler: ScreenBrightnessModifierBehavior.self, for: ScreenBrightnessModifierBehaviorModel.self)
|
||||
try? ModelRegistry.register(handler: PageGetContactBehavior.self, for: PageGetContactBehaviorModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: Label.self, viewModelClass: SwapMDNWithContactNameLabelModel.self)
|
||||
}
|
||||
|
||||
/// Convenience function to get required modules for a give model
|
||||
|
||||
@ -9,27 +9,6 @@
|
||||
import Foundation
|
||||
import Contacts
|
||||
|
||||
public class SwapMDNWithContactNameLabelModel: LabelModel, PageGetContactBehaviorConsumerProtocol, PageBehaviorProtocolRequirer {
|
||||
public class override var identifier: String { "swapMDNWithContactNameLabel" }
|
||||
|
||||
public func getRequiredBehaviors() -> [PageBehaviorModelProtocol] {
|
||||
return [PageGetContactBehaviorModel()]
|
||||
}
|
||||
|
||||
public func getMatchParameters() -> (NSPredicate, [CNKeyDescriptor])? {
|
||||
guard let mdn = MVMCoreUIUtility.removeMdnFormat(text) else { return nil }
|
||||
return (CNContact.predicateForContacts(matching: CNPhoneNumber(stringValue: mdn)), [CNContactFormatter.descriptorForRequiredKeys(for: .fullName)])
|
||||
}
|
||||
|
||||
public func consume(contacts: [CNContact]) {
|
||||
guard let contact = contacts.first else { return }
|
||||
let nameArray: [String?] = [contact.givenName, contact.middleName, contact.familyName]
|
||||
let name = nameArray.compactMap { $0 }.joined(separator: " ")
|
||||
guard name.count > 0 else { return }
|
||||
text = name
|
||||
}
|
||||
}
|
||||
|
||||
public protocol PageGetContactBehaviorConsumerProtocol {
|
||||
func getMatchParameters() -> (NSPredicate, [CNKeyDescriptor])?
|
||||
func consume(contacts: [CNContact])
|
||||
@ -38,6 +17,8 @@ public protocol PageGetContactBehaviorConsumerProtocol {
|
||||
public class PageGetContactBehaviorModel: PageBehaviorModelProtocol {
|
||||
public class var identifier: String { "pageGetContactBehavior" }
|
||||
public var shouldAllowMultipleInstances: Bool { false }
|
||||
|
||||
public init() {}
|
||||
}
|
||||
|
||||
public class PageGetContactBehavior: PageVisibilityBehavior {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user