Merge branch 'feature/external_link' into 'develop'

External link

See merge request BPHV_MIPS/mvm_core_ui!280
This commit is contained in:
Pan, Xinlei (Ryan) 2020-02-27 10:08:42 -05:00
commit 830a93be2c
8 changed files with 109 additions and 10 deletions

View File

@ -94,6 +94,8 @@
0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */; };
0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */; };
0AE14F64238315D2005417F8 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE14F63238315D2005417F8 /* TextField.swift */; };
0AE98BAF23FEF956004C5109 /* ExternalLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BAE23FEF956004C5109 /* ExternalLink.swift */; };
0AE98BB323FF0934004C5109 /* ExternalLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */; };
31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */; };
31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15CA23D8924C00452370 /* CheckboxModel.swift */; };
522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; };
@ -431,6 +433,8 @@
0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryField.swift; sourceTree = "<group>"; };
0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemDropdownEntryField.swift; sourceTree = "<group>"; };
0AE14F63238315D2005417F8 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = "<group>"; };
0AE98BAE23FEF956004C5109 /* ExternalLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalLink.swift; sourceTree = "<group>"; };
0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalLinkModel.swift; sourceTree = "<group>"; };
31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxLabelModel.swift; sourceTree = "<group>"; };
31BE15CA23D8924C00452370 /* CheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxModel.swift; sourceTree = "<group>"; };
522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = "<group>"; };
@ -778,6 +782,17 @@
path = Views;
sourceTree = "<group>";
};
0AE98BAD23FEF92B004C5109 /* Link */ = {
isa = PBXGroup;
children = (
D28A838823CCCFCB00DFE4FC /* LinkModel.swift */,
C07065C32395677300FBF997 /* Link.swift */,
0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */,
0AE98BAE23FEF956004C5109 /* ExternalLink.swift */,
);
path = Link;
sourceTree = "<group>";
};
52267A0523FFE0A900906CBA /* OneColumn */ = {
isa = PBXGroup;
children = (
@ -1279,12 +1294,11 @@
D29DF16821E69E1F003B2FB9 /* Buttons */ = {
isa = PBXGroup;
children = (
0AE98BAD23FEF92B004C5109 /* Link */,
01F2A03123A4498200D954D8 /* CaretLinkModel.swift */,
DBC4391A224421A0001AB423 /* CaretLink.swift */,
D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */,
D2E2A99E23E07F8A000B42E6 /* PillButton.swift */,
D28A838823CCCFCB00DFE4FC /* LinkModel.swift */,
C07065C32395677300FBF997 /* Link.swift */,
D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */,
D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */,
);
@ -1725,6 +1739,7 @@
C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */,
014AA72D23C5059B006F3E93 /* StackPageTemplateModel.swift in Sources */,
D260106123D0C02A00764D80 /* StackItemModelProtocol.swift in Sources */,
0AE98BAF23FEF956004C5109 /* ExternalLink.swift in Sources */,
012A88C4238D86E600FE3DA1 /* CarouselItemModelProtocol.swift in Sources */,
D2E2A9A123E095AB000B42E6 /* ButtonModelProtocol.swift in Sources */,
94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */,
@ -1830,6 +1845,7 @@
0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */,
8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */,
D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */,
0AE98BB323FF0934004C5109 /* ExternalLinkModel.swift in Sources */,
DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */,
0A21DB89235E06EF00C160A2 /* MFMdnTextField.m in Sources */,
D224798A2314445E003FCCF9 /* LabelToggle.swift in Sources */,

View File

@ -0,0 +1,57 @@
//
// ExternalLink.swift
// MVMCoreUI
//
// Created by Kevin Christiano on 2/20/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
open class ExternalLink: Link {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var exportImageView: UIImageView?
//--------------------------------------------------
// MARK: - ModelMoleculeViewProtocol
//--------------------------------------------------
open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let model = model as? ExternalLinkModel else { return }
exportImageView?.tintColor = model.textColor.uiColor
}
//--------------------------------------------------
// MARK: - MVMCoreViewProtocol
//--------------------------------------------------
open override func setupView() {
super.setupView()
let image = MVMCoreUIUtility.imageNamed("externalLink")
exportImageView = UIImageView(image: image?.withRenderingMode(.alwaysTemplate))
guard let exportIcon = exportImageView else { return }
exportIcon.contentMode = .scaleAspectFit
exportIcon.translatesAutoresizingMaskIntoConstraints = false
addSubview(exportIcon)
trailingAnchor.constraint(greaterThanOrEqualTo: exportIcon.trailingAnchor).isActive = true
if let titleLabel = titleLabel {
let dimension = round(0.6 * titleLabel.font.pointSize)
exportIcon.heightAnchor.constraint(equalToConstant: dimension).isActive = true
exportIcon.widthAnchor.constraint(equalToConstant: dimension).isActive = true
exportIcon.leadingAnchor.constraint(equalTo: titleLabel.trailingAnchor, constant: PaddingOne).isActive = true
exportIcon.bottomAnchor.constraint(equalTo: titleLabel.lastBaselineAnchor).isActive = true
}
}
}

View File

@ -0,0 +1,16 @@
//
// ExternalLinkModel.swift
// MVMCoreUI
//
// Created by Kevin Christiano on 2/20/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
open class ExternalLinkModel: LinkModel {
override open class var identifier: String {
return "externalLink"
}
}

View File

@ -40,9 +40,11 @@ import UIKit
// MARK: - ModelMoleculeViewProtocol
//--------------------------------------------------
public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let model = model as? LinkModel else { return }
setTitle(model.title, for: .normal)
setTitleColor(model.textColor.uiColor, for: .normal)
setTitleColor(model.disabledColor.uiColor, for: .disabled)
@ -58,7 +60,7 @@ import UIKit
// MARK: - MVMCoreViewProtocol
extension Link {
public override func updateView(_ size: CGFloat) {
open override func updateView(_ size: CGFloat) {
super.updateView(size)
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
@ -70,7 +72,7 @@ extension Link {
}
}
public override func setupView() {
open override func setupView() {
super.setupView()
backgroundColor = .clear
contentMode = .redraw
@ -86,7 +88,7 @@ extension Link {
// MARK: - MVMCoreUIViewConstrainingProtocol
extension Link: MVMCoreUIViewConstrainingProtocol {
public func horizontalAlignment() -> UIStackView.Alignment {
open func horizontalAlignment() -> UIStackView.Alignment {
return .leading
}
}

View File

@ -8,12 +8,14 @@
import UIKit
public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol {
open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "link"
public class var identifier: String {
return "link"
}
public var backgroundColor: Color?
public var title: String

View File

@ -9,7 +9,9 @@
import Foundation
public extension MFCustomButton {
func set(with action: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
buttonDelegate = delegateObject?.buttonDelegate
add({ [weak self] sender in
guard let self = self else { return }

View File

@ -10,8 +10,11 @@ import Foundation
// temporary until link is finished
extension PrimaryButton: ModelMoleculeViewProtocol {
public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
guard let model = model as? ButtonModel else { return }
setTitle(model.title, for: .normal)
backgroundColor = model.backgroundColor?.uiColor
@ -23,7 +26,6 @@ extension PrimaryButton: ModelMoleculeViewProtocol {
FormValidator.setupValidation(molecule: selfForm, delegate: delegateObject?.formValidationProtocol)
}
if let style = model.style {
switch style {
case .primary:
@ -32,6 +34,7 @@ extension PrimaryButton: ModelMoleculeViewProtocol {
setAsSecondaryCustom()
}
}
if let size = model.size {
switch size {
case .standard:

View File

@ -29,6 +29,7 @@ import Foundation
// Buttons
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: PillButton.self, viewModelClass: ButtonModel.self)
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TwoButtonView.self, viewModelClass: TwoButtonViewModel.self)
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ExternalLink.self, viewModelClass: ExternalLinkModel.self)
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Link.self, viewModelClass: LinkModel.self)
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretLink.self, viewModelClass: CaretLinkModel.self)