Link update
This commit is contained in:
parent
73c19383b6
commit
bb0be72519
@ -126,6 +126,8 @@
|
||||
D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */; };
|
||||
D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */; };
|
||||
D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */; };
|
||||
D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */; };
|
||||
D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838823CCCFCB00DFE4FC /* LinkModel.swift */; };
|
||||
D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; };
|
||||
D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@ -387,6 +389,8 @@
|
||||
D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccordionListItemModel.swift; sourceTree = "<group>"; };
|
||||
D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleProgressModel.swift; sourceTree = "<group>"; };
|
||||
D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollerModel.swift; sourceTree = "<group>"; };
|
||||
D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextButton+ModelExtension.swift"; sourceTree = "<group>"; };
|
||||
D28A838823CCCFCB00DFE4FC /* LinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkModel.swift; sourceTree = "<group>"; };
|
||||
D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = "<group>"; };
|
||||
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = "<group>"; };
|
||||
D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = "<group>"; };
|
||||
@ -998,6 +1002,8 @@
|
||||
D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */,
|
||||
D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */,
|
||||
D282AACA2243C61700C46919 /* ButtonView.swift */,
|
||||
D28A838823CCCFCB00DFE4FC /* LinkModel.swift */,
|
||||
D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */,
|
||||
D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */,
|
||||
D29DF17221E69E1F003B2FB9 /* MFTextButton.m */,
|
||||
);
|
||||
@ -1343,6 +1349,7 @@
|
||||
DBC4391822442197001AB423 /* CaretView.swift in Sources */,
|
||||
D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */,
|
||||
D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */,
|
||||
D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */,
|
||||
94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */,
|
||||
DBC4391922442197001AB423 /* DashLine.swift in Sources */,
|
||||
0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */,
|
||||
@ -1383,6 +1390,7 @@
|
||||
D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */,
|
||||
D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */,
|
||||
D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */,
|
||||
D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */,
|
||||
D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */,
|
||||
014AA72D23C5059B006F3E93 /* StackPageTemplateModel.swift in Sources */,
|
||||
012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */,
|
||||
|
||||
53
MVMCoreUI/Atoms/Buttons/LinkModel.swift
Normal file
53
MVMCoreUI/Atoms/Buttons/LinkModel.swift
Normal file
@ -0,0 +1,53 @@
|
||||
//
|
||||
// LinkModel.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 1/13/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
public class LinkModel: MoleculeProtocol {
|
||||
public static var identifier: String = "link"
|
||||
public var backgroundColor: Color?
|
||||
public var title: String
|
||||
public var action: ActionProtocol
|
||||
public var enabled = true
|
||||
public var textColor = Color(uiColor: .mfTextButton())
|
||||
|
||||
public init(title: String, action: ActionProtocol) {
|
||||
self.title = title
|
||||
self.action = action
|
||||
}
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case backgroundColor
|
||||
case title
|
||||
case action
|
||||
case enabled
|
||||
case textColor
|
||||
}
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
title = try typeContainer.decode(String.self, forKey: .title)
|
||||
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.type)
|
||||
if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) {
|
||||
self.enabled = enabled
|
||||
}
|
||||
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor) {
|
||||
textColor = color
|
||||
}
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(title, forKey: .title)
|
||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||
try container.encodeModel(action, forKey: .action)
|
||||
try container.encode(enabled, forKey: .enabled)
|
||||
try container.encode(textColor, forKey: .textColor)
|
||||
}
|
||||
}
|
||||
24
MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift
Normal file
24
MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift
Normal file
@ -0,0 +1,24 @@
|
||||
//
|
||||
// MFTextButton_ModelExtension.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 1/13/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
// temporary until link is finished
|
||||
extension MFTextButton: ModelMoleculeViewProtocol {
|
||||
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
guard let model = model as? LinkModel else { return }
|
||||
setTitle(model.title, for: .normal)
|
||||
setTitleColor(model.textColor.uiColor, for: .normal)
|
||||
isEnabled = model.enabled
|
||||
backgroundColor = model.backgroundColor?.uiColor
|
||||
//TODO: Use object when handleAction is rewrote to handle action model
|
||||
if let actionMap = model.action.toJSON() {
|
||||
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -18,7 +18,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol {
|
||||
public var link: LineModel?
|
||||
}
|
||||
|
||||
@objcMembers open class EyebrowHeadlineBodyLink: ViewConstrainingView {
|
||||
@objcMembers open class EyebrowHeadlineBodyLink: Container {
|
||||
let stack = MoleculeStackView(frame: .zero)
|
||||
let eyebrow = Label.commonLabelB3(true)
|
||||
let headline = Label.commonLabelB1(true)
|
||||
@ -48,7 +48,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol {
|
||||
stack.stackItems = [StackItem(andContain: eyebrow),StackItem(andContain: headline),StackItem(andContain: body),StackItem(andContain: link)]
|
||||
|
||||
addSubview(stack)
|
||||
pinView(toSuperView: stack)
|
||||
NSLayoutConstraint.constraintPinSubview(toSuperview: stack)
|
||||
}
|
||||
|
||||
open override func updateView(_ size: CGFloat) {
|
||||
@ -57,17 +57,23 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol {
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||
|
||||
open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
super.setWithModel(model, delegateObject, additionalData)
|
||||
eyebrow.setWithModel(casteModel?.eyeBrow, delegateObject, additionalData)
|
||||
headline.setWithModel(casteModel?.headline, delegateObject, additionalData)
|
||||
body.setWithModel(casteModel?.body, delegateObject, additionalData)
|
||||
link.setWithModel(casteModel?.link, delegateObject, additionalData)
|
||||
|
||||
(stack.stackItems[0].model as? StackItemModel)?.gone = !eyebrow.hasText
|
||||
(stack.stackItems[1].model as? StackItemModel)?.gone = !headline.hasText
|
||||
(stack.stackItems[2].model as? StackItemModel)?.gone = !body.hasText
|
||||
(stack.stackItems[3].model as? StackItemModel)?.gone = ((link.titleLabel?.text?.count) ?? 0) == 0
|
||||
stack.restack()
|
||||
}
|
||||
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
/* eyebrow.setWithJSON(json?.optionalDictionaryForKey("eyebrow"), delegateObject: delegateObject, additionalData: additionalData)
|
||||
stack.stackItems[0].gone = !eyebrow.hasText
|
||||
headline.setWithJSON(json?.optionalDictionaryForKey("headline"), delegateObject: delegateObject, additionalData: additionalData)
|
||||
stack.stackItems[1].gone = !headline.hasText
|
||||
body.setWithJSON(json?.optionalDictionaryForKey("body"), delegateObject: delegateObject, additionalData: additionalData)
|
||||
stack.stackItems[2].gone = !body.hasText
|
||||
link.setWithJSON(json?.optionalDictionaryForKey("link"), delegateObject: delegateObject, additionalData: additionalData)
|
||||
stack.stackItems[3].gone = link.titleLabel?.text?.count ?? 0 == 0
|
||||
stack.restack()*/
|
||||
guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: EyebrowHeadlineBodyLinkModel.self) else { return }
|
||||
setWithModel(model, delegateObject, additionalData)
|
||||
}
|
||||
|
||||
open override func reset() {
|
||||
@ -79,7 +85,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol {
|
||||
body.styleB2(true)
|
||||
}
|
||||
|
||||
public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
return 65
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user