Merge branch 'feature/coding' of https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui into feature/unordered_numbered_list_from_coding
This commit is contained in:
commit
31aabef3ae
@ -93,7 +93,7 @@
|
||||
944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589202385D6E900DE9FD4 /* DashLineModel.swift */; };
|
||||
944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589222385DA9500DE9FD4 /* ImageViewModel.swift */; };
|
||||
9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; };
|
||||
946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; };
|
||||
946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */; };
|
||||
948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; };
|
||||
94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */; };
|
||||
94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */; };
|
||||
@ -369,7 +369,7 @@
|
||||
944589202385D6E900DE9FD4 /* DashLineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashLineModel.swift; sourceTree = "<group>"; };
|
||||
944589222385DA9500DE9FD4 /* ImageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewModel.swift; sourceTree = "<group>"; };
|
||||
9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = "<group>"; };
|
||||
946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = "<group>"; };
|
||||
946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeModelHelper.swift; sourceTree = "<group>"; };
|
||||
948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = "<group>"; };
|
||||
94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeModel.swift; sourceTree = "<group>"; };
|
||||
94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeUnderlineModel.swift; sourceTree = "<group>"; };
|
||||
@ -704,7 +704,7 @@
|
||||
946EE1B5237B663A0036751F /* Extensions */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
946EE1B9237B66D80036751F /* ModelHelper.swift */,
|
||||
946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */,
|
||||
);
|
||||
path = Extensions;
|
||||
sourceTree = "<group>";
|
||||
@ -1588,7 +1588,6 @@
|
||||
012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */,
|
||||
D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */,
|
||||
C003506123AA94CD00B6AC29 /* Button.swift in Sources */,
|
||||
D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */,
|
||||
DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */,
|
||||
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */,
|
||||
0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */,
|
||||
@ -1616,7 +1615,7 @@
|
||||
01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */,
|
||||
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */,
|
||||
D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */,
|
||||
946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */,
|
||||
946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */,
|
||||
01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */,
|
||||
D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */,
|
||||
);
|
||||
|
||||
@ -36,8 +36,8 @@ public class ButtonModel: MoleculeProtocol {
|
||||
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)
|
||||
style = try typeContainer.decode(ButtonStyle.self, forKey: .style)
|
||||
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
|
||||
style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
@ -45,7 +45,7 @@ public class CaretLinkModel: MoleculeProtocol {
|
||||
if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) {
|
||||
self.enabled = enabled
|
||||
}
|
||||
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.type)
|
||||
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
@ -33,7 +33,7 @@ public class LinkModel: MoleculeProtocol {
|
||||
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)
|
||||
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
|
||||
if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) {
|
||||
self.enabled = enabled
|
||||
}
|
||||
|
||||
@ -16,9 +16,6 @@ extension MFTextButton: ModelMoleculeViewProtocol {
|
||||
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)
|
||||
}
|
||||
set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,9 +22,6 @@ extension PrimaryButton: ModelMoleculeViewProtocol {
|
||||
setAsSecondaryCustom()
|
||||
}
|
||||
}
|
||||
//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)
|
||||
}
|
||||
set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,6 @@ extension MFViewController: MoleculeDelegateProtocol {
|
||||
}
|
||||
|
||||
public extension MFViewController {
|
||||
@objc func parsePageJSON() {
|
||||
@objc func parsePageJSON() throws {
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +96,15 @@
|
||||
- (BOOL)shouldFinishProcessingLoad:(nonnull MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error {
|
||||
self.pageType = loadObject.pageType;
|
||||
self.loadObject = loadObject;
|
||||
[self parsePageJSON];
|
||||
|
||||
NSError *parseError = nil;
|
||||
[self parsePageJSONAndReturnError:&parseError];
|
||||
if (parseError) {
|
||||
if (error) {
|
||||
*error = [MVMCoreErrorObject createErrorObjectForNSError:parseError location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verifies all modules needed are loaded.
|
||||
return [MFViewController verifyRequiredModulesLoadedForLoadObject:loadObject error:error];
|
||||
@ -250,7 +258,8 @@
|
||||
|
||||
- (BOOL)newPageLoaded:(nonnull NSDictionary *)page {
|
||||
self.loadObject.pageJSON = page;
|
||||
[self parsePageJSON];
|
||||
NSError *parseError = nil;
|
||||
[self parsePageJSONAndReturnError:&parseError];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// ModelHelper.swift
|
||||
// MoleculeModelHelper.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Ryan on 11/12/19.
|
||||
@ -14,15 +14,11 @@ public protocol TemplateProtocol: class {
|
||||
}
|
||||
|
||||
public extension TemplateProtocol where Self: MFViewController {
|
||||
func parseTemplateJSON() {
|
||||
func parseTemplateJSON() throws {
|
||||
guard let pageJSON = self.loadObject?.pageJSON else { return }
|
||||
do {
|
||||
let data = try JSONSerialization.data(withJSONObject: pageJSON)
|
||||
let decoder = JSONDecoder()
|
||||
let templateModel = try decoder.decode(TemplateModel.self, from: data)
|
||||
self.templateModel = templateModel
|
||||
} catch {
|
||||
MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)")
|
||||
}
|
||||
let data = try JSONSerialization.data(withJSONObject: pageJSON)
|
||||
let decoder = JSONDecoder()
|
||||
let templateModel = try decoder.decode(TemplateModel.self, from: data)
|
||||
self.templateModel = templateModel
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
@objcMembers public class ListPageTemplateModel: TemplateModelProtocol {
|
||||
|
||||
public static var identifier: String = "listTemplate"
|
||||
public static var identifier: String = "list"
|
||||
|
||||
public var pageType: String
|
||||
public var screenHeading: String?
|
||||
|
||||
@ -15,7 +15,7 @@ import MVMCore
|
||||
public var action: ActionProtocol?
|
||||
public var hideArrow: Bool?
|
||||
public var line: LineModel?
|
||||
public var style: String?
|
||||
public var style: String? = "standard"
|
||||
|
||||
enum ListItemCodingKeys: String, CodingKey {
|
||||
case backgroundColor
|
||||
@ -28,13 +28,23 @@ import MVMCore
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: ListItemCodingKeys.self)
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.type)
|
||||
action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
|
||||
hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow)
|
||||
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
||||
style = try typeContainer.decodeIfPresent(String.self, forKey: .style)
|
||||
if let style = try typeContainer.decodeIfPresent(String.self, forKey: .style) {
|
||||
self.style = style
|
||||
}
|
||||
|
||||
try super.init(from: decoder)
|
||||
|
||||
if useHorizontalMargins == nil {
|
||||
useHorizontalMargins = true
|
||||
}
|
||||
if useVerticalMargins == nil {
|
||||
useVerticalMargins = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
try super.encode(to: encoder)
|
||||
var container = encoder.container(keyedBy: ListItemCodingKeys.self)
|
||||
@ -43,5 +53,6 @@ import MVMCore
|
||||
try container.encodeIfPresent(hideArrow, forKey: .hideArrow)
|
||||
try container.encodeIfPresent(line, forKey: .line)
|
||||
try container.encodeIfPresent(style, forKey: .style)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -24,10 +24,11 @@ import Foundation
|
||||
ModelRegistry.register(TabsModel.self)
|
||||
ModelRegistry.register(ScrollerModel.self)
|
||||
ModelRegistry.register(CornerLabelsModel.self)
|
||||
// buttons
|
||||
ModelRegistry.register(LineModel.self)
|
||||
// buttons
|
||||
ModelRegistry.register(ButtonModel.self)
|
||||
ModelRegistry.register(TwoButtonViewModel.self)
|
||||
ModelRegistry.register(LinkModel.self)
|
||||
// list items
|
||||
ModelRegistry.register(ListItemModel.self)
|
||||
ModelRegistry.register(DropDownListItemModel.self)
|
||||
@ -37,7 +38,7 @@ import Foundation
|
||||
//need to move labelattributemodel to different method
|
||||
ModelRegistry.register(LabelAttributeFontModel.self)
|
||||
ModelRegistry.register(LabelAttributeColorModel.self)
|
||||
ModelRegistry.register(LabelAttributeImageModel.self)
|
||||
//ModelRegistry.register(LabelAttributeImageModel.self) // We need to separate the registry by types due to collisions...
|
||||
ModelRegistry.register(LabelAttributeUnderlineModel.self)
|
||||
ModelRegistry.register(LabelAttributeStrikeThroughModel.self)
|
||||
ModelRegistry.register(LabelAttributeActionModel.self)
|
||||
|
||||
@ -14,8 +14,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
||||
var observer: NSKeyValueObservation?
|
||||
|
||||
public var templateModel: ListPageTemplateModel?
|
||||
public override func parsePageJSON() {
|
||||
parseTemplateJSON()
|
||||
@objc public override func parsePageJSON() throws {
|
||||
try parseTemplateJSON()
|
||||
}
|
||||
|
||||
open override var loadObject: MVMCoreLoadObject? {
|
||||
|
||||
@ -12,8 +12,8 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol {
|
||||
|
||||
var observer: NSKeyValueObservation?
|
||||
public var templateModel: StackPageTemplateModel?
|
||||
public override func parsePageJSON() {
|
||||
parseTemplateJSON()
|
||||
public override func parsePageJSON() throws {
|
||||
try parseTemplateJSON()
|
||||
}
|
||||
|
||||
open override var loadObject: MVMCoreLoadObject? {
|
||||
|
||||
@ -11,8 +11,8 @@ import UIKit
|
||||
@objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol {
|
||||
|
||||
public var templateModel: ThreeLayerPageTemplateModel?
|
||||
public override func parsePageJSON() {
|
||||
parseTemplateJSON()
|
||||
@objc public override func parsePageJSON() throws {
|
||||
try parseTemplateJSON()
|
||||
}
|
||||
|
||||
override open func viewDidLoad() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user