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:
Murugan, Vimal 2020-01-14 21:57:12 +05:30
commit 31aabef3ae
16 changed files with 54 additions and 44 deletions

View File

@ -93,7 +93,7 @@
944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589202385D6E900DE9FD4 /* DashLineModel.swift */; }; 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589202385D6E900DE9FD4 /* DashLineModel.swift */; };
944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589222385DA9500DE9FD4 /* ImageViewModel.swift */; }; 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589222385DA9500DE9FD4 /* ImageViewModel.swift */; };
9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; 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 */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; };
94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */; }; 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */; };
94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.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>"; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeUnderlineModel.swift; sourceTree = "<group>"; };
@ -704,7 +704,7 @@
946EE1B5237B663A0036751F /* Extensions */ = { 946EE1B5237B663A0036751F /* Extensions */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
946EE1B9237B66D80036751F /* ModelHelper.swift */, 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */,
); );
path = Extensions; path = Extensions;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1588,7 +1588,6 @@
012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */, 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */,
D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */,
C003506123AA94CD00B6AC29 /* Button.swift in Sources */, C003506123AA94CD00B6AC29 /* Button.swift in Sources */,
D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */,
DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */, DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */,
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */, 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */,
0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */, 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */,
@ -1616,7 +1615,7 @@
01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */, 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */,
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */,
D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */, D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */,
946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */, 946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */,
01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */, 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */,
D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */, D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */,
); );

View File

@ -36,8 +36,8 @@ public class ButtonModel: MoleculeProtocol {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
title = try typeContainer.decode(String.self, forKey: .title) 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)
style = try typeContainer.decode(ButtonStyle.self, forKey: .style) style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style)
} }
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {

View File

@ -45,7 +45,7 @@ public class CaretLinkModel: MoleculeProtocol {
if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) {
self.enabled = 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 { public func encode(to encoder: Encoder) throws {

View File

@ -33,7 +33,7 @@ public class LinkModel: MoleculeProtocol {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
title = try typeContainer.decode(String.self, forKey: .title) 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) { if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) {
self.enabled = enabled self.enabled = enabled
} }

View File

@ -16,9 +16,6 @@ extension MFTextButton: ModelMoleculeViewProtocol {
setTitleColor(model.textColor.uiColor, for: .normal) setTitleColor(model.textColor.uiColor, for: .normal)
isEnabled = model.enabled isEnabled = model.enabled
backgroundColor = model.backgroundColor?.uiColor backgroundColor = model.backgroundColor?.uiColor
//TODO: Use object when handleAction is rewrote to handle action model set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)
if let actionMap = model.action.toJSON() {
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
}
} }
} }

View File

@ -22,9 +22,6 @@ extension PrimaryButton: ModelMoleculeViewProtocol {
setAsSecondaryCustom() setAsSecondaryCustom()
} }
} }
//TODO: Use object when handleAction is rewrote to handle action model set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)
if let actionMap = model.action.toJSON() {
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
}
} }
} }

View File

@ -32,6 +32,6 @@ extension MFViewController: MoleculeDelegateProtocol {
} }
public extension MFViewController { public extension MFViewController {
@objc func parsePageJSON() { @objc func parsePageJSON() throws {
} }
} }

View File

@ -96,7 +96,15 @@
- (BOOL)shouldFinishProcessingLoad:(nonnull MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error { - (BOOL)shouldFinishProcessingLoad:(nonnull MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error {
self.pageType = loadObject.pageType; self.pageType = loadObject.pageType;
self.loadObject = loadObject; 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. // Verifies all modules needed are loaded.
return [MFViewController verifyRequiredModulesLoadedForLoadObject:loadObject error:error]; return [MFViewController verifyRequiredModulesLoadedForLoadObject:loadObject error:error];
@ -250,7 +258,8 @@
- (BOOL)newPageLoaded:(nonnull NSDictionary *)page { - (BOOL)newPageLoaded:(nonnull NSDictionary *)page {
self.loadObject.pageJSON = page; self.loadObject.pageJSON = page;
[self parsePageJSON]; NSError *parseError = nil;
[self parsePageJSONAndReturnError:&parseError];
return YES; return YES;
} }

View File

@ -1,5 +1,5 @@
// //
// ModelHelper.swift // MoleculeModelHelper.swift
// MVMCoreUI // MVMCoreUI
// //
// Created by Ryan on 11/12/19. // Created by Ryan on 11/12/19.

View File

@ -14,15 +14,11 @@ public protocol TemplateProtocol: class {
} }
public extension TemplateProtocol where Self: MFViewController { public extension TemplateProtocol where Self: MFViewController {
func parseTemplateJSON() { func parseTemplateJSON() throws {
guard let pageJSON = self.loadObject?.pageJSON else { return } guard let pageJSON = self.loadObject?.pageJSON else { return }
do { let data = try JSONSerialization.data(withJSONObject: pageJSON)
let data = try JSONSerialization.data(withJSONObject: pageJSON) let decoder = JSONDecoder()
let decoder = JSONDecoder() let templateModel = try decoder.decode(TemplateModel.self, from: data)
let templateModel = try decoder.decode(TemplateModel.self, from: data) self.templateModel = templateModel
self.templateModel = templateModel
} catch {
MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)")
}
} }
} }

View File

@ -10,7 +10,7 @@ import Foundation
@objcMembers public class ListPageTemplateModel: TemplateModelProtocol { @objcMembers public class ListPageTemplateModel: TemplateModelProtocol {
public static var identifier: String = "listTemplate" public static var identifier: String = "list"
public var pageType: String public var pageType: String
public var screenHeading: String? public var screenHeading: String?

View File

@ -15,7 +15,7 @@ import MVMCore
public var action: ActionProtocol? public var action: ActionProtocol?
public var hideArrow: Bool? public var hideArrow: Bool?
public var line: LineModel? public var line: LineModel?
public var style: String? public var style: String? = "standard"
enum ListItemCodingKeys: String, CodingKey { enum ListItemCodingKeys: String, CodingKey {
case backgroundColor case backgroundColor
@ -28,13 +28,23 @@ import MVMCore
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: ListItemCodingKeys.self) let typeContainer = try decoder.container(keyedBy: ListItemCodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) 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) hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow)
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) 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) try super.init(from: decoder)
if useHorizontalMargins == nil {
useHorizontalMargins = true
}
if useVerticalMargins == nil {
useVerticalMargins = true
}
} }
public override func encode(to encoder: Encoder) throws { public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder) try super.encode(to: encoder)
var container = encoder.container(keyedBy: ListItemCodingKeys.self) var container = encoder.container(keyedBy: ListItemCodingKeys.self)
@ -43,5 +53,6 @@ import MVMCore
try container.encodeIfPresent(hideArrow, forKey: .hideArrow) try container.encodeIfPresent(hideArrow, forKey: .hideArrow)
try container.encodeIfPresent(line, forKey: .line) try container.encodeIfPresent(line, forKey: .line)
try container.encodeIfPresent(style, forKey: .style) try container.encodeIfPresent(style, forKey: .style)
} }
} }

View File

@ -24,10 +24,11 @@ import Foundation
ModelRegistry.register(TabsModel.self) ModelRegistry.register(TabsModel.self)
ModelRegistry.register(ScrollerModel.self) ModelRegistry.register(ScrollerModel.self)
ModelRegistry.register(CornerLabelsModel.self) ModelRegistry.register(CornerLabelsModel.self)
// buttons
ModelRegistry.register(LineModel.self) ModelRegistry.register(LineModel.self)
// buttons
ModelRegistry.register(ButtonModel.self) ModelRegistry.register(ButtonModel.self)
ModelRegistry.register(TwoButtonViewModel.self) ModelRegistry.register(TwoButtonViewModel.self)
ModelRegistry.register(LinkModel.self)
// list items // list items
ModelRegistry.register(ListItemModel.self) ModelRegistry.register(ListItemModel.self)
ModelRegistry.register(DropDownListItemModel.self) ModelRegistry.register(DropDownListItemModel.self)
@ -37,7 +38,7 @@ import Foundation
//need to move labelattributemodel to different method //need to move labelattributemodel to different method
ModelRegistry.register(LabelAttributeFontModel.self) ModelRegistry.register(LabelAttributeFontModel.self)
ModelRegistry.register(LabelAttributeColorModel.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(LabelAttributeUnderlineModel.self)
ModelRegistry.register(LabelAttributeStrikeThroughModel.self) ModelRegistry.register(LabelAttributeStrikeThroughModel.self)
ModelRegistry.register(LabelAttributeActionModel.self) ModelRegistry.register(LabelAttributeActionModel.self)

View File

@ -14,8 +14,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
var observer: NSKeyValueObservation? var observer: NSKeyValueObservation?
public var templateModel: ListPageTemplateModel? public var templateModel: ListPageTemplateModel?
public override func parsePageJSON() { @objc public override func parsePageJSON() throws {
parseTemplateJSON() try parseTemplateJSON()
} }
open override var loadObject: MVMCoreLoadObject? { open override var loadObject: MVMCoreLoadObject? {

View File

@ -12,8 +12,8 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol {
var observer: NSKeyValueObservation? var observer: NSKeyValueObservation?
public var templateModel: StackPageTemplateModel? public var templateModel: StackPageTemplateModel?
public override func parsePageJSON() { public override func parsePageJSON() throws {
parseTemplateJSON() try parseTemplateJSON()
} }
open override var loadObject: MVMCoreLoadObject? { open override var loadObject: MVMCoreLoadObject? {

View File

@ -11,8 +11,8 @@ import UIKit
@objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol { @objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol {
public var templateModel: ThreeLayerPageTemplateModel? public var templateModel: ThreeLayerPageTemplateModel?
public override func parsePageJSON() { @objc public override func parsePageJSON() throws {
parseTemplateJSON() try parseTemplateJSON()
} }
override open func viewDidLoad() { override open func viewDidLoad() {