Merge branch 'feature/bottom_buttons_model_adapter' into 'develop'

add convenience initializers for creating a legacy footer

See merge request BPHV_MIPS/mvm_core_ui!331
This commit is contained in:
Pfeil, Scott Robert 2020-04-03 17:02:44 -04:00
commit 48b026971d
3 changed files with 39 additions and 3 deletions

View File

@ -106,6 +106,7 @@
0AE98BB323FF0934004C5109 /* ExternalLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */; };
0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB423FF18D2004C5109 /* Arrow.swift */; };
0AE98BB723FF18E9004C5109 /* ArrowModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */; };
279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B1568242BBC2F00921D6C /* ActionModelAdapter.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 */; };
@ -500,6 +501,7 @@
0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalLinkModel.swift; sourceTree = "<group>"; };
0AE98BB423FF18D2004C5109 /* Arrow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Arrow.swift; sourceTree = "<group>"; };
0AE98BB623FF18E9004C5109 /* ArrowModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrowModel.swift; sourceTree = "<group>"; };
279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModelAdapter.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>"; };
@ -914,6 +916,14 @@
path = Link;
sourceTree = "<group>";
};
279B1565242BBB8500921D6C /* Adapters */ = {
isa = PBXGroup;
children = (
279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */,
);
path = Adapters;
sourceTree = "<group>";
};
5206F150241144A900658DC5 /* Headers */ = {
isa = PBXGroup;
children = (
@ -1287,6 +1297,7 @@
D22D1F582204D2590077CEC0 /* Legacy */ = {
isa = PBXGroup;
children = (
279B1565242BBB8500921D6C /* Adapters */,
D213347523842FF5008E41B3 /* Views */,
D213347423842FE3008E41B3 /* Controllers */,
);
@ -2119,6 +2130,7 @@
BB2C968F24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift in Sources */,
D29DF29521E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.m in Sources */,
D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */,
279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */,
BB6C6AC0242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */,
D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */,
D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */,

View File

@ -42,18 +42,18 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
/// Temporary binding mechanism for the view to update on enable changes.
public var updateUI: (() -> Void)?
init(with title: String, action: ActionModelProtocol) {
public init(with title: String, action: ActionModelProtocol) {
self.title = title
self.action = action
}
init(secondaryButtonWith title: String, action: ActionModelProtocol) {
public init(secondaryButtonWith title: String, action: ActionModelProtocol) {
self.title = title
self.action = action
style = .secondary
}
init(primaryButtonWith title: String, action: ActionModelProtocol) {
public init(primaryButtonWith title: String, action: ActionModelProtocol) {
self.title = title
self.action = action
style = .primary

View File

@ -0,0 +1,24 @@
//
// ActionModelAdapter.swift
// MVMCoreUI
//
// Created by Kyle on 3/25/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
public extension Dictionary {
func asActionModel() throws -> ActionModelProtocol {
guard let castedSelf = self as? [String: Any] else {
throw ModelRegistry.Error.decoderOther(message: "Dictionary is not of type [String: Any]")
}
guard let actionType = ModelRegistry.getType(for: castedSelf.stringForkey(KeyActionType), with: ActionModelProtocol.self) else {
throw ModelRegistry.Error.decoderErrorModelNotMapped
}
guard let actionModel = try actionType.decode(jsonDict: castedSelf) as? ActionModelProtocol else {
throw ModelRegistry.Error.decoderOther(message: "Could not decode to ActionModelProtocol")
}
return actionModel
}
}